Beispiel #1
0
        void HandleChat(byte[] buffer, int offset)
        {
            if (!loggedIn)
            {
                return;
            }
            byte   continued = buffer[offset + 1];
            string text      = NetUtils.ReadString(buffer, offset + 2);

            LastAction = DateTime.UtcNow;
            if (FilterChat(ref text, continued))
            {
                return;
            }

            if (text != "/afk" && IsAfk)
            {
                CmdAfk.ToggleAfk(this, "");
            }

            bool isCommand;

            text = Chat.ParseInput(text, out isCommand);
            if (isCommand)
            {
                DoCommand(text); return;
            }

            // People who are muted can't speak or vote
            if (muted)
            {
                Message("You are muted."); return;
            }                                                 //Muted: Only allow commands

            if (Server.voting)
            {
                if (CheckVote(text, this, "y", "yes", ref Server.YesVotes) ||
                    CheckVote(text, this, "n", "no", ref Server.NoVotes))
                {
                    return;
                }
            }

            if (LSGame.Instance.HandlesChatMessage(this, text))
            {
                return;
            }
            if (ZSGame.Instance.HandlesChatMessage(this, text))
            {
                return;
            }

            // Put this after vote collection so that people can vote even when chat is moderated
            if (!CheckCanSpeak("speak"))
            {
                return;
            }

            // Filter out bad words
            if (Server.Config.ProfanityFiltering)
            {
                text = ProfanityFilter.Parse(text);
            }

            if (ChatModes.Handle(this, text))
            {
                return;
            }
            text = HandleJoker(text);

            OnPlayerChatEvent.Call(this, text);
            if (cancelchat)
            {
                cancelchat = false; return;
            }
            Chat.MessageChat(this, "λFULL: &f" + text, null, true);
        }
Beispiel #2
0
        void HandleMovement(byte[] buffer, int offset)
        {
            if (!loggedIn)
            {
                return;
            }
            if (trainGrab || following.Length > 0)
            {
                CheckBlocks(Pos, Pos); return;
            }
            if (Supports(CpeExt.HeldBlock))
            {
                ClientHeldBlock = ReadBlock(buffer, offset + 1);
                if (hasExtBlocks)
                {
                    offset++;               // corret offset for position later
                }
            }

            int x, y, z;

            if (hasExtPositions)
            {
                x       = NetUtils.ReadI32(buffer, offset + 2);
                y       = NetUtils.ReadI32(buffer, offset + 6);
                z       = NetUtils.ReadI32(buffer, offset + 10);
                offset += 6; // for yaw/pitch offset below
            }
            else
            {
                x = NetUtils.ReadI16(buffer, offset + 2);
                y = NetUtils.ReadI16(buffer, offset + 4);
                z = NetUtils.ReadI16(buffer, offset + 6);
            }

            byte     yaw = buffer[offset + 8], pitch = buffer[offset + 9];
            Position next = new Position(x, y, z);

            CheckBlocks(Pos, next);

            OnPlayerMoveEvent.Call(this, next, yaw, pitch);
            if (cancelmove)
            {
                cancelmove = false; return;
            }

            Pos = next;
            SetYawPitch(yaw, pitch);
            CheckZones(next);

            if (!Moved() || Loading)
            {
                return;
            }
            if (DateTime.UtcNow < AFKCooldown)
            {
                return;
            }

            LastAction = DateTime.UtcNow;
            if (IsAfk)
            {
                CmdAfk.ToggleAfk(this, "");
            }
        }
 void HandleExtInfo(byte[] buffer, int offset)
 {
     appName        = NetUtils.ReadString(buffer, offset + 1);
     extensionCount = buffer[offset + 66];
     CheckReadAllExtensions(); // in case client supports 0 CPE packets
 }
Beispiel #4
0
        void HandleChat(byte[] buffer, int offset)
        {
            if (!loggedIn)
            {
                return;
            }
            byte   continued = buffer[offset + 1];
            string text      = NetUtils.ReadString(buffer, offset + 2);

            if (FilterChat(ref text, continued))
            {
                return;
            }

            if (text != "/afk" && IsAfk)
            {
                CmdAfk.ToggleAfk(this, "");
            }

            LastAction = DateTime.UtcNow;

            // Typing //Command appears in chat as /command
            // Suggested by McMrCat
            if (text.StartsWith("//"))
            {
                text = text.Remove(0, 1);
            }
            else if (DoCommand(text))
            {
                return;
            }

            // People who are muted can't speak or vote
            if (muted)
            {
                Message("You are muted."); return;
            }                                                 //Muted: Only allow commands

            if (Server.voting)
            {
                if (CheckVote(text, this, "y", "yes", ref Server.YesVotes) ||
                    CheckVote(text, this, "n", "no", ref Server.NoVotes))
                {
                    return;
                }
            }

            if (LSGame.Instance.HandlesChatMessage(this, text))
            {
                return;
            }
            if (ZSGame.Instance.HandlesChatMessage(this, text))
            {
                return;
            }

            // Put this after vote collection so that people can vote even when chat is moderated
            if (Server.chatmod && !voice)
            {
                Message("Chat moderation is on, you cannot speak."); return;
            }

            // Filter out bad words
            if (Server.Config.ProfanityFiltering)
            {
                text = ProfanityFilter.Parse(text);
            }

            if (ChatModes.Handle(this, text))
            {
                return;
            }
            text = HandleJoker(text);

            OnPlayerChatEvent.Call(this, text);
            if (cancelchat)
            {
                cancelchat = false; return;
            }

            if (Chatroom != null)
            {
                string roomPrefix = "<ChatRoom: " + Chatroom + "> λNICK: &f";
                Chat.MessageChat(ChatScope.Chatroom, this, roomPrefix + text, Chatroom, null);
            }
            else
            {
                Chat.MessageChat(this, "λFULL: &f" + text, null, true);
            }
        }
Beispiel #5
0
        void HandleChat(byte[] packet)
        {
            if (!loggedIn)
            {
                return;
            }
            byte   continued = packet[1];
            string text      = NetUtils.ReadString(packet, 2);

            LastAction = DateTime.UtcNow;
            if (FilterChat(ref text, continued))
            {
                return;
            }

            if (text != "/afk" && IsAfk)
            {
                CmdAfk.ToggleAfk(this, "");
            }

            // Typing //Command appears in chat as /command
            // Suggested by McMrCat
            if (text.StartsWith("//"))
            {
                text = text.Remove(0, 1);
            }
            else if (DoCommand(text))
            {
                return;
            }

            // People who are muted can't speak or vote
            if (muted)
            {
                SendMessage("You are muted."); return;
            }                                                     //Muted: Only allow commands

            // Lava Survival map vote recorder
            if (Server.lava.HasPlayer(this) && Server.lava.HasVote(text.ToLower()))
            {
                if (Server.lava.AddVote(this, text.ToLower()))
                {
                    SendMessage("Your vote for &5" + text.ToLower().Capitalize() + " %Shas been placed. Thanks!");
                    Server.lava.map.ChatLevelOps(name + " voted for &5" + text.ToLower().Capitalize() + "%S.");
                    return;
                }
                else
                {
                    SendMessage("&cYou already voted!");
                    return;
                }
            }
            // Filter out bad words
            if (Server.profanityFilter)
            {
                text = ProfanityFilter.Parse(text);
            }

            if (IsHandledMessage(text))
            {
                return;
            }

            // Put this after vote collection so that people can vote even when chat is moderated
            if (Server.chatmod && !voice)
            {
                SendMessage("Chat moderation is on, you cannot speak."); return;
            }

            if (ChatModes.Handle(this, text))
            {
                return;
            }

            if (text[0] == ':' && PlayingTntWars)
            {
                string      newtext = text.Remove(0, 1).Trim();
                TntWarsGame it      = TntWarsGame.GetTntWarsGame(this);
                if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                {
                    TntWarsGame.player pl = it.FindPlayer(this);
                    foreach (TntWarsGame.player p in it.Players)
                    {
                        if (pl.Red && p.Red)
                        {
                            SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- " + Server.DefaultColor + newtext);
                        }
                        if (pl.Blue && p.Blue)
                        {
                            SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- " + Server.DefaultColor + newtext);
                        }
                    }
                    Server.s.Log("[TNT Wars] [TeamChat (" + (pl.Red ? "Red" : "Blue") + ") " + name + " " + newtext);
                    return;
                }
            }

            text = HandleJoker(text);
            if (Chatroom != null)
            {
                Chat.ChatRoom(this, text, true, Chatroom); return;
            }

            if (!level.worldChat)
            {
                Server.s.Log("<" + name + ">[level] " + text);
                Chat.GlobalChatLevel(this, text, true);
            }
            else
            {
                Server.s.Log("<" + name + "> " + text);
                if (OnChat != null)
                {
                    OnChat(this, text);
                }
                if (PlayerChat != null)
                {
                    PlayerChat(this, text);
                }
                OnPlayerChatEvent.Call(this, text);

                if (cancelchat)
                {
                    cancelchat = false; return;
                }
                if (Server.worldChat)
                {
                    SendChatFrom(this, text);
                }
                else
                {
                    Chat.GlobalChatLevel(this, text, true);
                }
            }
            CheckForMessageSpam();
        }
Beispiel #6
0
        void HandleMovement(byte[] packet)
        {
            if (!loggedIn || trainGrab || following != "")
            {
                return;
            }
            byte heldBlock = packet[1];

            if (HasCpeExt(CpeExt.HeldBlock))
            {
                RawHeldBlock = heldBlock;
            }

            ushort x = NetUtils.ReadU16(packet, 2);
            ushort y = NetUtils.ReadU16(packet, 4);
            ushort z = NetUtils.ReadU16(packet, 6);
            byte   rotx = packet[8], roty = packet[9];

            if (frozen)
            {
                bool movedX = Math.Abs((short)x - (short)pos[0]) > 4;  // moved more than 0.125 blocks horizontally
                bool movedY = Math.Abs((short)y - (short)pos[1]) > 40; // moved more than 1.25 blocks vertically
                bool movedZ = Math.Abs((short)z - (short)pos[2]) > 4;  // moved more than 0.125 blocks horizontally
                if (movedX || movedY || movedZ)
                {
                    SendPos(Entities.SelfID, pos[0], pos[1], pos[2], rotx, roty);
                }
                return;
            }

            if (Server.Countdown.HandlesMovement(this, x, y, z, rotx, roty))
            {
                return;
            }
            if (Server.zombie.Running && Server.zombie.HandlesMovement(this, x, y, z, rotx, roty))
            {
                return;
            }

            if (OnMove != null)
            {
                OnMove(this, x, y, z);
            }
            if (PlayerMove != null)
            {
                PlayerMove(this, x, y, z);
            }
            PlayerMoveEvent.Call(this, x, y, z);

            if (OnRotate != null)
            {
                OnRotate(this, rot);
            }
            if (PlayerRotate != null)
            {
                PlayerRotate(this, rot);
            }
            PlayerRotateEvent.Call(this, rot);

            if (cancelmove)
            {
                SendPos(Entities.SelfID, pos[0], pos[1], pos[2], rot[0], rot[1]); return;
            }

            pos = new ushort[3] {
                x, y, z
            };
            rot = new byte[2] {
                rotx, roty
            };
            if (!Moved() || Loading)
            {
                return;
            }
            if (DateTime.UtcNow < AFKCooldown)
            {
                return;
            }

            LastAction = DateTime.UtcNow;
            if (IsAfk)
            {
                CmdAfk.ToggleAfk(this, "");
            }
            /*if (!CheckIfInsideBlock()) { clippos = pos; cliprot = rot; }*/
        }