dmulloy2 / ProtocolLib

Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
1.04k stars 257 forks source link

Hey i have problem #3303

Open dawidox1238 opened 2 weeks ago

dawidox1238 commented 2 weeks ago
@Generated
    @Getter
    @RequiredArgsConstructor
    public static class PlayOutPlayerInfo implements PacketWrapper {
        private final EnumSet<EnumWrappers.PlayerInfoAction> playerInfo;
        private final Entity entity;
        private final PacketData packetData;
        private EnumWrappers.NativeGameMode gameMode;

        public static @NotNull PlayOutPlayerInfo of(EnumSet<EnumWrappers.PlayerInfoAction> playerInfo, Entity entity, PacketData packetData) {
            return new PlayOutPlayerInfo(playerInfo, entity, packetData);
        }

        @Override
        public void sendPacket() {
            PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
            packet.getPlayerInfoActions().writeSafely(0, EnumSet.of(playerInfo.iterator().next()));
           //ERROR LINE DOWN
            packet.getPlayerInfoDataLists().writeSafely(0, Collections.singletonList(
                    new PlayerInfoData(
                            new WrappedGameProfile(entity.getUniqueId(), entity.getName()),
                            1,
                            EnumWrappers.NativeGameMode.fromBukkit(
                                    (gameMode == null ? GameMode.SURVIVAL : gameMode.toBukkit())),
                            WrappedChatComponent.fromText(entity.getName())
                    )
            ));
            NMSPacketWrapper.sendPacket(packet, packetData);
        }
    }

    Caused by: java.lang.ClassCastException: Cannot cast java.util.ArrayList to java.util.EnumSet
        at java.base/java.lang.Class.cast(Class.java:4067) ~[?:?]
        at com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor.set(DefaultFieldAccessor.java:41) ~[?:?]
        at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:361) ~[?:?]
        at com.comphenix.protocol.reflect.StructureModifier.writeSafely(StructureModifier.java:337) ~[?:?]
        at hp.project.server.core.packets.NMSPacketWrapper$PlayOutPlayerInfo.sendPacket(NMSPacketWrapper.java:75) ~[?:?]
        at hp.project.server.core.features.npc.PersonalNPC.create(PersonalNPC.java:53) ~[?:?]
        at hp.project.server.core.commands.admin.TestCommand.commandExecute(TestCommand.java:22) ~[?:?]
        at hp.project.server.core.commands.AbstractCommand$1.execute(AbstractCommand.java:69) ~[?:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:150) ~[spigot-api-1.21.3-R0.1-SNAPSHOT.jar:?]
        ... 27 more
birthdates commented 2 days ago

Bump, I have the same problem

Edit: This issue seems to have a solution.