package commands import ( "fmt" "strings" ) // RegisterConsoleCommands registers all console-level commands func RegisterConsoleCommands(cm *CommandManager) error { commands := []*Command{ // Player management commands { Name: "console_ban", Type: CommandTypeConsole, Description: "Bans a player account", Usage: "console_ban [duration] [reason]", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleBan, }, { Name: "console_unban", Type: CommandTypeConsole, Description: "Unbans a player account", Usage: "console_unban ", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleUnban, }, { Name: "console_kick", Type: CommandTypeConsole, Description: "Kicks a player from the server", Usage: "console_kick [reason]", RequiredLevel: AdminLevelGM, Handler: HandleConsoleKick, }, // Communication commands { Name: "console_announce", Type: CommandTypeConsole, Description: "Announces a message to all players", Usage: "console_announce ", RequiredLevel: AdminLevelGM, Handler: HandleConsoleAnnounce, }, { Name: "console_broadcast", Type: CommandTypeConsole, Description: "Broadcasts a message to all players", Usage: "console_broadcast ", RequiredLevel: AdminLevelGM, Handler: HandleConsoleBroadcast, }, { Name: "channel", Type: CommandTypeConsole, Description: "Sends message to specific channel", Usage: "channel ", RequiredLevel: AdminLevelGM, Handler: HandleConsoleChannel, }, { Name: "console_tell", Type: CommandTypeConsole, Description: "Sends private message to a player", Usage: "console_tell ", RequiredLevel: AdminLevelGM, Handler: HandleConsoleTell, }, // Information commands { Name: "console_guild", Type: CommandTypeConsole, Description: "Guild management commands", Usage: "console_guild [options]", RequiredLevel: AdminLevelGM, Handler: HandleConsoleGuild, }, { Name: "player", Type: CommandTypeConsole, Description: "Player information and management", Usage: "player [options]", RequiredLevel: AdminLevelGM, Handler: HandleConsolePlayer, }, { Name: "setadmin", Type: CommandTypeConsole, Description: "Sets admin level for a player", Usage: "setadmin ", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleSetAdmin, }, { Name: "world", Type: CommandTypeConsole, Description: "World server information", Usage: "world", RequiredLevel: AdminLevelGM, Handler: HandleConsoleWorld, }, { Name: "console_zone", Type: CommandTypeConsole, Description: "Zone information and management", Usage: "console_zone [options]", RequiredLevel: AdminLevelGM, Handler: HandleConsoleZone, }, { Name: "console_who", Type: CommandTypeConsole, Description: "Lists players online", Usage: "console_who [pattern]", RequiredLevel: AdminLevelGM, Handler: HandleConsoleWho, }, // MOTD commands { Name: "getmotd", Type: CommandTypeConsole, Description: "Gets the current MOTD", Usage: "getmotd", RequiredLevel: AdminLevelGM, Handler: HandleConsoleGetMOTD, }, { Name: "setmotd", Type: CommandTypeConsole, Description: "Sets the MOTD", Usage: "setmotd ", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleSetMOTD, }, // Server management commands { Name: "console_reload", Type: CommandTypeConsole, Description: "Reloads server data", Usage: "console_reload ", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleReload, }, { Name: "console_shutdown", Type: CommandTypeConsole, Description: "Shuts down the server", Usage: "console_shutdown [time_minutes] [reason]", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleShutdown, }, { Name: "console_cancelshutdown", Type: CommandTypeConsole, Description: "Cancels a scheduled shutdown", Usage: "console_cancelshutdown", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleCancelShutdown, }, { Name: "exit", Type: CommandTypeConsole, Description: "Exits the server immediately", Usage: "exit", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleExit, }, { Name: "rules", Type: CommandTypeConsole, Description: "Rules management commands", Usage: "rules [options]", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleRules, }, // Testing commands { Name: "console_test", Type: CommandTypeConsole, Description: "Testing command for development", Usage: "console_test [parameters]", RequiredLevel: AdminLevelAdmin, Handler: HandleConsoleTest, }, } for _, cmd := range commands { if err := cm.Register(cmd); err != nil { return fmt.Errorf("failed to register console command %s: %w", cmd.Name, err) } } return nil } // HandleConsoleBan handles the console ban command func HandleConsoleBan(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(1, -1); err != nil { ctx.AddErrorMessage("Usage: ban [duration] [reason]") return nil } playerName := ctx.Arguments[0] duration := "permanent" reason := "Banned by administrator" if ctx.ArgumentCount() > 1 { duration = ctx.Arguments[1] } if ctx.ArgumentCount() > 2 { reason = ctx.GetRemainingArguments(2) } // TODO: Implement actual ban functionality ctx.AddStatusMessage(fmt.Sprintf("Banned player '%s' for %s with reason: %s", playerName, duration, reason)) return nil } // HandleConsoleUnban handles the console unban command func HandleConsoleUnban(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(1, 1); err != nil { ctx.AddErrorMessage("Usage: unban ") return nil } playerName := ctx.Arguments[0] // TODO: Implement actual unban functionality ctx.AddStatusMessage(fmt.Sprintf("Unbanned player '%s'", playerName)) return nil } // HandleConsoleKick handles the console kick command func HandleConsoleKick(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(1, -1); err != nil { ctx.AddErrorMessage("Usage: kick [reason]") return nil } playerName := ctx.Arguments[0] reason := "Kicked by administrator" if ctx.ArgumentCount() > 1 { reason = ctx.GetRemainingArguments(1) } // TODO: Implement actual kick functionality ctx.AddStatusMessage(fmt.Sprintf("Kicked player '%s' with reason: %s", playerName, reason)) return nil } // HandleConsoleAnnounce handles the console announce command func HandleConsoleAnnounce(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(1, -1); err != nil { ctx.AddErrorMessage("Usage: announce ") return nil } message := ctx.RawArguments // TODO: Implement server announcement ctx.AddMessage(ChannelBroadcast, ColorRed, fmt.Sprintf("[ANNOUNCEMENT] %s", message)) return nil } // HandleConsoleBroadcast handles the console broadcast command func HandleConsoleBroadcast(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(1, -1); err != nil { ctx.AddErrorMessage("Usage: broadcast ") return nil } message := ctx.RawArguments // TODO: Implement server-wide broadcast ctx.AddMessage(ChannelBroadcast, ColorYellow, fmt.Sprintf("[BROADCAST] %s", message)) return nil } // HandleConsoleChannel handles the console channel command func HandleConsoleChannel(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(2, -1); err != nil { ctx.AddErrorMessage("Usage: channel ") return nil } channelID := ctx.GetArgumentInt(0, 0) message := ctx.GetRemainingArguments(1) if channelID < 0 { ctx.AddErrorMessage("Invalid channel ID") return nil } // TODO: Implement channel message sending ctx.AddMessage(channelID, ColorWhite, message) ctx.AddStatusMessage(fmt.Sprintf("Sent message to channel %d: %s", channelID, message)) return nil } // HandleConsoleTell handles the console tell command func HandleConsoleTell(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(2, -1); err != nil { ctx.AddErrorMessage("Usage: tell ") return nil } targetName := ctx.Arguments[0] message := ctx.GetRemainingArguments(1) // TODO: Implement tell system ctx.AddStatusMessage(fmt.Sprintf("Told %s: %s", targetName, message)) return nil } // HandleConsoleGuild handles the console guild command func HandleConsoleGuild(ctx *CommandContext) error { if ctx.ArgumentCount() == 0 { ctx.AddErrorMessage("Usage: guild [options]") return nil } subCommand := strings.ToLower(ctx.Arguments[0]) switch subCommand { case "list": // TODO: List all guilds ctx.AddStatusMessage("Guild listing (not yet implemented)") case "info": if ctx.ArgumentCount() < 2 { ctx.AddErrorMessage("Usage: guild info ") return nil } guildName := ctx.Arguments[1] ctx.AddStatusMessage(fmt.Sprintf("Guild info for '%s' (not yet implemented)", guildName)) case "delete": if ctx.ArgumentCount() < 2 { ctx.AddErrorMessage("Usage: guild delete ") return nil } guildName := ctx.Arguments[1] ctx.AddStatusMessage(fmt.Sprintf("Deleted guild '%s' (not yet implemented)", guildName)) default: ctx.AddErrorMessage("Usage: guild [options]") } return nil } // HandleConsolePlayer handles the console player command func HandleConsolePlayer(ctx *CommandContext) error { if ctx.ArgumentCount() == 0 { ctx.AddErrorMessage("Usage: player [options]") return nil } subCommand := strings.ToLower(ctx.Arguments[0]) switch subCommand { case "list": // TODO: List all players ctx.AddStatusMessage("Player listing (not yet implemented)") case "info": if ctx.ArgumentCount() < 2 { ctx.AddErrorMessage("Usage: player info ") return nil } playerName := ctx.Arguments[1] ctx.AddStatusMessage(fmt.Sprintf("Player info for '%s' (not yet implemented)", playerName)) case "modify": if ctx.ArgumentCount() < 4 { ctx.AddErrorMessage("Usage: player modify ") return nil } playerName := ctx.Arguments[1] attribute := ctx.Arguments[2] value := ctx.Arguments[3] ctx.AddStatusMessage(fmt.Sprintf("Modified %s's %s to %s (not yet implemented)", playerName, attribute, value)) default: ctx.AddErrorMessage("Usage: player [options]") } return nil } // HandleConsoleSetAdmin handles the console setadmin command func HandleConsoleSetAdmin(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(2, 2); err != nil { ctx.AddErrorMessage("Usage: setadmin ") return nil } playerName := ctx.Arguments[0] adminLevel := ctx.GetArgumentInt(1, 0) if adminLevel < 0 || adminLevel > 300 { ctx.AddErrorMessage("Admin level must be between 0 and 300") return nil } // TODO: Implement admin level setting ctx.AddStatusMessage(fmt.Sprintf("Set %s's admin level to %d", playerName, adminLevel)) return nil } // HandleConsoleWorld handles the console world command func HandleConsoleWorld(ctx *CommandContext) error { // TODO: Show world server statistics ctx.AddStatusMessage("World Server Status:") ctx.AddStatusMessage(" Uptime: 1 hour 23 minutes (not yet implemented)") ctx.AddStatusMessage(" Players Online: 5 (not yet implemented)") ctx.AddStatusMessage(" Zones Active: 12 (not yet implemented)") ctx.AddStatusMessage(" Memory Usage: 256MB (not yet implemented)") return nil } // HandleConsoleZone handles the console zone command func HandleConsoleZone(ctx *CommandContext) error { if ctx.ArgumentCount() == 0 { ctx.AddErrorMessage("Usage: zone [options]") return nil } subCommand := strings.ToLower(ctx.Arguments[0]) switch subCommand { case "list": // TODO: List all zones ctx.AddStatusMessage("Zone listing (not yet implemented)") case "info": if ctx.ArgumentCount() < 2 { ctx.AddErrorMessage("Usage: zone info ") return nil } zoneName := ctx.Arguments[1] ctx.AddStatusMessage(fmt.Sprintf("Zone info for '%s' (not yet implemented)", zoneName)) case "shutdown": if ctx.ArgumentCount() < 2 { ctx.AddErrorMessage("Usage: zone shutdown ") return nil } zoneName := ctx.Arguments[1] ctx.AddStatusMessage(fmt.Sprintf("Shutting down zone '%s' (not yet implemented)", zoneName)) default: ctx.AddErrorMessage("Usage: zone [options]") } return nil } // HandleConsoleWho handles the console who command func HandleConsoleWho(ctx *CommandContext) error { pattern := "" if ctx.ArgumentCount() > 0 { pattern = ctx.Arguments[0] } // TODO: Implement player listing if pattern != "" { ctx.AddStatusMessage(fmt.Sprintf("Players matching '%s':", pattern)) } else { ctx.AddStatusMessage("Players online:") } ctx.AddStatusMessage(" TestPlayer (Zone: Qeynos, Level: 10)") ctx.AddStatusMessage("Total: 1 player online") return nil } // HandleConsoleGetMOTD handles the console getmotd command func HandleConsoleGetMOTD(ctx *CommandContext) error { // TODO: Get actual MOTD from database ctx.AddStatusMessage("Current MOTD:") ctx.AddStatusMessage(" Welcome to EQ2Go Server!") return nil } // HandleConsoleSetMOTD handles the console setmotd command func HandleConsoleSetMOTD(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(1, -1); err != nil { ctx.AddErrorMessage("Usage: setmotd ") return nil } message := ctx.RawArguments // TODO: Set MOTD in database ctx.AddStatusMessage(fmt.Sprintf("MOTD set to: %s", message)) return nil } // HandleConsoleReload handles the console reload command func HandleConsoleReload(ctx *CommandContext) error { if err := ctx.ValidateArgumentCount(1, 1); err != nil { ctx.AddErrorMessage("Usage: reload ") return nil } reloadType := strings.ToLower(ctx.Arguments[0]) switch reloadType { case "spells": ctx.AddStatusMessage("Reloaded spells") case "quests": ctx.AddStatusMessage("Reloaded quests") case "zones": ctx.AddStatusMessage("Reloaded zones") case "items": ctx.AddStatusMessage("Reloaded items") case "rules": ctx.AddStatusMessage("Reloaded rules") case "all": ctx.AddStatusMessage("Reloaded all server data") default: ctx.AddErrorMessage("Usage: reload ") } return nil } // HandleConsoleShutdown handles the console shutdown command func HandleConsoleShutdown(ctx *CommandContext) error { minutes := 5 // Default 5 minutes reason := "Server maintenance" if ctx.ArgumentCount() > 0 { minutes = ctx.GetArgumentInt(0, 5) } if ctx.ArgumentCount() > 1 { reason = ctx.GetRemainingArguments(1) } // TODO: Implement server shutdown ctx.AddStatusMessage(fmt.Sprintf("Server shutdown scheduled in %d minutes. Reason: %s", minutes, reason)) return nil } // HandleConsoleCancelShutdown handles the console cancelshutdown command func HandleConsoleCancelShutdown(ctx *CommandContext) error { // TODO: Implement shutdown cancellation ctx.AddStatusMessage("Server shutdown cancelled") return nil } // HandleConsoleExit handles the console exit command func HandleConsoleExit(ctx *CommandContext) error { // TODO: Implement immediate server exit ctx.AddStatusMessage("Exiting server immediately...") return nil } // HandleConsoleRules handles the console rules command func HandleConsoleRules(ctx *CommandContext) error { if ctx.ArgumentCount() == 0 { ctx.AddErrorMessage("Usage: rules [options]") return nil } subCommand := strings.ToLower(ctx.Arguments[0]) switch subCommand { case "list": // TODO: List all rules ctx.AddStatusMessage("Server rules listing (not yet implemented)") case "get": if ctx.ArgumentCount() < 2 { ctx.AddErrorMessage("Usage: rules get ") return nil } ruleName := ctx.Arguments[1] ctx.AddStatusMessage(fmt.Sprintf("Rule '%s' value (not yet implemented)", ruleName)) case "set": if ctx.ArgumentCount() < 3 { ctx.AddErrorMessage("Usage: rules set ") return nil } ruleName := ctx.Arguments[1] value := ctx.Arguments[2] ctx.AddStatusMessage(fmt.Sprintf("Set rule '%s' to '%s' (not yet implemented)", ruleName, value)) default: ctx.AddErrorMessage("Usage: rules [options]") } return nil } // HandleConsoleTest handles the console test command func HandleConsoleTest(ctx *CommandContext) error { ctx.AddStatusMessage("Console test command executed successfully") if ctx.ArgumentCount() > 0 { ctx.AddStatusMessage(fmt.Sprintf("Arguments: %s", ctx.RawArguments)) } // TODO: Add actual test functionality for development return nil }