public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            Action = (PlayerListAction)reader.ReadVarInt();
            Length = reader.ReadVarInt();
            UUID   = reader.ReadBigInteger();

            switch (Action)
            {
            case PlayerListAction.AddPlayer:
                PlayerList = new PlayerListActionAddPlayer().FromReader(reader);
                break;

            case PlayerListAction.UpdateGamemode:
                PlayerList = new PlayerListActionUpdateGamemode().FromReader(reader);
                break;

            case PlayerListAction.UpdateLatency:
                PlayerList = new PlayerListActionUpdateLatency().FromReader(reader);
                break;

            case PlayerListAction.UpdateDisplayName:
                PlayerList = new PlayerListActionUpdateDisplayName().FromReader(reader);
                break;

            case PlayerListAction.RemovePlayer:
                PlayerList = new PlayerListActionRemovePlayer().FromReader(reader);
                break;
            }

            return(this);
        }
Exemple #2
0
        public override void Decode(MinecraftStream stream)
        {
            Action = (PlayerListAction)stream.ReadVarInt();
            int count = stream.ReadVarInt();

            if (Action == PlayerListAction.AddPlayer)
            {
                ReadAddPlayerEntries(count, stream);
                return;
            }

            if (Action == PlayerListAction.UpdateLatency)
            {
                ReadUpdateLatencyEntries(count, stream);
                return;
            }

            if (Action == PlayerListAction.RemovePlayer)
            {
                RemovePlayerEntries = new RemovePlayerEntry[count];
                for (int i = 0; i < RemovePlayerEntries.Length; i++)
                {
                    var entry = new RemovePlayerEntry();
                    entry.UUID             = stream.ReadUuid();
                    RemovePlayerEntries[i] = entry;
                }
            }

            if (Action == PlayerListAction.UpdateDisplayName)
            {
                ReadUpdateDisplayNameEntries(count, stream);
            }
        }
Exemple #3
0
        public void ReadPacket(IMinecraftStreamReader reader)
        {
            Action = (PlayerListAction)reader.ReadVarInt();
            var count = reader.ReadVarInt();

            PlayerList = new List <IPlayerListItem>(count);

            for (int i = 0; i < count; i++)
            {
                var listItem = CreatePlayerListItem(Action);
                listItem.Uuid = new PlayerUuid(reader.ReadByteArray(16));
                listItem.FromReader(reader);

                PlayerList.Add(listItem);
            }
        }
Exemple #4
0
        private static IPlayerListItem CreatePlayerListItem(PlayerListAction action)
        {
            switch (action)
            {
            case PlayerListAction.AddPlayer:
                return(new PlayerListItemActionAddPlayer());

            case PlayerListAction.UpdateGamemode:
                return(new PlayerListItemActionUpdateGamemode());

            case PlayerListAction.UpdateLatency:
                return(new PlayerListItemActionUpdateLatency());

            case PlayerListAction.UpdateDisplayName:
                return(new PlayerListItemActionUpdateDisplayName());

            case PlayerListAction.RemovePlayer:
                return(new PlayerListItemActionRemovePlayer());

            default:
                throw new ArgumentException("Invalid Player List Action passed");
            }
        }
        public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            Action = (PlayerListAction) reader.ReadVarInt();
            Length = reader.ReadVarInt();
            UUID = reader.ReadBigInteger();

            switch (Action)
            {
                case PlayerListAction.AddPlayer:
                    PlayerList = new PlayerListActionAddPlayer().FromReader(reader);
                    break;
                case PlayerListAction.UpdateGamemode:
                    PlayerList = new PlayerListActionUpdateGamemode().FromReader(reader);
                    break;
                case PlayerListAction.UpdateLatency:
                    PlayerList = new PlayerListActionUpdateLatency().FromReader(reader);
                    break;
                case PlayerListAction.UpdateDisplayName:
                    PlayerList = new PlayerListActionUpdateDisplayName().FromReader(reader);
                    break;
                case PlayerListAction.RemovePlayer:
                    PlayerList = new PlayerListActionRemovePlayer().FromReader(reader);
                    break;
            }

            return this;
        }