From edf2e3aed4f5434edd70550f46516274dcfef720 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 6 Aug 2018 17:24:25 +0800 Subject: [PATCH] V3.0.1 Fix worldguard compatibility issue --- .../St3venAU/plugins/ArmorStandTools/ArmorStandGUI.java | 2 +- .../gmail/St3venAU/plugins/ArmorStandTools/Config.java | 5 ++++- src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java | 8 ++++---- .../St3venAU/plugins/ArmorStandTools/MainListener.java | 5 +++-- src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandGUI.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandGUI.java index 2857a4b..b183f4a 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandGUI.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/ArmorStandGUI.java @@ -76,7 +76,7 @@ class ArmorStandGUI implements Listener { p.openInventory(i); } - public static boolean isInUse(ArmorStand as) { + static boolean isInUse(ArmorStand as) { return inUse.contains(as.getEntityId()); } diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Config.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Config.java index 7323ff3..85ac201 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Config.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Config.java @@ -152,11 +152,14 @@ class Config { } Plugin worldGuard = plugin.getServer().getPluginManager().getPlugin("WorldGuard"); - worldGuardPlugin = worldGuard == null || !(worldGuard instanceof WorldGuardPlugin) ? null : (WorldGuardPlugin) worldGuard; + if(worldGuard instanceof WorldGuardPlugin) { + worldGuardPlugin = (WorldGuardPlugin) worldGuard; + } if(config.getBoolean("integrateWithWorldGuard")) { plugin.getLogger().log(Level.INFO, worldGuardPlugin == null ? "WorldGuard plugin not found. Continuing without WorldGuard support." : "WorldGuard plugin found. WorldGuard support enabled."); } else if(worldGuardPlugin != null) { plugin.getLogger().log(Level.WARNING, "WorldGuard plugin was found, but integrateWithWorldGuard is set to false in config.yml. Continuing without WorldGuard support."); + worldGuardPlugin = null; } } diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java index 94469f7..54b569e 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Main.java @@ -24,8 +24,8 @@ public class Main extends JavaPlugin { static NMS nms; - public final HashMap carryingArmorStand = new HashMap(); - public final HashMap savedInventories = new HashMap(); + final HashMap carryingArmorStand = new HashMap(); + final HashMap savedInventories = new HashMap(); @Override public void onEnable() { @@ -108,7 +108,7 @@ public class Main extends JavaPlugin { } } - public void saveInventoryAndClear(Player p) { + void saveInventoryAndClear(Player p) { ItemStack[] inv = p.getInventory().getContents().clone(); savedInventories.put(p.getUniqueId(), inv); p.getInventory().clear(); @@ -174,7 +174,7 @@ public class Main extends JavaPlugin { } } if(Config.worldGuardPlugin != null) { - return Config.worldGuardPlugin.canBuild(p, b); + return Config.worldGuardPlugin.createProtectionQuery().testBlockBreak(p, b); } BlockBreakEvent breakEvent = new BlockBreakEvent(b, p); Bukkit.getServer().getPluginManager().callEvent(breakEvent); diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java index f8d7cb6..be004af 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/MainListener.java @@ -433,12 +433,13 @@ public class MainListener implements Listener { final Block b = event.getBlock(); final ArmorStand as = getArmorStand(b); if (as != null) { - String input = ""; + StringBuilder sb = new StringBuilder(); for (String line : event.getLines()) { if (line != null && line.length() > 0) { - input += ChatColor.translateAlternateColorCodes('&', line); + sb.append(ChatColor.translateAlternateColorCodes('&', line)); } } + String input = sb.toString(); if(b.hasMetadata("setName")) { if (input.length() > 0) { as.setCustomName(input); diff --git a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java index 421fef0..bfdc8b4 100644 --- a/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java +++ b/src/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java @@ -28,7 +28,7 @@ class Utils { return false; } - public static boolean hasPermissionNode(Player player, String perm) { + static boolean hasPermissionNode(Player player, String perm) { if ((player == null) || player.isOp()) { return true; }