예제 #1
0
        public static void Init(Assembly[] assemblies)
        {
            MaxWaitingTime = new TimeSpan(6, 0, 0);

            Maps      = new List <MapBase>();
            IslandMap = new Island();

            Maps.Add(IslandMap);

            ForgetiveCommandCenter.cmds = new List <IForgetiveCommand>();
            ForgetiveCommandCenter.FindCommands(assemblies);

            Thread thread = new Thread(() => { while (Loop())
                                               {
                                                   ;
                                               }
                                       });

            thread.Start();

            if (UserSocketState.IsSocketInSingleThreadMode)
            {
                Logger.WriteLine("--网络单线程模式会降低服务器性能,仅测试使用");
            }
        }
예제 #2
0
        internal void ExecuteByPlayer(string cmd, Player player)
        {
            string command = "";

            CommandObject[] args = new CommandObject[0];
            if (cmd.Contains(" "))
            {
                command = cmd.Substring(0, cmd.IndexOf(' '));
                args    = SplitCommand(cmd.Substring(cmd.IndexOf(' ') + 1));
            }
            else
            {
                command = cmd;
            }
            IForgetiveCommand desc = ForgetiveCommandCenter.PreInvoke(command, !player.IsOp);

            if (desc == null)
            {
                player.SendChat("找不到指令或没有权限调用该指令。输入@help查看更多帮助", "Forgetive");
                return;
            }
            desc.invoker = player;
            try
            {
                desc.OnInvoke(args);
            }
            catch
            {
                player.SendChat("<" + command + "> 执行命令时出现内部错误", "Forgetive");
            }
        }
예제 #3
0
 public void Print(string str)
 {
     if (invoker == null)
     {
         ForgetiveCommandCenter.Log(Info.CommandNames[0], str);
     }
     else
     {
         invoker.SendChat(str, "Forgetive");
     }
 }
예제 #4
0
        internal void Execute(string cmd, bool needRepeatCommand = false)
        {
            string command = "";

            if (needRepeatCommand)
            {
                Logger.WriteLine(LogLevel.Info, "Server> " + cmd);
            }
            CommandObject[] args = new CommandObject[0];
            if (cmd.Contains(" "))
            {
                command = cmd.Substring(0, cmd.IndexOf(' '));
                args    = SplitCommand(cmd.Substring(cmd.IndexOf(' ') + 1));
            }
            else
            {
                command = cmd;
            }
            IForgetiveCommand desc = ForgetiveCommandCenter.PreInvoke(command);

            if (desc == null)
            {
                Logger.WriteLine(LogLevel.Warning, "<{0}> {1}", command, "找不到指令。输入help查看更多帮助");
                return;
            }
            desc.invoker = null;
#if !DEBUG
            try
            {
                desc.OnInvoke(args);
            }
            catch
            {
                Logger.WriteLine(LogLevel.Warning, "<{0}> {1}", command, "执行命令时出现内部错误");
            }
#else
            desc.OnInvoke(args);
#endif
        }