public void Execute(RocketPlayer caller, string[] cmd) { bool isServer; bool isAdmin; string charName; try { charName = caller.CharacterName; isServer = false; isAdmin = caller.IsAdmin; } //Mainly to fix exceptions when user is typing commands from the server console. catch (NullReferenceException n) { charName = "Server"; isServer = true; isAdmin = true; } if (cmd[0].ToLower().Equals("set") && isAdmin) //Set various settings. { if (cmd.Length < 3 || cmd.Length > 3) //Make sure we have the right number or arguments. { SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect number of arguments for 'set'."); return; } if (cmd[1].ToLower().Equals("enabled")) //Enable or disable plugin entirely. { if (cmd[2].ToLower().Equals("true")) { SpawnKit.SetEnabled(true); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Kits enabled" + " by " + charName); return; } if (cmd[2].ToLower().Equals("false")) { SpawnKit.SetEnabled(false); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Kits disabled" + " by " + charName); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect option. Only true or false is accepted."); return; } if (cmd[1].ToLower().Equals("cooldown")) //Turn off the cooldown. { if (cmd[2].ToLower().Equals("on")) { SpawnKit.SetGlobalCoolDownEnabled(true); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Cooldown enabled" + " by " + charName); return; } if (cmd[2].ToLower().Equals("off")) { SpawnKit.SetGlobalCoolDownEnabled(false); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Cooldown disabled" + " by " + charName); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect option. Only on or off is accepted."); return; } if (cmd[1].ToLower().Equals("cooldowntime")) //set the spawn kit cooldown. { try { SpawnKit.SetCooldown(int.Parse(cmd[2])); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Kit cooldown set to " + cmd[2] + " by " + charName); return; } catch (Exception e) { SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Not a valid input for cooldown. (Seconds)"); Logger.LogException(e); return; } } if (cmd[1].ToLower().Equals("cooldownmessages")) //Turn off the cooldown chat messages. { if (cmd[2].ToLower().Equals("on")) { SpawnKit.SetCoolDownChatMessagesEnabled(true); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Cooldown chat messages enabled" + " by " + charName); return; } if (cmd[2].ToLower().Equals("off")) { SpawnKit.SetCoolDownChatMessagesEnabled(false); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Cooldown chat messages disabled" + " by " + charName); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect option. Only on or off is accepted."); return; } if (cmd[1].ToLower().Equals("professionmode")) //Enable or disable profession mode. { if (cmd[2].ToLower().Equals("on")) { SpawnKit.SetProfessionModeEnable(true); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Profession mode enabled" + " by " + charName); return; } if (cmd[2].ToLower().Equals("off")) { SpawnKit.SetProfessionModeEnable(false); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Profession mode disabled" + " by " + charName); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect option. Only on or off is accepted."); return; } if (cmd[1].ToLower().Equals("professionmessages")) //Turn off the prefession chat messages. { if (cmd[2].ToLower().Equals("on")) { SpawnKit.SetProfessionChatMessagesEnabled(true); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Profession chat messages enabled" + " by " + charName); return; } if (cmd[2].ToLower().Equals("off")) { SpawnKit.SetProfessionChatMessagesEnabled(false); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Profession chat messages disabled" + " by " + charName); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect option. Only on or off is accepted."); return; } if (cmd[1].ToLower().Equals("subscriptionmode")) //Enable or disable subscription (class) mode. { if (cmd[2].ToLower().Equals("on")) { SpawnKit.SetSubscriptionMode(true); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Subscription mode enabled" + " by " + charName); return; } if (cmd[2].ToLower().Equals("off")) { SpawnKit.SetSubscriptionMode(false); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Subscription mode disabled" + " by " + charName); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect option. Only on or off is accepted."); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Invalid set option."); return; } if (cmd[0].ToLower().Equals("status") && isAdmin) //View plugin status. { PrintStatus(); return; } if (cmd[0].ToLower().Equals("reload") && isAdmin) { SpawnKit.ReloadSpawnKitConfiguration(); return; } if (cmd[0].ToLower().Equals("save") && isAdmin) { SpawnKit.SaveConfiguration(); return; } if (cmd[0].ToLower().Equals("givekit") && isAdmin) //Clear the named players inventory and give them a kit. { if (cmd.Length == 3) //Make sure we have to proper number of parameters. { SpawnKit.AdminGiveKit(cmd[1], cmd[2]); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Incorrect number of arguments for 'givekit'."); return; } if (cmd[0].ToLower().Equals("list")) //List Classes if class subscription mode is on. { if (SpawnKit.GetSubscriptionModeEnabled()) //If subscription mode is enabled print list. { string classListString = ""; foreach (Kit k in SpawnKit.GetKitsList()) { classListString = classListString + k.Name + ", "; } RocketChat.Say(caller, "Class List: " + classListString); RocketChat.Say(caller, "/sk class ClassName to pick class."); return; } RocketChat.Say(caller, "Subscription mode disabled."); return; } if (cmd[0].ToLower().Equals("class")) //Select class { if (SpawnKit.GetSubscriptionModeEnabled()) //If subscription mode is enabled. { try { foreach (Kit k in SpawnKit.GetKitsList()) //Loop through kits to see if they picked a valid class. { if (cmd[1].ToLower().Equals(k.Name.ToLower())) //They did. { SpawnKit.AddPlayerToSubscriptionList(charName, k); RocketChat.Say(caller, "Class selected."); return; } } RocketChat.Say(caller, "No such class."); return; } catch (Exception e) { RocketChat.Say(caller, "No such class."); return; } } RocketChat.Say(caller, "Subscription mode disabled."); return; } if (cmd[0].ToLower().Equals("listsubs") && isAdmin) //Print the player kit subscriptions to the console. { if (SpawnKit.GetSubscriptionModeEnabled()) { var tempSubList = SpawnKit.GetSubscriptionList(); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "-- Kit Subscriptions --"); foreach (var pName in SpawnKit.GetSubscriptionList().Keys) { SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Player: " + pName + " | Kit: " + tempSubList[pName].Name); } return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Subscription mode disabled."); return; } if (cmd[0].ToLower().Equals("logme") && isAdmin) //Direct SpawnKit console messages to yourself. { if (isServer) { ShowCannotRunFromConsoleWarning(); return; } SpawnKit.AddPlayerToLogList(caller); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Added player " + charName + " to the log output list."); return; } if (cmd[0].ToLower().Equals("unlogme") && isAdmin) //Disable SpawnKit console messages being sent to you. { if (isServer) { ShowCannotRunFromConsoleWarning(); return; } SpawnKit.RemovePlayerFromLogList(caller); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Removed player " + charName + " from the log output list."); return; } if (cmd[0].ToLower().Equals("clearlogplayers") && isAdmin) //Disable SpawnKit console messages being sent to you. { SpawnKit.CleanPlayerLogList(); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "Player log message list cleared."); return; } if (cmd[0].ToLower().Equals("help")) { if (cmd.Length == 1) //If we are only showing the default help page. { ShowHelp("help"); return; } if (cmd[1].ToLower().Equals("set")) { ShowHelp("set"); return; } if (cmd[1].ToLower().Equals("status")) { ShowHelp("status"); return; } if (cmd[1].ToLower().Equals("reload")) { ShowHelp("reload"); return; } if (cmd[1].ToLower().Equals("save")) { ShowHelp("save"); return; } if (cmd[1].ToLower().Equals("givekit")) { ShowHelp("givekit"); return; } if (cmd[1].ToLower().Equals("list")) { ShowHelp("list"); return; } if (cmd[1].ToLower().Equals("listsubs")) { ShowHelp("listsubs"); return; } if (cmd[1].ToLower().Equals("class")) { ShowHelp("class"); return; } if (cmd[1].ToLower().Equals("logme")) { ShowHelp("logme"); return; } if (cmd[1].ToLower().Equals("unlogme")) { ShowHelp("unlogme"); return; } if (cmd[1].ToLower().Equals("clearlogplayers")) { ShowHelp("clearlogplayers"); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Invalid help topic."); return; } SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_WARNING, "Invalid SpawnKit command. Use 'sk help' for more info."); return; }
/* * Print plugin status to the console. */ private void PrintStatus() { SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "-- SpawnKit Status --"); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "- Plugin Enabled: " + SpawnKit.GetEnabled()); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "- Subscription Mode Enabled: " + SpawnKit.GetSubscriptionModeEnabled()); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "- Profession Mode Enabled: " + SpawnKit.GetProfessionModeEnabled()); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "- Cooldown Enabled: " + SpawnKit.GetCooldownEnabled()); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "- Cooldown Seconds: " + SpawnKit.GetCooldown()); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "- Cooldown Chat Messages Enabled: " + SpawnKit.GetCoolDownMessagesEnabled()); SpawnKit.logHelper.LogMessage(LogHelper.MESSAGELEVEL_INFO, "- Profession Chat Messages Enabled: " + SpawnKit.GetProfessionChatMessagesEnabled()); }