+ * Check out https://bStats.org/ to learn more about bStats!
+ *
+ * This class is modified by tr7zw to work when the api is shaded into other peoples plugins.
+ */
+public class ApiMetricsLite {
+
+ private static final String PLUGINNAME = "ItemNBTAPI"; // DO NOT CHANGE THE NAME! else it won't link the data on bStats
+
+ // The version of this bStats class
+ public static final int B_STATS_VERSION = 1;
+
+ // The version of the NBT-Api bStats
+ public static final int NBT_BSTATS_VERSION = 1;
+
+ // The url to which the data is sent
+ private static final String URL = "https://bStats.org/submitData/bukkit";
+
+ // Is bStats enabled on this server?
+ private boolean enabled;
+
+ // Should failed requests be logged?
+ private static boolean logFailedRequests;
+
+ // Should the sent data be logged?
+ private static boolean logSentData;
+
+ // Should the response text be logged?
+ private static boolean logResponseStatusText;
+
+ // The uuid of the server
+ private static String serverUUID;
+
+ // The plugin
+ private Plugin plugin;
+
+ /**
+ * Class constructor.
+ *
+ */
+ public ApiMetricsLite() {
+
+ // The register method just uses any enabled plugin it can find to register. This *shouldn't* cause any problems, since the plugin isn't used any other way.
+ // Register our service
+ for(Plugin plug : Bukkit.getPluginManager().getPlugins()) {
+ plugin = plug;
+ if(plugin != null)
+ break;
+ }
+ if(plugin == null) {
+ return;// Didn't find any plugin that could work
+ }
+
+ // Get the config file
+ File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
+ File configFile = new File(bStatsFolder, "config.yml");
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
+
+ // Check if the config file exists
+ if (!config.isSet("serverUuid")) {
+
+ // Add default values
+ config.addDefault("enabled", true);
+ // Every server gets it's unique random id.
+ config.addDefault("serverUuid", UUID.randomUUID().toString());
+ // Should failed request be logged?
+ config.addDefault("logFailedRequests", false);
+ // Should the sent data be logged?
+ config.addDefault("logSentData", false);
+ // Should the response text be logged?
+ config.addDefault("logResponseStatusText", false);
+
+ // Inform the server owners about bStats
+ config.options().header(
+ "bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
+ "To honor their work, you should not disable it.\n" +
+ "This has nearly no effect on the server performance!\n" +
+ "Check out https://bStats.org/ to learn more :)"
+ ).copyDefaults(true);
+ try {
+ config.save(configFile);
+ } catch (IOException ignored) { }
+ }
+
+ // Load the data
+ serverUUID = config.getString("serverUuid");
+ logFailedRequests = config.getBoolean("logFailedRequests", false);
+ enabled = config.getBoolean("enabled", true);
+ logSentData = config.getBoolean("logSentData", false);
+ logResponseStatusText = config.getBoolean("logResponseStatusText", false);
+ if (enabled) {
+ boolean found = false;
+ // Search for all other bStats Metrics classes to see if we are the first one
+ for (Class> service : Bukkit.getServicesManager().getKnownServices()) {
+ try {
+ service.getField("NBT_BSTATS_VERSION"); // Create only one instance of the nbt-api bstats.
+ return;
+ } catch (NoSuchFieldException ignored) { }
+ try {
+ service.getField("B_STATS_VERSION"); // Our identifier :)
+ found = true; // We aren't the first
+ break;
+ } catch (NoSuchFieldException ignored) { }
+ }
+ boolean fFound = found;
+ // Register our service
+ if(Bukkit.isPrimaryThread()){
+ Bukkit.getServicesManager().register(ApiMetricsLite.class, this, plugin, ServicePriority.Normal);
+ if (!fFound) {
+ getLogger().info("[NBTAPI] Using the plugin '" + plugin.getName() + "' to create a bStats instance!");
+ // We are the first!
+ startSubmitting();
+ }
+ }else{
+ Bukkit.getScheduler().runTask(plugin, () -> {
+ Bukkit.getServicesManager().register(ApiMetricsLite.class, this, plugin, ServicePriority.Normal);
+ if (!fFound) {
+ getLogger().info("[NBTAPI] Using the plugin '" + plugin.getName() + "' to create a bStats instance!");
+ // We are the first!
+ startSubmitting();
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Checks if bStats is enabled.
+ *
+ * @return Whether bStats is enabled or not.
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Starts the Scheduler which submits our data every 30 minutes.
+ */
+ private void startSubmitting() {
+ final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ if (!plugin.isEnabled()) { // Plugin was disabled
+ timer.cancel();
+ return;
+ }
+ // Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
+ // Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
+ Bukkit.getScheduler().runTask(plugin, () -> submitData());
+ }
+ }, 1000l * 60l * 5l, 1000l * 60l * 30l);
+ // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
+ // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
+ // WARNING: Just don't do it!
+ }
+
+ /**
+ * Gets the plugin specific data.
+ * This method is called using Reflection.
+ *
+ * @return The plugin specific data.
+ */
+ public JsonObject getPluginData() {
+ JsonObject data = new JsonObject();
+
+ data.addProperty("pluginName", PLUGINNAME); // Append the name of the plugin
+ data.addProperty("pluginVersion", MinecraftVersion.VERSION); // Append the version of the plugin
+ data.add("customCharts", new JsonArray());
+
+ return data;
+ }
+
+ /**
+ * Gets the server specific data.
+ *
+ * @return The server specific data.
+ */
+ private JsonObject getServerData() {
+ // Minecraft specific data
+ int playerAmount;
+ try {
+ // Around MC 1.8 the return type was changed to a collection from an array,
+ // This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
+ Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
+ playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
+ ? ((Collection>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
+ : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
+ } catch (Exception e) {
+ playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
+ }
+ int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
+ String bukkitVersion = Bukkit.getVersion();
+ String bukkitName = Bukkit.getName();
+
+ // OS/Java specific data
+ String javaVersion = System.getProperty("java.version");
+ String osName = System.getProperty("os.name");
+ String osArch = System.getProperty("os.arch");
+ String osVersion = System.getProperty("os.version");
+ int coreCount = Runtime.getRuntime().availableProcessors();
+
+ JsonObject data = new JsonObject();
+
+ data.addProperty("serverUUID", serverUUID);
+
+ data.addProperty("playerAmount", playerAmount);
+ data.addProperty("onlineMode", onlineMode);
+ data.addProperty("bukkitVersion", bukkitVersion);
+ data.addProperty("bukkitName", bukkitName);
+
+ data.addProperty("javaVersion", javaVersion);
+ data.addProperty("osName", osName);
+ data.addProperty("osArch", osArch);
+ data.addProperty("osVersion", osVersion);
+ data.addProperty("coreCount", coreCount);
+
+ return data;
+ }
+
+ /**
+ * Collects the data and sends it afterwards.
+ */
+ private void submitData() {
+ final JsonObject data = getServerData();
+
+ JsonArray pluginData = new JsonArray();
+ // Search for all other bStats Metrics classes to get their plugin data
+ for (Class> service : Bukkit.getServicesManager().getKnownServices()) {
+ try {
+ service.getField("B_STATS_VERSION"); // Our identifier :)
+
+ for (RegisteredServiceProvider> provider : Bukkit.getServicesManager().getRegistrations(service)) {
+ try {
+ Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
+ if (plugin instanceof JsonObject) {
+ pluginData.add((JsonObject) plugin);
+ } else { // old bstats version compatibility
+ try {
+ Class> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
+ if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
+ Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
+ jsonStringGetter.setAccessible(true);
+ String jsonString = (String) jsonStringGetter.invoke(plugin);
+ JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
+ pluginData.add(object);
+ }
+ } catch (ClassNotFoundException e) {
+ // minecraft version 1.14+
+ if (logFailedRequests) {
+ getLogger().log(Level.WARNING, "[NBTAPI][BSTATS] Encountered exception while posting request!", e);
+ // Not using the plugins logger since the plugin isn't the plugin containing the NBT-Api most of the time
+ //this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception ", e);
+ }
+ continue; // continue looping since we cannot do any other thing.
+ }
+ }
+ } catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
+ }
+ }
+ } catch (NoSuchFieldException ignored) { }
+ }
+
+ data.add("plugins", pluginData);
+
+ // Create a new thread for the connection to the bStats server
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ // Send the data
+ sendData(plugin, data);
+ } catch (Exception e) {
+ // Something went wrong! :(
+ if (logFailedRequests) {
+ getLogger().log(Level.WARNING, "[NBTAPI][BSTATS] Could not submit plugin stats of " + plugin.getName(), e);
+ // Not using the plugins logger since the plugin isn't the plugin containing the NBT-Api most of the time
+ //plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
+ }
+ }
+ }
+ }).start();
+ }
+
+ /**
+ * Sends the data to the bStats server.
+ *
+ * @param plugin Any plugin. It's just used to get a logger instance.
+ * @param data The data to send.
+ * @throws Exception If the request failed.
+ */
+ private static void sendData(Plugin plugin, JsonObject data) throws Exception {
+ if (data == null) {
+ throw new IllegalArgumentException("Data cannot be null!");
+ }
+ if (Bukkit.isPrimaryThread()) {
+ throw new IllegalAccessException("This method must not be called from the main thread!");
+ }
+ if (logSentData) {
+ getLogger().info("[NBTAPI][BSTATS] Sending data to bStats: " + data.toString());
+ // Not using the plugins logger since the plugin isn't the plugin containing the NBT-Api most of the time
+ //plugin.getLogger().info("Sending data to bStats: " + data.toString());
+ }
+ HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
+
+ // Compress the data to save bandwidth
+ byte[] compressedData = compress(data.toString());
+
+ // Add headers
+ connection.setRequestMethod("POST");
+ connection.addRequestProperty("Accept", "application/json");
+ connection.addRequestProperty("Connection", "close");
+ connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
+ connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
+ connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
+ connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
+
+ // Send data
+ connection.setDoOutput(true);
+ DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
+ outputStream.write(compressedData);
+ outputStream.flush();
+ outputStream.close();
+
+ InputStream inputStream = connection.getInputStream();
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+
+ StringBuilder builder = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ builder.append(line);
+ }
+ bufferedReader.close();
+ if (logResponseStatusText) {
+ getLogger().info("[NBTAPI][BSTATS] Sent data to bStats and received response: " + builder.toString());
+ // Not using the plugins logger since the plugin isn't the plugin containing the NBT-Api most of the time
+ //plugin.getLogger().info("Sent data to bStats and received response: " + builder.toString());
+ }
+ }
+
+ /**
+ * Gzips the given String.
+ *
+ * @param str The string to gzip.
+ * @return The gzipped String.
+ * @throws IOException If the compression failed.
+ */
+ private static byte[] compress(final String str) throws IOException {
+ if (str == null) {
+ return new byte[0];
+ }
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
+ gzip.write(str.getBytes(StandardCharsets.UTF_8));
+ gzip.close();
+ return outputStream.toByteArray();
+ }
+
+}
diff --git a/src/com/pretzel/dev/villagertradelimiter/nms/utils/MinecraftVersion.java b/src/com/pretzel/dev/villagertradelimiter/nms/utils/MinecraftVersion.java
index aceec7a..693444b 100644
--- a/src/com/pretzel/dev/villagertradelimiter/nms/utils/MinecraftVersion.java
+++ b/src/com/pretzel/dev/villagertradelimiter/nms/utils/MinecraftVersion.java
@@ -9,7 +9,7 @@ import org.bukkit.Bukkit;
* This class acts as the "Brain" of the NBTApi. It contains the main logger for
* other classes,registers bStats and checks rather Maven shading was done
* correctly.
- *
+ *
* @author tr7zw
*
*/
@@ -17,7 +17,7 @@ import org.bukkit.Bukkit;
public enum MinecraftVersion {
UNKNOWN(Integer.MAX_VALUE), // Use the newest known mappings
MC1_7_R4(174), MC1_8_R3(183), MC1_9_R1(191), MC1_9_R2(192), MC1_10_R1(1101), MC1_11_R1(1111), MC1_12_R1(1121),
- MC1_13_R1(1131), MC1_13_R2(1132), MC1_14_R1(1141), MC1_15_R1(1151), MC1_16_R1(1161), MC1_16_R2(1162), MC1_16_R3(1163), MC1_17_R1(1171), MC1_18_R1(1181, true);
+ MC1_13_R1(1131), MC1_13_R2(1132), MC1_14_R1(1141), MC1_15_R1(1151), MC1_16_R1(1161), MC1_16_R2(1162), MC1_16_R3(1163), MC1_17_R1(1171), MC1_18_R1(1181, true), MC1_18_R2(1182, true);
private static MinecraftVersion version;
private static Boolean hasGsonSupport;
@@ -30,15 +30,15 @@ public enum MinecraftVersion {
private static Logger logger = Logger.getLogger("NBTAPI");
// NBT-API Version
- protected static final String VERSION = "2.9.0-SNAPSHOT";
+ protected static final String VERSION = "2.9.2";
private final int versionId;
private final boolean mojangMapping;
- MinecraftVersion(int versionId) {
- this(versionId, false);
- }
-
+ MinecraftVersion(int versionId) {
+ this(versionId, false);
+ }
+
MinecraftVersion(int versionId, boolean mojangMapping) {
this.versionId = versionId;
this.mojangMapping = mojangMapping;
@@ -55,29 +55,34 @@ public enum MinecraftVersion {
* @return True if method names are in Mojang format and need to be remapped internally
*/
public boolean isMojangMapping() {
- return mojangMapping;
- }
-
- public String getPackageName() {
- if(this == UNKNOWN) {
- return values()[values().length-1].name().replace("MC", "v");
- }
- return this.name().replace("MC", "v");
+ return mojangMapping;
}
- /**
+ /**
+ * This method is required to hot-wire the plugin during mappings generation for newer mc versions thanks to md_5 not used mojmap.
+ *
+ * @return
+ */
+ public String getPackageName() {
+ if(this == UNKNOWN) {
+ return Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
+ }
+ return this.name().replace("MC", "v");
+ }
+
+ /**
* Returns true if the current versions is at least the given Version
- *
+ *
* @param version The minimum version
* @return
*/
public static boolean isAtLeastVersion(MinecraftVersion version) {
return getVersion().getVersionId() >= version.getVersionId();
}
-
+
/**
* Returns true if the current versions newer (not equal) than the given version
- *
+ *
* @param version The minimum version
* @return
*/
@@ -88,7 +93,7 @@ public enum MinecraftVersion {
/**
* Getter for this servers MinecraftVersion. Also init's bStats and checks the
* shading.
- *
+ *
* @return The enum for the MinecraftVersion this server is running
*/
public static MinecraftVersion getVersion() {
@@ -105,19 +110,26 @@ public enum MinecraftVersion {
if (version != UNKNOWN) {
logger.info("[NBTAPI] NMS support '" + version.name() + "' loaded!");
} else {
- logger.warning("[NBTAPI] Wasn't able to find NMS Support! Some functions may not work!");
+ logger.warning("[NBTAPI] This Server-Version(" + ver + ") is not supported by this NBT-API Version(" + VERSION + ") located at " + MinecraftVersion.class.getName() + ". The NBT-API will try to work as good as it can! Some functions may not work!");
}
init();
return version;
}
private static void init() {
+ try {
+ if (hasGsonSupport() && !bStatsDisabled)
+ new ApiMetricsLite();
+ } catch (Exception ex) {
+ logger.log(Level.WARNING, "[NBTAPI] Error enabling Metrics!", ex);
+ }
+
if (hasGsonSupport() && !updateCheckDisabled)
new Thread(() -> {
try {
VersionChecker.checkForUpdates();
} catch (Exception ex) {
- logger.log(Level.WARNING, "[NBTAPI] Error while checking for updates!", ex);
+ logger.log(Level.WARNING, "[NBTAPI] Error while checking for updates! Error: " + ex.getMessage());
}
}).start();
// Maven's Relocate is clever and changes strings, too. So we have to use this
@@ -182,17 +194,17 @@ public enum MinecraftVersion {
public static void disablePackageWarning() {
disablePackageWarning = true;
}
-
+
/**
* @return Logger used by the NBT-API
*/
public static Logger getLogger() {
return logger;
}
-
+
/**
* Replaces the NBT-API logger with a custom implementation.
- *
+ *
* @param logger The new logger(can not be null!)
*/
public static void replaceLogger(Logger logger) {
@@ -200,4 +212,4 @@ public enum MinecraftVersion {
MinecraftVersion.logger = logger;
}
-}
+}
\ No newline at end of file
diff --git a/src/com/pretzel/dev/villagertradelimiter/nms/utils/UUIDUtil.java b/src/com/pretzel/dev/villagertradelimiter/nms/utils/UUIDUtil.java
new file mode 100644
index 0000000..a0ac39e
--- /dev/null
+++ b/src/com/pretzel/dev/villagertradelimiter/nms/utils/UUIDUtil.java
@@ -0,0 +1,22 @@
+package com.pretzel.dev.villagertradelimiter.nms.utils;
+
+import java.util.UUID;
+
+public class UUIDUtil {
+
+ public static UUID uuidFromIntArray(int[] is) {
+ return new UUID((long) is[0] << 32 | (long) is[1] & 4294967295L,
+ (long) is[2] << 32 | (long) is[3] & 4294967295L);
+ }
+
+ public static int[] uuidToIntArray(UUID uUID) {
+ long l = uUID.getMostSignificantBits();
+ long m = uUID.getLeastSignificantBits();
+ return leastMostToIntArray(l, m);
+ }
+
+ private static int[] leastMostToIntArray(long l, long m) {
+ return new int[]{(int) (l >> 32), (int) l, (int) (m >> 32), (int) m};
+ }
+
+}
diff --git a/src/com/pretzel/dev/villagertradelimiter/nms/utils/VersionChecker.java b/src/com/pretzel/dev/villagertradelimiter/nms/utils/VersionChecker.java
index 67f40dd..954c210 100644
--- a/src/com/pretzel/dev/villagertradelimiter/nms/utils/VersionChecker.java
+++ b/src/com/pretzel/dev/villagertradelimiter/nms/utils/VersionChecker.java
@@ -10,7 +10,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-
import com.pretzel.dev.villagertradelimiter.nms.NBTItem;
/**
@@ -21,12 +20,13 @@ public class VersionChecker {
private static final String USER_AGENT = "nbt-api Version check";
private static final String REQUEST_URL = "https://api.spiget.org/v2/resources/7939/versions?size=100";
+ public static boolean hideOk = false;
protected static void checkForUpdates() throws Exception {
URL url = new URL(REQUEST_URL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.addRequestProperty("User-Agent", USER_AGENT);// Set
- // User-Agent
+ // User-Agent
// If you're not sure if the request will be successful,
// you need to check the response code and use #getErrorStream if it
@@ -43,18 +43,19 @@ public class VersionChecker {
int versionDifference = getVersionDifference(latest.get("name").getAsString());
if (versionDifference == -1) { // Outdated
MinecraftVersion.getLogger().log(Level.WARNING,
- "[NBTAPI] The NBT-API at '" + NBTItem.class.getPackage() + "' seems to be outdated!");
+ "[NBTAPI] The NBT-API located at '" + NBTItem.class.getPackage() + "' seems to be outdated!");
MinecraftVersion.getLogger().log(Level.WARNING, "[NBTAPI] Current Version: '" + MinecraftVersion.VERSION
+ "' Newest Version: " + latest.get("name").getAsString() + "'");
MinecraftVersion.getLogger().log(Level.WARNING,
- "[NBTAPI] Please update the nbt-api or the plugin that contains the api!");
+ "[NBTAPI] Please update the NBTAPI or the plugin that contains the api(nag the mod author when the newest release has an old version, not the NBTAPI dev)!");
} else if (versionDifference == 0) {
- MinecraftVersion.getLogger().log(Level.INFO, "[NBTAPI] The NBT-API seems to be up-to-date!");
+ if(!hideOk)
+ MinecraftVersion.getLogger().log(Level.INFO, "[NBTAPI] The NBT-API seems to be up-to-date!");
} else if (versionDifference == 1) {
- MinecraftVersion.getLogger().log(Level.WARNING, "[NBTAPI] The NBT-API at '" + NBTItem.class.getPackage()
- + "' seems to be a future Version, not yet released on Spigot/CurseForge!");
- MinecraftVersion.getLogger().log(Level.WARNING, "[NBTAPI] Current Version: '" + MinecraftVersion.VERSION
+ MinecraftVersion.getLogger().log(Level.INFO, "[NBTAPI] The NBT-API at '" + NBTItem.class.getPackage()
+ + "' seems to be a future Version, not yet released on Spigot/CurseForge! This is not an error!");
+ MinecraftVersion.getLogger().log(Level.INFO, "[NBTAPI] Current Version: '" + MinecraftVersion.VERSION
+ "' Newest Version: " + latest.get("name").getAsString() + "'");
}
} else {
@@ -97,7 +98,7 @@ public class VersionChecker {
return 1;
if (!relPatch.contains("-") && curPatch.contains("-"))
return -1; // Release has no - but we do = We use a Snapshot of the
- // release
+ // release
if (relPatch.contains("-") && curPatch.contains("-"))
return 0; // Release and cur are Snapshots/alpha/beta
return 1;
diff --git a/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/ClassWrapper.java b/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/ClassWrapper.java
index e6f9f85..21a3b03 100644
--- a/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/ClassWrapper.java
+++ b/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/ClassWrapper.java
@@ -8,7 +8,7 @@ import com.pretzel.dev.villagertradelimiter.nms.utils.MinecraftVersion;
/**
* Wraps NMS and CRAFT classes
- *
+ *
* @author tr7zw
*
*/
@@ -23,6 +23,7 @@ public enum ClassWrapper {
NMS_NBTBASE(PackageWrapper.NMS, "NBTBase", null, null, "net.minecraft.nbt", "net.minecraft.nbt.Tag"),
NMS_NBTTAGSTRING(PackageWrapper.NMS, "NBTTagString", null, null, "net.minecraft.nbt", "net.minecraft.nbt.StringTag"),
NMS_NBTTAGINT(PackageWrapper.NMS, "NBTTagInt", null, null, "net.minecraft.nbt", "net.minecraft.nbt.IntTag"),
+ NMS_NBTTAGINTARRAY(PackageWrapper.NMS, "NBTTagIntArray", null, null, "net.minecraft.nbt", "net.minecraft.nbt.IntArrayTag"),
NMS_NBTTAGFLOAT(PackageWrapper.NMS, "NBTTagFloat", null, null, "net.minecraft.nbt", "net.minecraft.nbt.FloatTag"),
NMS_NBTTAGDOUBLE(PackageWrapper.NMS, "NBTTagDouble", null, null, "net.minecraft.nbt", "net.minecraft.nbt.DoubleTag"),
NMS_NBTTAGLONG(PackageWrapper.NMS, "NBTTagLong", null, null, "net.minecraft.nbt", "net.minecraft.nbt.LongTag"),
@@ -56,7 +57,7 @@ public enum ClassWrapper {
}
ClassWrapper(PackageWrapper packageId, String clazzName, MinecraftVersion from, MinecraftVersion to,
- String mojangMap, String mojangName) {
+ String mojangMap, String mojangName) {
this.mojangName = mojangName;
if (from != null && MinecraftVersion.getVersion().getVersionId() < from.getVersionId()) {
return;
diff --git a/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/MojangToMapping.java b/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/MojangToMapping.java
index 115b8aa..d55d92e 100644
--- a/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/MojangToMapping.java
+++ b/src/com/pretzel/dev/villagertradelimiter/nms/utils/nmsmappings/MojangToMapping.java
@@ -3,9 +3,12 @@ package com.pretzel.dev.villagertradelimiter.nms.utils.nmsmappings;
import java.util.HashMap;
import java.util.Map;
+import com.pretzel.dev.villagertradelimiter.nms.utils.MinecraftVersion;
+import com.pretzel.dev.villagertradelimiter.nms.NbtApiException;
+
/**
* Temporary solution to hold Mojang to unmapped Spigot mappings.
- *
+ *
* @author tr7zw
*
*/
@@ -13,7 +16,7 @@ public class MojangToMapping {
@SuppressWarnings("serial")
private static Map