Browse Source

Add support for 1.16.4

master
datdenkikniet 2 years ago
parent
commit
16d5dd39f2
26 changed files with 417 additions and 19 deletions
  1. +1
    -1
      README.md
  2. +2
    -2
      api/pom.xml
  3. +3
    -1
      api/src/main/java/net/jitse/npclib/NPCLib.java
  4. +2
    -1
      api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java
  5. +2
    -1
      nms/pom.xml
  6. +1
    -1
      nms/v1_10_R1/pom.xml
  7. +1
    -1
      nms/v1_11_R1/pom.xml
  8. +1
    -1
      nms/v1_12_R1/pom.xml
  9. +1
    -1
      nms/v1_13_R1/pom.xml
  10. +1
    -1
      nms/v1_13_R2/pom.xml
  11. +1
    -1
      nms/v1_14_R1/pom.xml
  12. +1
    -1
      nms/v1_15_R1/pom.xml
  13. +1
    -1
      nms/v1_16_R1/pom.xml
  14. +24
    -0
      nms/v1_16_R3/pom.xml
  15. +150
    -0
      nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/NPC_v1_16_R3.java
  16. +20
    -0
      nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutAnimationWrapper.java
  17. +26
    -0
      nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutEntityHeadRotationWrapper.java
  18. +39
    -0
      nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutEntityMetadataWrapper.java
  19. +38
    -0
      nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutNamedEntitySpawnWrapper.java
  20. +39
    -0
      nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutPlayerInfoWrapper.java
  21. +52
    -0
      nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutScoreboardTeamWrapper.java
  22. +1
    -1
      nms/v1_8_R3/pom.xml
  23. +1
    -1
      nms/v1_9_R1/pom.xml
  24. +1
    -1
      nms/v1_9_R2/pom.xml
  25. +7
    -1
      plugin/pom.xml
  26. +1
    -1
      pom.xml

+ 1
- 1
README.md View File

@ -49,7 +49,7 @@ If you have NPCLib under your `plugins` folder, you may use the following:
<dependency>
<groupId>net.jitse</groupId>
<artifactId>npclib-api</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>


+ 2
- 2
api/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<artifactId>npclib</artifactId>
<groupId>net.jitse</groupId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-api</artifactId>
@ -28,7 +28,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>


+ 3
- 1
api/src/main/java/net/jitse/npclib/NPCLib.java View File

@ -111,7 +111,9 @@ public final class NPCLib {
*/
public NPC createNPC(List<String> text) {
try {
return (NPC) npcClass.getConstructors()[0].newInstance(this, text);
return (NPC) npcClass
.getConstructors()[0]
.newInstance(this, text);
} catch (Exception exception) {
logger.warning("Failed to create NPC. Please report the following stacktrace message", exception);
}


+ 2
- 1
api/src/main/java/net/jitse/npclib/internal/MinecraftVersion.java View File

@ -17,7 +17,8 @@ public enum MinecraftVersion {
V1_13_R2,
V1_14_R1,
V1_15_R1,
V1_16_R1;
V1_16_R1,
V1_16_R3;
public boolean isAboveOrEqual(MinecraftVersion compare) {
return ordinal() >= compare.ordinal();


+ 2
- 1
nms/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms</artifactId>
@ -25,6 +25,7 @@
<module>v1_14_R1</module>
<module>v1_15_R1</module>
<module>v1_16_R1</module>
<module>v1_16_R3</module>
</modules>
<dependencies>


+ 1
- 1
nms/v1_10_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_10_R1</artifactId>


+ 1
- 1
nms/v1_11_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_11_R1</artifactId>


+ 1
- 1
nms/v1_12_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_12_R1</artifactId>


+ 1
- 1
nms/v1_13_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_13_R1</artifactId>


+ 1
- 1
nms/v1_13_R2/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_13_R2</artifactId>


+ 1
- 1
nms/v1_14_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_14_R1</artifactId>


+ 1
- 1
nms/v1_15_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_15_R1</artifactId>


+ 1
- 1
nms/v1_16_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_16_R1</artifactId>


+ 24
- 0
nms/v1_16_R3/pom.xml View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_16_R3</artifactId>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

+ 150
- 0
nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/NPC_v1_16_R3.java View File

@ -0,0 +1,150 @@
package net.jitse.npclib.nms.v1_16_R3;
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.NPCAnimation;
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_R3.packets.*;
import net.minecraft.server.v1_16_R3.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R3.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_R3 extends NPCBase {
private PacketPlayOutNamedEntitySpawn packetPlayOutNamedEntitySpawn;
private PacketPlayOutScoreboardTeam packetPlayOutScoreboardTeamRegister;
private PacketPlayOutPlayerInfo packetPlayOutPlayerInfoAdd, packetPlayOutPlayerInfoRemove;
private PacketPlayOutEntityHeadRotation packetPlayOutEntityHeadRotation;
private PacketPlayOutEntityDestroy packetPlayOutEntityDestroy;
private PacketPlayOutAnimation packetPlayOutAnimation;
public NPC_v1_16_R3(NPCLib instance, List<String> lines) {
super(instance, lines);
}
@Override
public Hologram getPlayerHologram(Player player) {
Hologram holo = super.getPlayerHologram(player);
if (holo == null) {
holo = new Hologram(MinecraftVersion.V1_16_R3, location.clone().add(0, 0.5, 0), getPlayerLines(player));
}
super.textDisplayHolograms.put(player.getUniqueId(), holo);
return holo;
}
@Override
public void createPackets() {
Bukkit.getOnlinePlayers().forEach(this::createPackets);
}
@Override
public void createPackets(Player player) {
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);
getPlayerHologram(player).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);
getPlayerHologram(player).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<EnumItemSlot, net.minecraft.server.v1_16_R3.ItemStack> pair = new Pair<>(nmsSlot, CraftItemStack.asNMSCopy(item));
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, Collections.singletonList(pair));
playerConnection.sendPacket(packet);
}
@Override
public void sendAnimationPacket(Player player, NPCAnimation animation) {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
PacketPlayOutAnimation packet = new PacketPlayOutAnimationWrapper().create(animation, entityId);
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);
}
}
}

+ 20
- 0
nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutAnimationWrapper.java View File

@ -0,0 +1,20 @@
package net.jitse.npclib.nms.v1_16_R3.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.jitse.npclib.api.state.NPCAnimation;
import net.minecraft.server.v1_16_R3.PacketPlayOutAnimation;
public class PacketPlayOutAnimationWrapper {
public PacketPlayOutAnimation create(NPCAnimation npcAnimation, int entityId) {
PacketPlayOutAnimation packetPlayOutAnimation = new PacketPlayOutAnimation();
Reflection.getField(packetPlayOutAnimation.getClass(), "a", int.class)
.set(packetPlayOutAnimation, entityId);
Reflection.getField(packetPlayOutAnimation.getClass(), "b", int.class)
.set(packetPlayOutAnimation, npcAnimation.getId());
return packetPlayOutAnimation;
}
}

+ 26
- 0
nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutEntityHeadRotationWrapper.java View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_16_R3.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_16_R3.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;
}
}

+ 39
- 0
nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutEntityMetadataWrapper.java View File

@ -0,0 +1,39 @@
package net.jitse.npclib.nms.v1_16_R3.packets;
import net.jitse.npclib.api.state.NPCState;
import net.minecraft.server.v1_16_R3.DataWatcher;
import net.minecraft.server.v1_16_R3.DataWatcherObject;
import net.minecraft.server.v1_16_R3.DataWatcherRegistry;
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata;
import java.util.Collection;
public class PacketPlayOutEntityMetadataWrapper {
public PacketPlayOutEntityMetadata create(Collection<NPCState> 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<DataWatcher.Item<?>> entries = (Int2ObjectOpenHashMap<DataWatcher.Item<?>>) 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);
}
}

+ 38
- 0
nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutNamedEntitySpawnWrapper.java View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_16_R3.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_16_R3.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;
}
}

+ 39
- 0
nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutPlayerInfoWrapper.java View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_16_R3.packets;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_16_R3.EnumGamemode;
import net.minecraft.server.v1_16_R3.IChatBaseComponent;
import net.minecraft.server.v1_16_R3.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<List> fieldAccessor = Reflection.getField(packetPlayOutPlayerInfo.getClass(), "b", List.class);
fieldAccessor.set(packetPlayOutPlayerInfo, Collections.singletonList(playerInfoData));
return packetPlayOutPlayerInfo;
}
}

+ 52
- 0
nms/v1_16_R3/src/main/java/net/jitse/npclib/nms/v1_16_R3/packets/PacketPlayOutScoreboardTeamWrapper.java View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.nms.v1_16_R3.packets;
import com.comphenix.tinyprotocol.Reflection;
import net.minecraft.server.v1_16_R3.ChatComponentText;
import net.minecraft.server.v1_16_R3.IChatBaseComponent;
import net.minecraft.server.v1_16_R3.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<Collection> 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;
}
}

+ 1
- 1
nms/v1_8_R3/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_8_R3</artifactId>


+ 1
- 1
nms/v1_9_R1/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_9_R1</artifactId>


+ 1
- 1
nms/v1_9_R2/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-nms-v1_9_R2</artifactId>


+ 7
- 1
plugin/pom.xml View File

@ -8,7 +8,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
</parent>
<artifactId>npclib-plugin</artifactId>
@ -92,6 +92,12 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms-v1_16_R3</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>


+ 1
- 1
pom.xml View File

@ -7,7 +7,7 @@
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.11-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>


Loading…
Cancel
Save