private void OnPluginCommandAdded(CommandAddedEventArgs e) { foreach (EventListener v in Plugins) { PluginListener pl = (PluginListener)v.Listener; if (v.Event == Event.COMMAND_ADDED) pl.OnPluginCommandAdded(e); } }
/// <summary> /// Registers a command with the server. /// </summary> /// <param name="cmd">The command to register. ClientCommand or ServerCommand.</param> /// <param name="plugin">The plugin to associate the command with.</param> public void RegisterCommand(ICommand cmd, IPlugin plugin) { if (cmd is IClientCommand) { try { //Event CommandAddedEventArgs e = new CommandAddedEventArgs(plugin, cmd); CallEvent(Event.CommandAdded, e); if (e.EventCanceled) return; //End Event PluginCommands.Add(cmd,plugin); plugin.Server.ClientCommandHandler.RegisterCommand(cmd); } catch (CommandAlreadyExistsException e) { plugin.Server.Logger.Log(e); } } else if (cmd is IServerCommand) { try { //Event CommandAddedEventArgs e = new CommandAddedEventArgs(plugin, cmd); CallEvent(Event.CommandAdded, e); if (e.EventCanceled) return; //End Event PluginCommands.Add(cmd, plugin); plugin.Server.ServerCommandHandler.RegisterCommand(cmd); } catch (CommandAlreadyExistsException e) { plugin.Server.Logger.Log(e); } } }
public virtual void OnPluginCommandAdded(CommandAddedEventArgs e) { }
/// <summary> /// Registers a command with the server. /// </summary> /// <param name="cmd">The command to register. ClientCommand or ServerCommand.</param> /// <param name="Plugin">The plugin to associate the command with.</param> public void RegisterCommand(Command cmd, IPlugin Plugin) { if (cmd is ClientCommand) { try { //Event CommandAddedEventArgs e = new CommandAddedEventArgs(Plugin, cmd); CallEvent("COMMAND_ADDED", e); if (e.EventCanceled) return; //End Event PluginCommands.Add(cmd, Plugin); Plugin.Server.ClientCommandHandler.RegisterCommand(cmd); } catch (CommandAlreadyExistsException e) { Plugin.Server.Logger.Log(e); } } else if(cmd is ServerCommand) { try { //Event CommandAddedEventArgs e = new CommandAddedEventArgs(Plugin, cmd); CallEvent("COMMAND_ADDED", e); if (e.EventCanceled) return; //End Event PluginCommands.Add(cmd, Plugin); Plugin.Server.ServerCommandHandler.RegisterCommand(cmd); } catch (CommandAlreadyExistsException e) { Plugin.Server.Logger.Log(e); } } }