From f64ac8e3acbf4f7175058b17024ed18ad217306e Mon Sep 17 00:00:00 2001 From: tr7zw Date: Fri, 13 Dec 2019 19:27:04 +0100 Subject: [PATCH] 1.15 update, 2.2.1 --- item-nbt-api/pom.xml | 2 +- .../java/de/tr7zw/changeme/nbtapi/NBTIntegerList.java | 7 +++++-- .../java/de/tr7zw/changeme/nbtapi/NBTStringList.java | 7 +++++-- .../de/tr7zw/changeme/nbtapi/utils/ApiMetricsLite.java | 2 +- .../tr7zw/changeme/nbtapi/utils/MinecraftVersion.java | 3 ++- .../nbtapi/utils/nmsmappings/ReflectionMethod.java | 10 ++++++---- item-nbt-plugin/pom.xml | 6 +++--- nbt-injector/pom.xml | 4 ++-- pom.xml | 2 +- 9 files changed, 26 insertions(+), 17 deletions(-) diff --git a/item-nbt-api/pom.xml b/item-nbt-api/pom.xml index c340563ef..3a18976df 100644 --- a/item-nbt-api/pom.xml +++ b/item-nbt-api/pom.xml @@ -7,7 +7,7 @@ de.tr7zw item-nbt-parent - 2.1.1-SNAPSHOT + 2.1.1 item-nbt-api diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTIntegerList.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTIntegerList.java index 566c3b03c..ede90ae55 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTIntegerList.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTIntegerList.java @@ -1,5 +1,6 @@ package de.tr7zw.changeme.nbtapi; +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import de.tr7zw.changeme.nbtapi.utils.nmsmappings.ClassWrapper; @@ -20,10 +21,12 @@ protected NBTIntegerList(NBTCompound owner, String name, NBTType type, Object li @Override protected Object asTag(Integer object) { try { - return ClassWrapper.NMS_NBTTAGINT.getClazz().getConstructor(int.class).newInstance(object); + Constructor con = ClassWrapper.NMS_NBTTAGINT.getClazz().getDeclaredConstructor(int.class); + con.setAccessible(true); + return con.newInstance(object); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - throw new NbtApiException("Error while wrapping the Oject " + object + " to it's NMS object!", e); + throw new NbtApiException("Error while wrapping the Object " + object + " to it's NMS object!", e); } } diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTStringList.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTStringList.java index 593b83211..d0edd2a1c 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTStringList.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTStringList.java @@ -1,5 +1,6 @@ package de.tr7zw.changeme.nbtapi; +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import de.tr7zw.changeme.nbtapi.utils.nmsmappings.ClassWrapper; @@ -29,10 +30,12 @@ public String get(int index) { @Override protected Object asTag(String object) { try { - return ClassWrapper.NMS_NBTTAGSTRING.getClazz().getConstructor(String.class).newInstance(object); + Constructor con = ClassWrapper.NMS_NBTTAGSTRING.getClazz().getDeclaredConstructor(String.class); + con.setAccessible(true); + return con.newInstance(object); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - throw new NbtApiException("Error while wrapping the Oject " + object + " to it's NMS object!", e); + throw new NbtApiException("Error while wrapping the Object " + object + " to it's NMS object!", e); } } diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/ApiMetricsLite.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/ApiMetricsLite.java index 396452db8..05b1cb915 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/ApiMetricsLite.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/ApiMetricsLite.java @@ -34,7 +34,7 @@ public class ApiMetricsLite { private static final String PLUGINNAME = "ItemNBTAPI"; // DO NOT CHANGE THE NAME! else it won't link the data on bStats - private static final String PLUGINVERSION = "2.1.1-SNAPSHOT"; // In case you fork the nbt-api for internal use in your network, plugins and so on, you *may* add that to the version here. (2.x.x-Timolia or something like that?) + private static final String PLUGINVERSION = "2.1.1"; // In case you fork the nbt-api for internal use in your network, plugins and so on, you *may* add that to the version here. (2.x.x-Timolia or something like that?) // Not sure how good of an idea that is, so maybe just leave it as is ¯\_(ツ)_/¯ // The version of this bStats class diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java index 697b3c7ce..491cb577a 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/MinecraftVersion.java @@ -25,7 +25,8 @@ public enum MinecraftVersion { MC1_12_R1(1121), MC1_13_R1(1131), MC1_13_R2(1132), - MC1_14_R1(1141); + MC1_14_R1(1141), + MC1_15_R1(1151); private static MinecraftVersion version; private static Boolean hasGsonSupport; diff --git a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/ReflectionMethod.java b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/ReflectionMethod.java index cc38cd136..f030c0d3f 100644 --- a/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/ReflectionMethod.java +++ b/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/utils/nmsmappings/ReflectionMethod.java @@ -53,7 +53,7 @@ public enum ReflectionMethod { COMPOUND_REMOVE_KEY(ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), new Class[]{String.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "remove")), COMPOUND_HAS_KEY(ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), new Class[]{String.class}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "hasKey")), - COMPOUND_GET_TYPE(ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), new Class[]{String.class}, MinecraftVersion.MC1_8_R3, new Since(MinecraftVersion.MC1_8_R3, "b"), new Since(MinecraftVersion.MC1_9_R1, "d")), //FIXME: No Spigot mapping! + COMPOUND_GET_TYPE(ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), new Class[]{String.class}, MinecraftVersion.MC1_8_R3, new Since(MinecraftVersion.MC1_8_R3, "b"), new Since(MinecraftVersion.MC1_9_R1, "d"), new Since(MinecraftVersion.MC1_15_R1, "e")), //FIXME: No Spigot mapping! COMPOUND_GET_KEYS(ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), new Class[]{}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "c"), new Since(MinecraftVersion.MC1_13_R1, "getKeys")), LISTCOMPOUND_GET_KEYS(ClassWrapper.NMS_NBTTAGCOMPOUND.getClazz(), new Class[]{}, MinecraftVersion.MC1_7_R4, new Since(MinecraftVersion.MC1_7_R4, "c"), new Since(MinecraftVersion.MC1_13_R1, "getKeys")), @@ -127,7 +127,7 @@ public enum ReflectionMethod { loaded = true; methodName = targetVersion.name; }catch(NullPointerException | NoSuchMethodException | SecurityException ex){ - System.out.println("[NBTAPI] Unable to find the method '" + targetVersion.name + "' in '" + targetClass.getSimpleName() + "'"); //NOSONAR This gets loaded before the logger is loaded + System.out.println("[NBTAPI] Unable to find the method '" + targetVersion.name + "' in '" + targetClass.getSimpleName() + "' Enum: " + this); //NOSONAR This gets loaded before the logger is loaded } } @@ -143,10 +143,12 @@ public enum ReflectionMethod { * @return Value returned by the method */ public Object run(Object target, Object... args){ - try{ + if(method == null) + throw new NbtApiException("Method not loaded! '" + this + "'"); + try{ return method.invoke(target, args); }catch(Exception ex){ - throw new NbtApiException("Error while calling the method '" + methodName + "', loaded: " + loaded + ".", ex); + throw new NbtApiException("Error while calling the method '" + methodName + "', loaded: " + loaded + ", Enum: " + this, ex); } } diff --git a/item-nbt-plugin/pom.xml b/item-nbt-plugin/pom.xml index 0c0e6f085..249792948 100644 --- a/item-nbt-plugin/pom.xml +++ b/item-nbt-plugin/pom.xml @@ -4,7 +4,7 @@ de.tr7zw item-nbt-parent - 2.1.1-SNAPSHOT + 2.1.1 item-nbt-api-plugin jar @@ -12,13 +12,13 @@ de.tr7zw item-nbt-api - 2.1.1-SNAPSHOT + 2.1.1 compile de.tr7zw nbt-injector - 2.1.1-SNAPSHOT + 2.1.1 compile diff --git a/nbt-injector/pom.xml b/nbt-injector/pom.xml index 76c8cff5e..6fef1d8c4 100644 --- a/nbt-injector/pom.xml +++ b/nbt-injector/pom.xml @@ -4,7 +4,7 @@ de.tr7zw item-nbt-parent - 2.1.1-SNAPSHOT + 2.1.1 nbt-injector jar @@ -12,7 +12,7 @@ de.tr7zw item-nbt-api - 2.1.1-SNAPSHOT + 2.1.1 compile diff --git a/pom.xml b/pom.xml index f6778aed6..ad67db133 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 de.tr7zw item-nbt-parent - 2.1.1-SNAPSHOT + 2.1.1 pom item-nbt-api