ProtocolLib

3M Downloads

Exception getting enum from class net.minecraft.server.v1_14_R1.PacketPlayOutWorldParticles at index 0

rkubik opened this issue ยท 2 comments

commented

MC: 1.14.1
Version: 4.5.0-SNAPSHOT (latest)

Is getPlayerInfoAction deprecated? It throws an error but I'm not sure what else to use instead.

PARTICLE_CLASS = getEnum(PacketType.Play.Server.WORLD_PARTICLES.getPacketClass(), 0);

Code

	public static void updateTabList() {
		for (Player player : Bukkit.getOnlinePlayers()) {
			PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
			List<PlayerInfoData> data = new ArrayList<PlayerInfoData>();
			data.add(new PlayerInfoData(
				WrappedGameProfile.fromPlayer(player),
				0,
				NativeGameMode.SURVIVAL,
				WrappedChatComponent.fromText("Player Clone")
			));
			if (data.size() > 0) {
				packet.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
				packet.getPlayerInfoDataLists().write(0, data);
				try {
					ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
				} catch (InvocationTargetException e) {
					e.printStackTrace();
				}
			}
		}
	}

Full error:

[20:04:26] [Server thread/WARN]: [ProtocolLib] [Debug] Exception getting enum from class net.minecraft.server.v1_14_R1.PacketPlayOutWorldParticles at index 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.8.0_211]
        at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_211]
        at com.comphenix.protocol.wrappers.EnumWrappers.getEnum(EnumWrappers.java:451) [ProtocolLib-4.5.0.jar:?]
        at com.comphenix.protocol.wrappers.EnumWrappers.initialize(EnumWrappers.java:406) [ProtocolLib-4.5.0.jar:?]
        at com.comphenix.protocol.wrappers.EnumWrappers.getPlayerInfoActionClass(EnumWrappers.java:503) [ProtocolLib-4.5.0.jar:?]
        at com.comphenix.protocol.events.PacketContainer.getPlayerInfoAction(PacketContainer.java:763) [ProtocolLib-4.5.0.jar:?]

I suppose this is related to commit:

502c596

commented

Does the code work as intended otherwise?

commented

Not from what I can tell. The tab list does not contain the new player.