예제 #1
0
 public static byte[] Kick(string message, bool cp437)
 {
     byte[] buffer = new byte[65];
     buffer[0] = Opcode.Kick;
     NetUtils.Write(message, buffer, 1, cp437);
     return(buffer);
 }
예제 #2
0
 /// <summary> Sends a raw message without performing any token resolving, emoticon parsing, or color parsing. </summary>
 public void SendRawMessage(CpeMessageType id, string message)
 {
     byte[] buffer = new byte[66];
     buffer[0] = Opcode.Message;
     buffer[1] = (byte)id;
     NetUtils.Write(message, buffer, 2, HasCpeExt(CpeExt.FullCP437));
     Send(buffer);
 }
예제 #3
0
        public void SendMessage(byte id, string message, bool colorParse = true)
        {
            message = Chat.Format(message, this, colorParse);
            int totalTries = 0;

            if (MessageRecieve != null)
            {
                MessageRecieve(this, message);
            }
            if (OnMessageRecieve != null)
            {
                OnMessageRecieve(this, message);
            }
            OnMessageRecieveEvent.Call(this, message);
            if (cancelmessage)
            {
                cancelmessage = false; return;
            }

            retryTag : try {
                foreach (string raw in LineWrapper.Wordwrap(message))
                {
                    string line = raw;
                    if (!HasCpeExt(CpeExt.EmoteFix) && line.TrimEnd(' ')[line.TrimEnd(' ').Length - 1] < '!')
                    {
                        line += '\'';
                    }

                    byte[] buffer = new byte[66];
                    buffer[0] = Opcode.Message;
                    buffer[1] = (byte)id;
                    NetUtils.Write(line, buffer, 2, HasCpeExt(CpeExt.FullCP437));
                    Send(buffer);
                }
            } catch (Exception e) {
                message = "&f" + message;
                totalTries++;
                if (totalTries < 10)
                {
                    goto retryTag;
                }
                else
                {
                    Server.ErrorLog(e);
                }
            }
        }
예제 #4
0
        public static byte[] Motd(Player p, string motd)
        {
            byte[] buffer = new byte[131];
            buffer[0] = Opcode.Handshake;
            buffer[1] = Server.version;

            bool cp437 = p.HasCpeExt(CpeExt.FullCP437);

            if (motd.Length > 64)
            {
                NetUtils.Write(motd, buffer, 2, cp437);
                NetUtils.Write(motd.Substring(64), buffer, 66, cp437);
            }
            else
            {
                NetUtils.Write(Server.name, buffer, 2, cp437);
                NetUtils.Write(motd, buffer, 66, cp437);
            }

            buffer[130] = Block.canPlace(p, Block.blackrock) ? (byte)100 : (byte)0;
            return(buffer);
        }