private void RemoveChatCommand(Command.ChatCommand command) { if (this.chatCommands.ContainsKey(command.Name)) { this.chatCommands.Remove(command.Name); } }
public void RemoveChatCommand(string command, Plugin plugin) { Command.ChatCommand chatCommand = ( from x in this.chatCommands.Values where x.Plugin == plugin select x).FirstOrDefault <Command.ChatCommand>((Command.ChatCommand x) => x.Name == command); if (chatCommand != null) { this.RemoveChatCommand(chatCommand); } }
public void AddChatCommand(string command, Plugin plugin, Action <BasePlayer, string, string[]> callback) { Command.ChatCommand chatCommand; RustCommandSystem.RegisteredCommand registeredCommand; object name; object obj; object name1; object obj1; object name2; string lowerInvariant = command.ToLowerInvariant(); if (!this.CanOverrideCommand(command, "chat")) { if (plugin != null) { name2 = plugin.Name; } else { name2 = null; } if (name2 == null) { name2 = "An unknown plugin"; } string str = name2; Interface.Oxide.LogError("{0} tried to register command '{1}', this command already exists and cannot be overridden!", new Object[] { str, lowerInvariant }); return; } if (this.chatCommands.TryGetValue(lowerInvariant, out chatCommand)) { Plugin plugin1 = chatCommand.Plugin; if (plugin1 != null) { name1 = plugin1.Name; } else { name1 = null; } if (name1 == null) { name1 = "an unknown plugin"; } string str1 = name1; if (plugin != null) { obj1 = plugin.Name; } else { obj1 = null; } if (obj1 == null) { obj1 = "An unknown plugin"; } string str2 = obj1; string str3 = String.Concat(new String[] { str2, " has replaced the '", lowerInvariant, "' chat command previously registered by ", str1 }); Interface.Oxide.LogWarning(str3, Array.Empty <object>()); } if (RustCore.Covalence.CommandSystem.registeredCommands.TryGetValue(lowerInvariant, out registeredCommand)) { Plugin source = registeredCommand.Source; if (source != null) { name = source.Name; } else { name = null; } if (name == null) { name = "an unknown plugin"; } string str4 = name; if (plugin != null) { obj = plugin.Name; } else { obj = null; } if (obj == null) { obj = "An unknown plugin"; } string str5 = obj; string str6 = String.Concat(new String[] { str5, " has replaced the '", lowerInvariant, "' command previously registered by ", str4 }); Interface.Oxide.LogWarning(str6, Array.Empty <object>()); RustCore.Covalence.CommandSystem.UnregisterCommand(lowerInvariant, registeredCommand.Source); } chatCommand = new Command.ChatCommand(lowerInvariant, plugin, callback); this.chatCommands[lowerInvariant] = chatCommand; if (plugin != null && !this.pluginRemovedFromManager.ContainsKey(plugin)) { this.pluginRemovedFromManager[plugin] = plugin.OnRemovedFromManager.Add(new Action <Plugin, PluginManager>(this.plugin_OnRemovedFromManager)); } }