@Override public void onServerChange() { PlayerListItem packet = new PlayerListItem(); packet.setAction( PlayerListItem.Action.REMOVE_PLAYER ); PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ]; int i = 0; for ( UUID uuid : uuids ) { PlayerListItem.Item item = items[i++] = new PlayerListItem.Item(); item.setUuid( uuid ); } packet.setItems( items ); player.unsafe().sendPacket( packet ); uuids.clear(); }
@Override public void onUpdate(PlayerListItem playerListItem) { for ( PlayerListItem.Item item : playerListItem.getItems() ) { if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER ) { uuids.add( item.getUuid() ); } else if ( playerListItem.getAction() == PlayerListItem.Action.REMOVE_PLAYER ) { uuids.remove( item.getUuid() ); } } player.unsafe().sendPacket( playerListItem ); }
@Override public void onServerChange() PlayerListItem packet = new PlayerListItem(); packet.setAction( PlayerListItem.Action.REMOVE_PLAYER ); PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() + usernames.size() ]; int i = 0; item.setDisplayName( username ); packet.setItems( items ); if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 ) for ( PlayerListItem.Item item : packet.getItems() ) PlayerListItem p2 = new PlayerListItem(); p2.setAction( packet.getAction() ); p2.setItems( new PlayerListItem.Item[]
writeString( item.displayName, buf ); // TODO: Server unique only! buf.writeBoolean( action != Action.REMOVE_PLAYER ); buf.writeShort( item.ping );
item.displayName = item.username = readString( buf ); action = !buf.readBoolean() ? Action.REMOVE_PLAYER : Action.ADD_PLAYER; item.ping = buf.readShort();
switch (packet.getAction()) { case ADD_PLAYER: for (PlayerListItem.Item item : packet.getItems()) { if (fakePlayerUUIDSet.contains(item.getUuid())) { throw new AssertionError("UUID collision: " + item); for (PlayerListItem.Item item : packet.getItems()) { TabListItem tabListItem = serverTabList.get(item.getUuid()); if (tabListItem != null) { for (PlayerListItem.Item item : packet.getItems()) { TabListItem tabListItem = serverTabList.get(item.getUuid()); if (tabListItem != null) { for (PlayerListItem.Item item : packet.getItems()) { TabListItem tabListItem = serverTabList.get(item.getUuid()); if (tabListItem != null) { for (PlayerListItem.Item item : packet.getItems()) { serverTabList.remove(item.getUuid()); switch (packet.getAction()) { case ADD_PLAYER: for (PlayerListItem.Item item : packet.getItems()) { if (item.getGamemode() == 3 && item.getUuid().equals(getUniqueId())) { for (PlayerListItem.Item item : packet.getItems()) { if (!serverTabList.containsKey(item.getUuid())) { continue;
PlayerListItem packet = new PlayerListItem(); packet.setAction( PlayerListItem.Action.REMOVE_PLAYER ); PlayerListItem.Item item = new PlayerListItem.Item(); item.setUuid( con.getUniqueId() ); packet.setItems( new PlayerListItem.Item[]
@Override public void onConnect() PlayerListItem playerListItem = new PlayerListItem(); playerListItem.setAction( PlayerListItem.Action.ADD_PLAYER ); Collection<ProxiedPlayer> players = BungeeCord.getInstance().getPlayers(); PlayerListItem.Item[] items = new PlayerListItem.Item[ players.size() ]; playerListItem.setItems( items ); int i = 0; for ( ProxiedPlayer p : players ) for ( PlayerListItem.Item item : playerListItem.getItems() ) PlayerListItem packet = new PlayerListItem(); packet.setAction( playerListItem.getAction() ); packet.setItems( new PlayerListItem.Item[] PlayerListItem packet = new PlayerListItem(); packet.setAction( PlayerListItem.Action.ADD_PLAYER ); PlayerListItem.Item item = new PlayerListItem.Item(); item.setUuid( player.getUniqueId() ); packet.setItems( new PlayerListItem.Item[]
public static PlayerListItem rewrite(PlayerListItem playerListItem) for ( PlayerListItem.Item item : playerListItem.getItems() ) if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_GAMEMODE ) if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_LATENCY )
public PlayerListItem unwrap() { PlayerListItem packet = new PlayerListItem(); packet.setAction(action); packet.setItems(items.stream().map(TabListItemWrapper::unwrap).collect(Collectors.toList()).toArray(new PlayerListItem.Item[items.size()])); return packet; } }
@Override public void onServerSwitch() { for (String player : serverTabList.keySet()) { PlayerListItem pli = new PlayerListItem(); PlayerListItem.Item item = new PlayerListItem.Item(); item.setDisplayName(player); item.setPing(9999); pli.setItems(new PlayerListItem.Item[]{item}); pli.setAction(PlayerListItem.Action.REMOVE_PLAYER); sendPacket(pli); } serverTabListEntryNames.clear(); serverTabList.clear(); } }
@Override public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { if (packet.getAction() == PlayerListItem.Action.ADD_PLAYER || packet.getAction() == PlayerListItem.Action.UPDATE_GAMEMODE) { for (PlayerListItem.Item item : packet.getItems()) { if (userConnection.getUniqueId().equals(item.getUuid())) { userConnection.setGamemode(item.getGamemode()); } } } return super.onPlayerListPacket(packet); } }
@Override public void onServerSwitch() { PlayerListItem packet = new PlayerListItem(); packet.setAction(REMOVE_PLAYER); PlayerListItem.Item[] items = new PlayerListItem.Item[serverTabList.size()]; Iterator<UUID> iterator = serverTabList.keySet().iterator(); for (int i = 0; i < items.length; i++) { items[i] = item(iterator.next()); } packet.setItems(items); if (onPlayerListPacketInternal(packet) != PacketListenerResult.CANCEL) { sendPacket(packet); } serverTeams.clear(); playerToTeamMap.clear(); serverTabList.clear(); serverHeader = null; serverFooter = null; }
@Override public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { if (packet.getAction() == PlayerListItem.Action.ADD_PLAYER) { for (PlayerListItem.Item item : packet.getItems()) { serverTabListEntryNames.add(getName(item)); serverTabList.put(getName(item), item.getPing()); } } else { for (PlayerListItem.Item item : packet.getItems()) { serverTabListEntryNames.remove(getName(item)); serverTabList.remove(getName(item)); } } return passThrough ? PacketListenerResult.PASS : PacketListenerResult.CANCEL; }
private void updateTextInternal(int index, String text) { Preconditions.checkElementIndex(index, size); if (!passtrough && !clientText[index].equals(text)) { PlayerListItem packet = new PlayerListItem(); PlayerListItem.Item item = new PlayerListItem.Item(); item.setUuid(clientUuid[index]); item.setDisplayName(text); packet.setAction(UPDATE_DISPLAY_NAME); packet.setItems(new PlayerListItem.Item[]{item}); sendPacket(packet); } clientText[index] = text; }
@Override protected void sendPacket(DefinedPacket packet) { if (!onlineMode && packet instanceof PlayerListItem) { PlayerListItem pli = (PlayerListItem) packet; if (pli.getAction() == PlayerListItem.Action.ADD_PLAYER) { for (PlayerListItem.Item item : pli.getItems()) { if (fakePlayerUUIDSet.contains(item.getUuid())) { item.setProperties(EMPTY_PROPRTIES); } } } } player.unsafe().sendPacket(packet); }
private void updatePingInternal(int index, int ping) { Preconditions.checkElementIndex(index, size); if (!passtrough && clientPing[index] != ping) { PlayerListItem packet = new PlayerListItem(); PlayerListItem.Item item = new PlayerListItem.Item(); item.setUuid(clientUuid[index]); item.setPing(ping); packet.setAction(UPDATE_LATENCY); packet.setItems(new PlayerListItem.Item[]{item}); sendPacket(packet); } clientPing[index] = ping; }
@Override public void onUpdate(PlayerListItem playerListItem) { for ( PlayerListItem.Item item : playerListItem.getItems() ) { if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER ) { if ( item.getUuid() != null ) { uuids.add( item.getUuid() ); } else { usernames.add( item.getUsername() ); } } else if ( playerListItem.getAction() == PlayerListItem.Action.REMOVE_PLAYER ) { if ( item.getUuid() != null ) { uuids.remove( item.getUuid() ); } else { usernames.remove( item.getUsername() ); } } } player.unsafe().sendPacket( playerListItem ); }
@Override public void onDisconnect() { PlayerListItem packet = new PlayerListItem(); packet.setAction( PlayerListItem.Action.REMOVE_PLAYER ); PlayerListItem.Item item = new PlayerListItem.Item(); item.setUuid( player.getUniqueId() ); item.setUsername( player.getName() ); packet.setItems( new PlayerListItem.Item[] { item } ); BungeeCord.getInstance().broadcast( packet ); } }