示例#1
0
 /// <summary>
 /// Registers a command (chat + console)
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="callback"></param>
 public void RegisterCommand(string cmd, CommandCallback callback)
 {
     if (cmdSystem == null)
     {
         return;
     }
     try
     {
         cmdSystem.RegisterCommand(cmd, CommandType.Chat, callback);
         cmdSystem.RegisterCommand(cmd, CommandType.Console, callback);
     }
     catch (CommandAlreadyExistsException)
     {
         logger.Write(LogType.Error, "Tried to register command '{0}', already exists!", cmd);
     }
 }
示例#2
0
        /// <summary>
        /// Registers a command (chat + console)
        /// </summary>
        /// <param name="command"></param>
        /// <param name="plugin"></param>
        /// <param name="callback"></param>
        public void RegisterCommand(string command, Plugin plugin, CommandCallback callback)
        {
            if (cmdSystem == null)
            {
                return;
            }

            try
            {
                cmdSystem.RegisterCommand(command, plugin, callback);
            }
            catch (CommandAlreadyExistsException)
            {
                var pluginName = plugin?.Name ?? "An unknown plugin";
                logger.Write(LogType.Error, "{0} tried to register command '{1}', this command already exists and cannot be overridden!", pluginName, command);
            }
        }