MinecraftToIrcColors() private method

private MinecraftToIrcColors ( [ input ) : string
input [
return string
Example #1
0
 public static void SendChannelMessage([NotNull] string line)
 {
     if (line == null)
     {
         throw new ArgumentNullException("line");
     }
     line = Color.MinecraftToIrcColors(line);
     if (_channelName == null || !GcReady)
     {
         return; // in case IRC bot is disabled.
     }
     SendRawMessage(IRCCommands.Privmsg(_channelName, line));
 }
Example #2
0
 public static void SendChannelMessage([NotNull] string line)
 {
     if (line == null)
     {
         throw new ArgumentNullException("line");
     }
     line = Color.MinecraftToIrcColors(line);
     if (channelNames == null || !GCReady)
     {
         return; // in case IRC bot is disabled.
     }
     for (int i = 0; i < channelNames.Length; i++)
     {
         SendRawMessage(IRCCommands.Privmsg(channelNames[i], line));
     }
 }
Example #3
0
 public static void SendNotice([NotNull] string line)
 {
     if (line == null)
     {
         throw new ArgumentNullException("line");
     }
     if (channelNames == null)
     {
         return;                       // in case IRC bot is disabled.
     }
     if (ConfigKey.IRCUseColor.Enabled())
     {
         line = Color.MinecraftToIrcColors(line);
     }
     else
     {
         line = NonPrintableChars.Replace(line, "").Trim();
     }
     for (int i = 0; i < channelNames.Length; i++)
     {
         SendRawMessage(IRCCommands.Notice(channelNames[i], line));
     }
 }
Example #4
0
        private static void GlobalHandler(Player player, Command cmd)
        {
            var    sendList = Server.Players.Where(p => p.GlobalChatAllowed && !p.IsDeaf);
            string msg      = cmd.NextAll();

            if (!ConfigKey.GlobalChat.Enabled())
            {
                player.Message("&WGlobal Chat is disabled on this server.");
                return;
            }
            if (!GlobalChat.GlobalThread.GcReady)
            {
                player.Message("&WGlobal Chat is not connected.");
                return;
            }
            string reason;

            if (Server.GlobalChatBans.TryGetValue(player.Name.ToLower(), out reason))
            {
                player.Message("You were &cbanned &efrom &gglobal chat&e by &h{0}&e", reason);
                player.Message("You can appeal your ban at &9http://atomiccraft.net");
                return;
            }
            switch (msg)
            {
            case "reconnect":
                if (player.Can(Permission.ManageGlobalChat))
                {
                    if (GlobalChat.GlobalThread.GcReady)
                    {
                        player.Message("&WThis server is currently connected to global chat.");
                        return;
                    }
                    GlobalChat.GlobalThread.GcReady = true;
                    Server.Message(
                        "&WAttempting to connect to AtomicCraft Global Chat Network. This may take a few seconds.");
                    GlobalChat.Init();
                    GlobalChat.Start();
                    return;
                }
                break;

            case "rules":
                if (!player.GlobalChatAllowed)
                {
                    player.Message(
                        "&RRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                        "&WServer staff have the right to kick you.\n" +
                        "&SBy using the Global Chat, you accept these conditions.\n" +
                        "&SType &H/global accept &Sto connect");
                    return;
                }

                if (player.GlobalChatAllowed)
                {
                    player.Message(
                        "&RRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                        "&WServer staff have the right to kick you.\n" +
                        "&SBy using the Global Chat, you accept these conditions.");
                    return;
                }
                break;

            case "accept":

                if (!player.GlobalChatAllowed)
                {
                    player.GlobalChatAllowed = true;
                    player.Message("&SThank you for accepting the global chat rules.\n" +
                                   "&WYou now have global chat enabled.");
                    GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName + " &Sjoined global chat.");
                    sendList.Message(player.ClassyName + " &Sjoined global chat.");
                    return;
                }

                if (player.GlobalChatAllowed)
                {
                    player.Message("&WYou have already accepted the global chat rules.");
                    return;
                }
                break;

            case "ignore":
                if (!player.GlobalChatIgnore)
                {
                    player.GlobalChatIgnore = true;
                    player.Message("&WYou have disconnected from global chat.");
                    sendList.Message(player.ClassyName + " &Sdisconnected from global chat.");
                    GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName +
                                                               " &Sdisconnected from global chat.");
                    return;
                }
                break;

            case "help":
                CdGlobal.PrintUsage(player);
                break;
            }
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if ((!player.GlobalChatAllowed) && ((msg.Length < 1) || (msg.Length > 1)))
            {
                player.Message("&WYou must read and accept the global chat rules. Type &H/global rules");
                return;
            }

            if ((player.GlobalChatAllowed) && string.IsNullOrEmpty(msg))
            {
                player.Message("&WYou must enter a message!");
                return;
            }
            if (!player.GlobalChatAllowed)
            {
                return;
            }
            string pMsg = player.ClassyName + Color.White + ": " + msg;

            msg = player.ClassyName + Color.Black + ": " + msg;
            sendList.Message("&g[Global] " + pMsg); //send the white message to Server
            msg = Color.MinecraftToIrcColors(msg);
            msg = Color.ReplacePercentCodes(msg);
            GlobalChat.GlobalThread.SendChannelMessage(msg); //send the black message to GC
        }