From 8ee819bbb20db25c17f833e8546332fbeac58ea4 Mon Sep 17 00:00:00 2001 From: Jitse Boonstra Date: Thu, 25 Jun 2020 11:35:24 +0200 Subject: [PATCH] Added support for 1.16 --- api/pom.xml | 2 +- nms/pom.xml | 3 +- nms/v1_10_R1/pom.xml | 2 +- nms/v1_11_R1/pom.xml | 2 +- nms/v1_12_R1/pom.xml | 2 +- nms/v1_13_R1/pom.xml | 2 +- nms/v1_13_R2/pom.xml | 2 +- nms/v1_14_R1/pom.xml | 2 +- nms/v1_15_R1/pom.xml | 2 +- nms/v1_16_R1/pom.xml | 24 ++++ .../npclib/nms/v1_16_R1/NPC_v1_16_R1.java | 126 ++++++++++++++++++ ...acketPlayOutEntityHeadRotationWrapper.java | 26 ++++ .../PacketPlayOutEntityMetadataWrapper.java | 39 ++++++ .../PacketPlayOutNamedEntitySpawnWrapper.java | 38 ++++++ .../PacketPlayOutPlayerInfoWrapper.java | 39 ++++++ .../PacketPlayOutScoreboardTeamWrapper.java | 52 ++++++++ nms/v1_8_R2/pom.xml | 2 +- nms/v1_8_R3/pom.xml | 2 +- nms/v1_9_R1/pom.xml | 2 +- nms/v1_9_R2/pom.xml | 2 +- plugin/pom.xml | 8 +- pom.xml | 2 +- 22 files changed, 366 insertions(+), 15 deletions(-) create mode 100644 nms/v1_16_R1/pom.xml create mode 100644 nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/NPC_v1_16_R1.java create mode 100644 nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityHeadRotationWrapper.java create mode 100644 nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityMetadataWrapper.java create mode 100644 nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutNamedEntitySpawnWrapper.java create mode 100644 nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutPlayerInfoWrapper.java create mode 100644 nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutScoreboardTeamWrapper.java diff --git a/api/pom.xml b/api/pom.xml index 592087b..04993c0 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -8,7 +8,7 @@ npclib net.jitse - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-api diff --git a/nms/pom.xml b/nms/pom.xml index a50f313..c073a82 100644 --- a/nms/pom.xml +++ b/nms/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms @@ -25,6 +25,7 @@ v1_13_R2 v1_14_R1 v1_15_R1 + v1_16_R1 diff --git a/nms/v1_10_R1/pom.xml b/nms/v1_10_R1/pom.xml index 6ba7886..881bb41 100755 --- a/nms/v1_10_R1/pom.xml +++ b/nms/v1_10_R1/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_10_R1 diff --git a/nms/v1_11_R1/pom.xml b/nms/v1_11_R1/pom.xml index be5a75a..3055261 100755 --- a/nms/v1_11_R1/pom.xml +++ b/nms/v1_11_R1/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_11_R1 diff --git a/nms/v1_12_R1/pom.xml b/nms/v1_12_R1/pom.xml index 34a4ff6..2a69e05 100755 --- a/nms/v1_12_R1/pom.xml +++ b/nms/v1_12_R1/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_12_R1 diff --git a/nms/v1_13_R1/pom.xml b/nms/v1_13_R1/pom.xml index 658ab5b..1379b81 100755 --- a/nms/v1_13_R1/pom.xml +++ b/nms/v1_13_R1/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_13_R1 diff --git a/nms/v1_13_R2/pom.xml b/nms/v1_13_R2/pom.xml index 69e8f79..95f2eaf 100755 --- a/nms/v1_13_R2/pom.xml +++ b/nms/v1_13_R2/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_13_R2 diff --git a/nms/v1_14_R1/pom.xml b/nms/v1_14_R1/pom.xml index 005dd62..ab91ec7 100755 --- a/nms/v1_14_R1/pom.xml +++ b/nms/v1_14_R1/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_14_R1 diff --git a/nms/v1_15_R1/pom.xml b/nms/v1_15_R1/pom.xml index 929a2ff..71a04e6 100644 --- a/nms/v1_15_R1/pom.xml +++ b/nms/v1_15_R1/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_15_R1 diff --git a/nms/v1_16_R1/pom.xml b/nms/v1_16_R1/pom.xml new file mode 100644 index 0000000..7c521e3 --- /dev/null +++ b/nms/v1_16_R1/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + jar + + + net.jitse + npclib-nms + 2.8-SNAPSHOT + + + npclib-nms-v1_16_R1 + + + + org.spigotmc + spigot + 1.16.1-R0.1-SNAPSHOT + provided + + + diff --git a/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/NPC_v1_16_R1.java b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/NPC_v1_16_R1.java new file mode 100644 index 0000000..c7ee60c --- /dev/null +++ b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/NPC_v1_16_R1.java @@ -0,0 +1,126 @@ +package net.jitse.npclib.nms.v1_16_R1; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.datafixers.util.Pair; +import net.jitse.npclib.NPCLib; +import net.jitse.npclib.api.skin.Skin; +import net.jitse.npclib.api.state.NPCSlot; +import net.jitse.npclib.hologram.Hologram; +import net.jitse.npclib.internal.MinecraftVersion; +import net.jitse.npclib.internal.NPCBase; +import net.jitse.npclib.nms.v1_16_R1.packets.*; +import net.minecraft.server.v1_16_R1.*; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.Collections; +import java.util.List; + +/** + * @author Jitse Boonstra + */ +public class NPC_v1_16_R1 extends NPCBase { + + private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn; + private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister; + private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove; + private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation; + private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy; + + public NPC_v1_16_R1(NPCLib instance, List lines) { + super(instance, lines); + } + + @Override + public void createPackets() { + this.hologram = new Hologram(MinecraftVersion.V1_15_R1, location.clone().add(0, 0.5, 0), text); + + PacketPlayOutPlayerInfoWrapper packetPlayOutPlayerInfoWrapper = new PacketPlayOutPlayerInfoWrapper(); + + // Packets for spawning the NPC: + this.packetPlayOutScoreboardTeamRegister = new PacketPlayOutScoreboardTeamWrapper() + .createRegisterTeam(name); // First packet to send. + + this.packetPlayOutPlayerInfoAdd = packetPlayOutPlayerInfoWrapper + .create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, gameProfile, name); // Second packet to send. + + this.packetPlayOutNamedEntitySpawn = new PacketPlayOutNamedEntitySpawnWrapper() + .create(uuid, location, entityId); // Third packet to send. + + this.packetPlayOutEntityHeadRotation = new PacketPlayOutEntityHeadRotationWrapper() + .create(location, entityId); // Fourth packet to send. + + this.packetPlayOutPlayerInfoRemove = packetPlayOutPlayerInfoWrapper + .create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, gameProfile, name); // Fifth packet to send (delayed). + + // Packet for destroying the NPC: + this.packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(entityId); // First packet to send. + } + + @Override + public void sendShowPackets(Player player) { + PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; + + if (hasTeamRegistered.add(player.getUniqueId())) + playerConnection.sendPacket(packetPlayOutScoreboardTeamRegister); + playerConnection.sendPacket(packetPlayOutPlayerInfoAdd); + playerConnection.sendPacket(packetPlayOutNamedEntitySpawn); + playerConnection.sendPacket(packetPlayOutEntityHeadRotation); + sendMetadataPacket(player); + + hologram.show(player); + + // Removing the player info after 10 seconds. + Bukkit.getScheduler().runTaskLater(instance.getPlugin(), () -> + playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 200); + } + + @Override + public void sendHidePackets(Player player) { + PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; + + playerConnection.sendPacket(packetPlayOutEntityDestroy); + playerConnection.sendPacket(packetPlayOutPlayerInfoRemove); + + hologram.hide(player); + } + + @Override + public void sendMetadataPacket(Player player) { + PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadataWrapper().create(activeStates, entityId); + + playerConnection.sendPacket(packet); + } + + @Override + public void sendEquipmentPacket(Player player, NPCSlot slot, boolean auto) { + PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; + + EnumItemSlot nmsSlot = slot.getNmsEnum(EnumItemSlot.class); + ItemStack item = getItem(slot); + + Pair pair = new Pair<>(nmsSlot, CraftItemStack.asNMSCopy(item)); + PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, Collections.singletonList(pair)); + playerConnection.sendPacket(packet); + } + + @Override + public void updateSkin(Skin skin) { + GameProfile newProfile = new GameProfile(uuid, name); + newProfile.getProperties().get("textures").clear(); + newProfile.getProperties().put("textures", new Property("textures", skin.getValue(), skin.getSignature())); + this.packetPlayOutPlayerInfoAdd = new PacketPlayOutPlayerInfoWrapper().create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, newProfile, name); + for (Player player : Bukkit.getOnlinePlayers()) { + PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; + playerConnection.sendPacket(packetPlayOutPlayerInfoRemove); + playerConnection.sendPacket(packetPlayOutEntityDestroy); + playerConnection.sendPacket(packetPlayOutPlayerInfoAdd); + playerConnection.sendPacket(packetPlayOutNamedEntitySpawn); + } + } +} diff --git a/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityHeadRotationWrapper.java b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityHeadRotationWrapper.java new file mode 100644 index 0000000..8651081 --- /dev/null +++ b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityHeadRotationWrapper.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018 Jitse Boonstra + */ + +package net.jitse.npclib.nms.v1_16_R1.packets; + +import com.comphenix.tinyprotocol.Reflection; +import net.minecraft.server.v1_16_R1.PacketPlayOutEntityHeadRotation; +import org.bukkit.Location; + +/** + * @author Jitse Boonstra + */ +public class PacketPlayOutEntityHeadRotationWrapper { + + public PacketPlayOutEntityHeadRotation create(Location location, int entityId) { + PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation = new PacketPlayOutEntityHeadRotation(); + + Reflection.getField(packetPlayOutEntityHeadRotation.getClass(), "a", int.class). + set(packetPlayOutEntityHeadRotation, entityId); + Reflection.getField(packetPlayOutEntityHeadRotation.getClass(), "b", byte.class) + .set(packetPlayOutEntityHeadRotation, (byte) ((int) location.getYaw() * 256.0F / 360.0F)); + + return packetPlayOutEntityHeadRotation; + } +} diff --git a/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityMetadataWrapper.java b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityMetadataWrapper.java new file mode 100644 index 0000000..a610b12 --- /dev/null +++ b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutEntityMetadataWrapper.java @@ -0,0 +1,39 @@ +package net.jitse.npclib.nms.v1_16_R1.packets; + +import net.jitse.npclib.api.state.NPCState; +import net.minecraft.server.v1_16_R1.DataWatcher; +import net.minecraft.server.v1_16_R1.DataWatcherObject; +import net.minecraft.server.v1_16_R1.DataWatcherRegistry; +import net.minecraft.server.v1_16_R1.PacketPlayOutEntityMetadata; + +import java.util.Collection; + +public class PacketPlayOutEntityMetadataWrapper { + + public PacketPlayOutEntityMetadata create(Collection activateStates, int entityId) { + DataWatcher dataWatcher = new DataWatcher(null); + dataWatcher.register(new DataWatcherObject<>(16, DataWatcherRegistry.a), (byte) 127); + + byte masked = NPCState.getMasked(activateStates); + // TODO: Find out why NPCState#CROUCHED doesn't work. + dataWatcher.register(new DataWatcherObject<>(0, DataWatcherRegistry.a), masked); + +// for (Player online : Bukkit.getOnlinePlayers()) { +// DataWatcher watcher = ((CraftPlayer) online).getHandle().getDataWatcher(); +// try { +// Field entriesField = watcher.getClass().getDeclaredField("entries"); +// entriesField.setAccessible(true); +// +// Int2ObjectOpenHashMap> entries = (Int2ObjectOpenHashMap>) entriesField.get(watcher); +// entries.forEach((integer, item) -> { +// if (item.b() instanceof Boolean || item.b() instanceof Byte) +// online.sendMessage(integer + ": " + item.b() + " type = " + item.b().getClass().toString()); +// }); +// } catch (NoSuchFieldException | IllegalAccessException e) { +// e.printStackTrace(); +// } +// } + + return new PacketPlayOutEntityMetadata(entityId, dataWatcher, true); + } +} diff --git a/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutNamedEntitySpawnWrapper.java b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutNamedEntitySpawnWrapper.java new file mode 100644 index 0000000..498ffa2 --- /dev/null +++ b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutNamedEntitySpawnWrapper.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018 Jitse Boonstra + */ + +package net.jitse.npclib.nms.v1_16_R1.packets; + +import com.comphenix.tinyprotocol.Reflection; +import net.minecraft.server.v1_16_R1.PacketPlayOutNamedEntitySpawn; +import org.bukkit.Location; + +import java.util.UUID; + +/** + * @author Jitse Boonstra + */ +public class PacketPlayOutNamedEntitySpawnWrapper { + + public PacketPlayOutNamedEntitySpawn create(UUID uuid, Location location, int entityId) { + PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn = new PacketPlayOutNamedEntitySpawn(); + + Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "a", int.class) + .set(packetPlayOutNamedEntitySpawn, entityId); + Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "b", UUID.class) + .set(packetPlayOutNamedEntitySpawn, uuid); + Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "c", double.class) + .set(packetPlayOutNamedEntitySpawn, location.getX()); + Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "d", double.class) + .set(packetPlayOutNamedEntitySpawn, location.getY()); + Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "e", double.class) + .set(packetPlayOutNamedEntitySpawn, location.getZ()); + Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "f", byte.class) + .set(packetPlayOutNamedEntitySpawn, (byte) ((int) (location.getYaw() * 256.0F / 360.0F))); + Reflection.getField(packetPlayOutNamedEntitySpawn.getClass(), "g", byte.class) + .set(packetPlayOutNamedEntitySpawn, (byte) ((int) (location.getPitch() * 256.0F / 360.0F))); + + return packetPlayOutNamedEntitySpawn; + } +} diff --git a/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutPlayerInfoWrapper.java b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutPlayerInfoWrapper.java new file mode 100644 index 0000000..82589da --- /dev/null +++ b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutPlayerInfoWrapper.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018 Jitse Boonstra + */ + +package net.jitse.npclib.nms.v1_16_R1.packets; + +import com.comphenix.tinyprotocol.Reflection; +import com.mojang.authlib.GameProfile; +import net.minecraft.server.v1_16_R1.EnumGamemode; +import net.minecraft.server.v1_16_R1.IChatBaseComponent; +import net.minecraft.server.v1_16_R1.PacketPlayOutPlayerInfo; + +import java.util.Collections; +import java.util.List; + +/** + * @author Jitse Boonstra + */ +public class PacketPlayOutPlayerInfoWrapper { + + private final Class packetPlayOutPlayerInfoClazz = Reflection.getMinecraftClass("PacketPlayOutPlayerInfo"); + private final Class playerInfoDataClazz = Reflection.getMinecraftClass("PacketPlayOutPlayerInfo$PlayerInfoData"); + private final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClazz, + packetPlayOutPlayerInfoClazz, GameProfile.class, int.class, EnumGamemode.class, IChatBaseComponent.class); + + public PacketPlayOutPlayerInfo create(PacketPlayOutPlayerInfo.EnumPlayerInfoAction action, GameProfile gameProfile, String name) { + PacketPlayOutPlayerInfo packetPlayOutPlayerInfo = new PacketPlayOutPlayerInfo(); + Reflection.getField(packetPlayOutPlayerInfo.getClass(), "a", PacketPlayOutPlayerInfo.EnumPlayerInfoAction.class) + .set(packetPlayOutPlayerInfo, action); + + Object playerInfoData = playerInfoDataConstructor.invoke(packetPlayOutPlayerInfo, gameProfile, 1, EnumGamemode.NOT_SET, + IChatBaseComponent.ChatSerializer.b("{\"text\":\"[NPC] " + name + "\",\"color\":\"dark_gray\"}")); + + Reflection.FieldAccessor fieldAccessor = Reflection.getField(packetPlayOutPlayerInfo.getClass(), "b", List.class); + fieldAccessor.set(packetPlayOutPlayerInfo, Collections.singletonList(playerInfoData)); + + return packetPlayOutPlayerInfo; + } +} diff --git a/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutScoreboardTeamWrapper.java b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutScoreboardTeamWrapper.java new file mode 100644 index 0000000..a163237 --- /dev/null +++ b/nms/v1_16_R1/src/main/java/net/jitse/npclib/nms/v1_16_R1/packets/PacketPlayOutScoreboardTeamWrapper.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 Jitse Boonstra + */ + +package net.jitse.npclib.nms.v1_16_R1.packets; + +import com.comphenix.tinyprotocol.Reflection; +import net.minecraft.server.v1_16_R1.ChatComponentText; +import net.minecraft.server.v1_16_R1.IChatBaseComponent; +import net.minecraft.server.v1_16_R1.PacketPlayOutScoreboardTeam; + +import java.util.Collection; +import java.util.Collections; + +/** + * @author Jitse Boonstra + */ +public class PacketPlayOutScoreboardTeamWrapper { + + public PacketPlayOutScoreboardTeam createRegisterTeam(String name) { + PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeam = new PacketPlayOutScoreboardTeam(); + + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "i", int.class) + .set(packetPlayOutScoreboardTeam, 0); + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "a", String.class) + .set(packetPlayOutScoreboardTeam, name); + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "b", IChatBaseComponent.class) + .set(packetPlayOutScoreboardTeam, new ChatComponentText(name)); + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "e", String.class) + .set(packetPlayOutScoreboardTeam, "never"); + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "f", String.class) + .set(packetPlayOutScoreboardTeam, "never"); + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "j", int.class) + .set(packetPlayOutScoreboardTeam, 0); + Reflection.FieldAccessor collectionFieldAccessor = Reflection.getField( + packetPlayOutScoreboardTeam.getClass(), "h", Collection.class); + collectionFieldAccessor.set(packetPlayOutScoreboardTeam, Collections.singletonList(name)); + + return packetPlayOutScoreboardTeam; + } + + public PacketPlayOutScoreboardTeam createUnregisterTeam(String name) { + PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeam = new PacketPlayOutScoreboardTeam(); + + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "i", int.class) + .set(packetPlayOutScoreboardTeam, 1); + Reflection.getField(packetPlayOutScoreboardTeam.getClass(), "a", String.class) + .set(packetPlayOutScoreboardTeam, name); + + return packetPlayOutScoreboardTeam; + } +} diff --git a/nms/v1_8_R2/pom.xml b/nms/v1_8_R2/pom.xml index 426235e..d3a4a9e 100755 --- a/nms/v1_8_R2/pom.xml +++ b/nms/v1_8_R2/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_8_R2 diff --git a/nms/v1_8_R3/pom.xml b/nms/v1_8_R3/pom.xml index 62cf623..abca64d 100755 --- a/nms/v1_8_R3/pom.xml +++ b/nms/v1_8_R3/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_8_R3 diff --git a/nms/v1_9_R1/pom.xml b/nms/v1_9_R1/pom.xml index 240a64a..855a828 100755 --- a/nms/v1_9_R1/pom.xml +++ b/nms/v1_9_R1/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_9_R1 diff --git a/nms/v1_9_R2/pom.xml b/nms/v1_9_R2/pom.xml index 146b0fc..e593cd2 100755 --- a/nms/v1_9_R2/pom.xml +++ b/nms/v1_9_R2/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib-nms - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-nms-v1_9_R2 diff --git a/plugin/pom.xml b/plugin/pom.xml index 147d71e..113b733 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -8,7 +8,7 @@ net.jitse npclib - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT npclib-plugin @@ -92,6 +92,12 @@ ${project.version} compile + + net.jitse + npclib-nms-v1_16_R1 + ${project.version} + compile + diff --git a/pom.xml b/pom.xml index d95afb0..07841be 100755 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ net.jitse npclib - 2.7.2-SNAPSHOT + 2.8-SNAPSHOT UTF-8