ProtocolLib

3M Downloads

Problem With Wrapper

kopolinka32 opened this issue ยท 1 comments

commented

Hello i have problem with code

    ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();

    PacketContainer packetContainer = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
    if(!(this.players.contains(player.getUniqueId()))) {
        packetContainer.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
        packetContainer.getPlayerInfoDataLists().write(0, playerInfoDatas);
        System.out.println("XD");
    } else {
        packetContainer.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME);
        packetContainer.getPlayerInfoDataLists().write(0, playerInfoDatas);
        System.out.println("XDC");
    }

    this.players.add(player.getUniqueId());
    protocolManager.sendServerPacket(player, packetContainer);
    
    
  this is a code how i send a packet but a Wrapper named UPDATE_DISPLAY_NAME doesnt work
  this is whta is a PlayerInfoDatas:
  
 for(int i = 0; i<= 80; i++) {
        GameProfile profile = new GameProfile(UUID.randomUUID(), String.format("%03d", i));

        PlayerInfoData data = new PlayerInfoData(
                WrappedGameProfile.fromHandle(profile),
                0,
                EnumWrappers.NativeGameMode.CREATIVE,
                WrappedChatComponent.fromLegacyText(TextUtil.fixColor(members.get(i))));

                playerInfoDatas.add(data);
    }
commented

I'm pretty sure the code that you provided works, as long as you provide the same unique id to the update action as you did to the add action (which is currently a random uuid).