Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ProtocolManager man = ProtocolLibrary.getProtocolManager();
- man.addPacketListener(myAwesomePacketListener);
- Player playerToUpdate = null;
- Player playerToFool = null;
- PacketContainer rem = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);//new packet of type player info
- rem.getPlayerInfoAction().writeSafely(0, PlayerInfoAction.REMOVE_PLAYER);//write to the packet that this packet will be in this case removing a player
- StructureModifier<List<PlayerInfoData>> remSmodListPlayerInfo = rem.getPlayerInfoDataLists();//get the data lists of PlayerInfo, as we know this is a player info packet
- remSmodListPlayerInfo.writeSafely(0, Arrays.asList(new PlayerInfoData(WrappedGameProfile.fromPlayer(playerToUpdate), 0, NativeGameMode.NOT_SET, null)));//Write a new list to the packet, as this packet, in this case, will only contain one entry
- PacketContainer add = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
- add.getPlayerInfoAction().writeSafely(0, PlayerInfoAction.ADD_PLAYER);
- StructureModifier<List<PlayerInfoData>> smodListPlayerInfo = rem.getPlayerInfoDataLists();
- smodListPlayerInfo.writeSafely(0, Arrays.asList(new PlayerInfoData(WrappedGameProfile.fromPlayer(playerToUpdate), 0, NativeGameMode.fromBukkit(playerToUpdate.getGameMode()), WrappedChatComponent.fromText(playerToUpdate.getDisplayName()))));
- try {//send packets to the player to fool
- man.sendServerPacket(playerToFool, rem);
- man.sendServerPacket(playerToFool, add);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement