Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1.         ProtocolManager man = ProtocolLibrary.getProtocolManager();
  2.         man.addPacketListener(myAwesomePacketListener);
  3.        
  4.         Player playerToUpdate = null;
  5.         Player playerToFool = null;
  6.        
  7.         PacketContainer rem = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);//new packet of type player info
  8.         rem.getPlayerInfoAction().writeSafely(0, PlayerInfoAction.REMOVE_PLAYER);//write to the packet that this packet will be in this case removing a player
  9.         StructureModifier<List<PlayerInfoData>> remSmodListPlayerInfo = rem.getPlayerInfoDataLists();//get the data lists of PlayerInfo, as we know this is a player info packet
  10.         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
  11.        
  12.         PacketContainer add = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
  13.         add.getPlayerInfoAction().writeSafely(0, PlayerInfoAction.ADD_PLAYER);
  14.         StructureModifier<List<PlayerInfoData>> smodListPlayerInfo = rem.getPlayerInfoDataLists();
  15.         smodListPlayerInfo.writeSafely(0, Arrays.asList(new PlayerInfoData(WrappedGameProfile.fromPlayer(playerToUpdate), 0, NativeGameMode.fromBukkit(playerToUpdate.getGameMode()), WrappedChatComponent.fromText(playerToUpdate.getDisplayName()))));
  16.        
  17.        
  18.         try {//send packets to the player to fool
  19.             man.sendServerPacket(playerToFool, rem);
  20.             man.sendServerPacket(playerToFool, add);
  21.         } catch (InvocationTargetException e) {
  22.             e.printStackTrace();
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement