diff --git a/README.md b/README.md index 4d3ca8c..276c948 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ I wanted to create an armor stand for each kit in my mini-game, and I quickly be Compatibility ------------- -- Armor Stand Tools v3.0.0 - Spigot/CraftBukkit 1.13 only +- Armor Stand Tools v3.0.2 - Spigot/CraftBukkit 1.13 only - Armor Stand Tools v2.4.3 - Spigot/CraftBukkit 1.8, 1.9, 1.10, 1.11, 1.12 Features diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java index 54b569e..6865bbe 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java @@ -79,7 +79,7 @@ public class Main extends JavaPlugin { getLogger().warning("Support for " + nmsVersion + " not found, trying " + usingVersion + ". Please check for possible updates to the plugin."); } try { - nms = (NMS) Class.forName("com.gmail.St3venAU.plugins.ArmorStandTools.NMS_" + usingVersion).getConstructor(String.class).newInstance(nmsVersion); + nms = (NMS) Class.forName("com.gmail.St3venAU.plugins.ArmorStandTools.NMS_" + usingVersion).getConstructor(Main.class, String.class).newInstance(this, nmsVersion); } catch (Exception e) { e.printStackTrace(); getLogger().warning("An error occurred while attempting to load support for this version of Craftbukkit/Spigot. Loading plugin failed."); diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS.java index 98e8a4d..716adeb 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS.java @@ -11,17 +11,21 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.scheduler.BukkitRunnable; import java.lang.reflect.Field; import java.util.Map; abstract class NMS { + private Main plugin; + private final String nmsVersion, disabledSlotsFieldName; - NMS(String nmsVersion, String disabledSlotsFieldName) { + NMS(Main plugin, String nmsVersion, String disabledSlotsFieldName) { + this.plugin = plugin; this.nmsVersion = nmsVersion; this.disabledSlotsFieldName = disabledSlotsFieldName; } @@ -39,16 +43,21 @@ abstract class NMS { } } - void openSign(Player p, Block b) { - try { - Object world = b.getWorld().getClass().getMethod("getHandle").invoke(b.getWorld()); - Object blockPos = getNMSClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(b.getX(), b.getY(), b.getZ()); - Object sign = world.getClass().getMethod("getTileEntity", getNMSClass("BlockPosition")).invoke(world, blockPos); - Object player = p.getClass().getMethod("getHandle").invoke(p); - player.getClass().getMethod("openSign", getNMSClass("TileEntitySign")).invoke(player, sign); - } catch (Exception e) { - e.printStackTrace(); - } + void openSign(final Player p, final Block b) { + new BukkitRunnable() { + @Override + public void run() { + try { + Object world = b.getWorld().getClass().getMethod("getHandle").invoke(b.getWorld()); + Object blockPos = getNMSClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(b.getX(), b.getY(), b.getZ()); + Object sign = world.getClass().getMethod("getTileEntity", getNMSClass("BlockPosition")).invoke(world, blockPos); + Object player = p.getClass().getMethod("getHandle").invoke(p); + player.getClass().getMethod("openSign", getNMSClass("TileEntitySign")).invoke(player, sign); + } catch (Exception e) { + e.printStackTrace(); + } + } + }.runTaskLater(plugin, 2L); } boolean toggleSlotsDisabled(ArmorStand as) { @@ -102,7 +111,7 @@ abstract class NMS { if(is == null) { return ""; } - StringBuilder tags = new StringBuilder(""); + StringBuilder tags = new StringBuilder(); if(is.getItemMeta() != null && is.getItemMeta() instanceof LeatherArmorMeta) { LeatherArmorMeta armorMeta = (LeatherArmorMeta) is.getItemMeta(); tags.append("display:{color:"); diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS_v1_13_R1.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS_v1_13_R1.java index 2edc394..00d7e2e 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS_v1_13_R1.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/NMS_v1_13_R1.java @@ -3,10 +3,11 @@ package com.gmail.St3venAU.plugins.ArmorStandTools; @SuppressWarnings("unused") class NMS_v1_13_R1 extends NMS { - public NMS_v1_13_R1(String nmsVersion) { + public NMS_v1_13_R1(Main plugin, String nmsVersion) { super( - nmsVersion, // NMS Version - "bH" // Disabled slots field name + plugin, + nmsVersion, + "bH" ); } diff --git a/src/config.yml b/src/config.yml index 8842d4c..682c513 100644 --- a/src/config.yml +++ b/src/config.yml @@ -4,7 +4,7 @@ # # Main Config # -# File generated by: v3.0.0 +# File generated by: v3.0.2 # (If this is not the version you are running, consider deleting this # config to allow it to be re-created. There may be new config options) # diff --git a/src/language.yml b/src/language.yml index 445bb2e..2e6e973 100644 --- a/src/language.yml +++ b/src/language.yml @@ -4,7 +4,7 @@ # # Language Config # -# File generated by: v3.0.0 +# File generated by: v3.0.2 # (If this is not the version you are running, consider deleting this # config to allow it to be re-created. There may be new config options) # diff --git a/src/plugin.yml b/src/plugin.yml index e6e1b4e..b0c143b 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ main: com.gmail.St3venAU.plugins.ArmorStandTools.Main name: ArmorStandTools -version: 3.0.0 +version: 3.0.2 api-version: 1.13 author: St3venAU description: Armor stand manipulation tools