/// <summary> /// 呼出事件 /// </summary> public void callEvent() { ServerExecutedCommandArg arguments = new ServerExecutedCommandArg(this.Command, this.Args); int size = 0; foreach (Command command in Console.getServer().getCommands().Keys) { if (command.Equals(this.Command)) { size++; Console.Out.println("Console issued server command: /" + this.Command.getCommand()); if (ServerExecutedCommandEvent != null) { ServerExecutedCommandEvent(this.Sender, arguments); } ClassDetector detector = new ClassDetector(); foreach (Type type in detector.begin()) { try { if (type == null) { continue; } Object instance = Activator.CreateInstance(type); MethodInfo executor = type.GetMethod("CommandExecutor"); Object[] parameter = new Object[3]; parameter[0] = this.Sender; parameter[1] = this.Command.getCommand(); parameter[2] = this.Args; executor.Invoke(instance, parameter); } catch (Exception ex) { Console.Out.println(Level.Severe, ex.ToString()); } } } } if (size <= 0) { Console.Out.println("Unknown command. Type \"/help\" for help."); } }