From 768e21d1b56e20e3befbebd4082213f83561db2b Mon Sep 17 00:00:00 2001 From: Speentie8081 Date: Sun, 22 Jul 2018 09:09:39 -0500 Subject: [PATCH] Update NBTFactory to support spigot 1.13 --- .../java/com/plotsquared/bukkit/util/NbtFactory.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java index f1795005d..69690cc8c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java @@ -73,11 +73,12 @@ public class NbtFactory { ClassLoader loader = NbtFactory.class.getClassLoader(); String packageName = getPackageName(); + String craftpackageName = getCraftPackageName(); Class offlinePlayer = loader.loadClass(packageName + ".CraftOfflinePlayer"); // Prepare NBT this.COMPOUND_CLASS = getMethod(0, Modifier.STATIC, offlinePlayer, "getData").getReturnType(); - this.BASE_CLASS = this.COMPOUND_CLASS.getSuperclass(); + this.BASE_CLASS = loader.loadClass(craftpackageName + ".NBTBase"); this.NBT_GET_TYPE = getMethod(0, Modifier.STATIC, this.BASE_CLASS, "getTypeId"); this.NBT_CREATE_TAG = getMethod(Modifier.STATIC, 0, this.BASE_CLASS, "createTag", byte.class); @@ -400,9 +401,14 @@ public class NbtFactory { return name; } else { // Fallback - return "org.bukkit.craftbukkit.v1_7_R3"; + return "org.bukkit.craftbukkit.v1_13_R1"; } } + + private String getCraftPackageName() { + String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; + return "net.minecraft.server." + version; + } @SuppressWarnings("unchecked") private Map getDataMap(Object handle) {