示例#1
0
        // ConsoleSystem.SystemRealm.Normal
        public static void On_ServerConsole(ConsoleSystem.Arg arg, string cmd)
        {
            try {
                if (!Bootstrap.PlutonLoaded)
                {
                    return;
                }

                ServerConsoleEvent ssc = new ServerConsoleEvent(arg, cmd);

                foreach (KeyValuePair <string, BasePlugin> pl in PluginLoader.GetInstance().Plugins)
                {
                    ConsoleCommand[] commands = pl.Value.consoleCommands.getConsoleCommands(ssc.cmd);
                    foreach (ConsoleCommand cc in commands)
                    {
                        if (cc.callback == null)
                        {
                            continue;
                        }
                        try {
                            cc.callback(arg.ArgsStr.Split(' '));
                        } catch (Exception ex) {
                            Logger.LogError(cc.plugin.FormatException(ex));
                        }
                    }
                }

                OnNext("On_ServerConsole", ssc);
                if (arg.Invalid)
                {
                    Debug.Log(ssc.Reply);
                }
            } catch (Exception ex) {
                Logger.LogException(ex);
            }
        }
示例#2
0
        /// <summary>
        /// Called from <c>ConsoleSystem.SystemRealm.Normal(RunOptions, string, params object[])</c> .
        /// </summary>
        public static void On_ServerConsole(ConsoleSystem.Arg arg, string cmd)
        {
            try
            {
                if (!Core.Bootstrap.PlutonLoaded)
                    return;

                var sce = new ServerConsoleEvent(arg, cmd);

                foreach (KeyValuePair<string, BasePlugin> pl in PluginLoader.GetInstance().Plugins)
                {
                    object globalObj = pl.Value.GetGlobalObject("ServerConsoleCommands");

                    if (globalObj is ConsoleCommands)
                    {
                        ConsoleCommand[] commands = (globalObj as ConsoleCommands).getConsoleCommands(sce.Cmd);

                        foreach (ConsoleCommand cc in commands)
                        {
                            if (cc.callback == null)
                                continue;

                            try
                            {
                                cc.callback(arg.ArgsStr.Split(' '));
                            }
                            catch (Exception ex)
                            {
                                Logger.LogError(cc.plugin.FormatException(ex));
                            }
                        }
                    }
                }

                OnNext("On_ServerConsole", sce);

                if (arg.Invalid)
                {
                    Debug.Log(sce.Reply);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
示例#3
0
 public void On_ServerConsole(ServerConsoleEvent sce)
 {
     SetHookWorking("On_ServerConsole");
     Broadcast(sce.Cmd + " command used in server console");
 }
示例#4
0
 public void OnServerConsole(ServerConsoleEvent ce)
 {
     this.Invoke("On_ServerConsole", ce);
 }