mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Update NBTFactory to support spigot 1.13
This commit is contained in:
parent
bbee2debff
commit
768e21d1b5
@ -73,11 +73,12 @@ public class NbtFactory {
|
|||||||
ClassLoader loader = NbtFactory.class.getClassLoader();
|
ClassLoader loader = NbtFactory.class.getClassLoader();
|
||||||
|
|
||||||
String packageName = getPackageName();
|
String packageName = getPackageName();
|
||||||
|
String craftpackageName = getCraftPackageName();
|
||||||
Class<?> offlinePlayer = loader.loadClass(packageName + ".CraftOfflinePlayer");
|
Class<?> offlinePlayer = loader.loadClass(packageName + ".CraftOfflinePlayer");
|
||||||
|
|
||||||
// Prepare NBT
|
// Prepare NBT
|
||||||
this.COMPOUND_CLASS = getMethod(0, Modifier.STATIC, offlinePlayer, "getData").getReturnType();
|
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_GET_TYPE = getMethod(0, Modifier.STATIC, this.BASE_CLASS, "getTypeId");
|
||||||
this.NBT_CREATE_TAG = getMethod(Modifier.STATIC, 0, this.BASE_CLASS, "createTag", byte.class);
|
this.NBT_CREATE_TAG = getMethod(Modifier.STATIC, 0, this.BASE_CLASS, "createTag", byte.class);
|
||||||
|
|
||||||
@ -400,10 +401,15 @@ public class NbtFactory {
|
|||||||
return name;
|
return name;
|
||||||
} else {
|
} else {
|
||||||
// Fallback
|
// 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")
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, Object> getDataMap(Object handle) {
|
private Map<String, Object> getDataMap(Object handle) {
|
||||||
return (Map<String, Object>) getFieldValue(getDataField(NbtType.TAG_COMPOUND, handle), handle);
|
return (Map<String, Object>) getFieldValue(getDataField(NbtType.TAG_COMPOUND, handle), handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user