示例#1
0
            static bool Prefix(ClientLogic __instance, ChatSubmitMessage.Data data)
            {
                if (data.message_.StartsWith("!") || data.message_.StartsWith("%") || data.message_.StartsWith("/"))
                {
                    return(true);
                }

                var chatName = __instance.GetType().GetMethod("GetClientChatName", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[] { }) as string;

                if (configs.colorizeName)
                {
                    chatName = colorizeText(NGUIText.StripSymbols(chatName));
                }
                if (data.message_ == "/colorizer")
                {
                    configs.colorizeMessage = !configs.colorizeMessage;
                    return(false);
                }
                if (data.message_ == "/coloriname")
                {
                    configs.colorizeName = !configs.colorizeName;
                    return(false);
                }

                if (!configs.colorizeMessage)
                {
                    Message.SendMessage(chatName + ": " + data.message_);
                }
                else
                {
                    Message.SendMessage(chatName + ": " + colorizeText(data.message_, false));
                }

                return(false);
            }
示例#2
0
        private void Chat_MessageSent(ChatSubmitMessage.Data messageData)
        {
            // by doing the below instead, we preserver formatting symbols.
            string message = UIExInputGeneric <string> .current_.Value_; //messageData.message_;

            var commandInfo = MessageUtilities.getCommandInfo(message);
            Cmd cmd         = commandInfo.matches ? Cmd.all.getCommand(commandInfo.commandName) : null;

            string logMessage = "";

            var client = GeneralUtilities.localClient();

            var showRegularChat = (!commandInfo.local && !GeneralUtilities.isHost()) || !LogCmd.localHostCommands ||
                                  !commandInfo.matches || commandInfo.forceVisible || (cmd != null && client != null && cmd.showChatPublic(client));

            if (showRegularChat)
            {
                sendingLocalChat = true;
                replicateLocalChatFunc?.Invoke(messageData);
                if (!commandInfo.matches)
                {
                    return;
                }
                logMessage = message;
            }

            if (client == null)
            {
                Console.WriteLine("Error: Local client can't be found !");
                return;
            }

            if (!showRegularChat)
            {
                MessageUtilities.sendMessage(client, $"[00FFFF]{message}[-]");
                logMessage = $"[00FFFF]{message}[-]";
            }

            MessageStateOptionLog cmdLog = new MessageStateOptionLog(new List <string>());

            MessageUtilities.pushMessageOption(cmdLog);

            if (LogCmd.localHostResults)
            {
                MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(client));
            }
            else
            {
                MessageUtilities.pushMessageOption(new MessageStateOptionPlayer());
            }

            if (!commandInfo.local && commandInfo.commandName.ToLower() == "plugin")
            {
                printClient();
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }

            if (GeneralUtilities.isHost() && commandInfo.local)
            {
                MessageUtilities.sendMessage(client, "Cannot use local commands as host");
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }
            else if (!GeneralUtilities.isHost() && !commandInfo.local)
            {
                MessageUtilities.popMessageOptions(2);
                return;
            }

            if (cmd == null)
            {
                MessageUtilities.sendMessage(client, "The command '" + commandInfo.commandName + "' doesn't exist.");
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }

            if (commandInfo.local && !cmd.canUseLocal && cmd.perm != PermType.LOCAL)
            {
                MessageUtilities.sendMessage(client, "You can't use that command as client");
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }

            MessageUtilities.popMessageOptions();                                       // remove local/non-local only option

            bool renderToPublic = commandInfo.forceVisible || !LogCmd.localHostResults; // log settings may change if cmd changes them

            if (renderToPublic)
            {
                MessageUtilities.pushMessageOption(new MessageStateOptionPlayer());
            }
            exec(cmd, client, commandInfo.commandParams);
            if (renderToPublic)
            {
                MessageUtilities.popMessageOptions();
            }
            LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
            MessageUtilities.popAllMessageOptions();
        }