public static bool FindTokenCommand(string prefix, out CommandInfo info)
        {
            info = null;

            prefix = prefix.ToLower();
            foreach (var def in commands)
            {
                var plugin = def.Key;
                var cmd = def.Value;

                lock (cmd.commands)
                {
                    if (plugin.IsEnabled && cmd.commands.TryGetValue(prefix, out info) && (info.tokenCallback != null || info.LuaCallback != null))
                        return true;
                }
            }

            if (Entry.CommandParser.serverCommands.TryGetValue(prefix, out info) && info.tokenCallback != null)
                return true;

            return false;
        }
 internal void NotifyAfterCommand(CommandInfo cmd)
 {
     Interlocked.Decrement(ref runningCommands);
     threadInCommand = 0;
 }
        internal void NotifyBeforeCommand(CommandInfo cmd)
        {
            Interlocked.Increment(ref runningCommands);

            var signal = commandPauseSignal;
            if (signal != null)
            {
                Interlocked.Increment(ref pausedCommands);
                signal.WaitOne();
                Interlocked.Decrement(ref pausedCommands);
            }

            threadInCommand = 1;
        }
        /// <summary>
        /// Adds a new command to the server's command list
        /// </summary>
        /// <param name="prefix">Command text</param>
        /// <returns>New Command</returns>
        public static CommandInfo AddPluginCommand(BasePlugin plugin, string prefix)
        {
            var def = CommandManager.GetOrCreatePluginCommandDefinitions(plugin);

            if (def.commands.ContainsKey(prefix))
                throw new ApplicationException("AddCommand: duplicate command: " + prefix);

            var cmd = new CommandInfo(prefix);
            cmd.BeforeEvent += def.NotifyBeforeCommand;
            cmd.AfterEvent += def.NotifyAfterCommand;

            lock (def.commands)
            {
                def.commands[prefix] = cmd;
                def.commands[string.Concat(plugin.Name.ToLower(), ".", prefix)] = cmd;
            }

            return cmd;
        }