diff --git a/.gitignore b/.gitignore index 8225f90..f5f43e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ Server/ +Server_1_14_4/ target/ *.log \ No newline at end of file diff --git a/pom.xml b/pom.xml index ba25772..9117f01 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ org.spigotmc spigot-api - 1.14.4-R0.1-SNAPSHOT + 1.15.2-R0.1-SNAPSHOT provided diff --git a/src/main/java/com/jamesdpeters/minecraft/chests/listeners/ChestLinkListener.java b/src/main/java/com/jamesdpeters/minecraft/chests/listeners/ChestLinkListener.java index 2b091fb..068f140 100644 --- a/src/main/java/com/jamesdpeters/minecraft/chests/listeners/ChestLinkListener.java +++ b/src/main/java/com/jamesdpeters/minecraft/chests/listeners/ChestLinkListener.java @@ -28,7 +28,6 @@ public class ChestLinkListener implements Listener { @EventHandler public void playerInteract(BlockPlaceEvent event){ - if(event.getPlayer().hasPermission(Permissions.ADD)){ if(event.getBlockPlaced().getState() instanceof Sign){ if(event.getBlockAgainst().getState() instanceof Chest) { new TempListener() { @@ -38,16 +37,20 @@ public class ChestLinkListener implements Listener { Sign sign = (Sign) signChangeEvent.getBlock().getState(); ChestLinkInfo info = Utils.getChestLinkInfo(sign, signChangeEvent.getLines(), signChangeEvent.getPlayer()); if (info != null) { - if(Utils.isValidSignPosition(event.getBlockAgainst().getLocation())) { - Config.addChest(info.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation()); - Messages.CHEST_ADDED(event.getPlayer(), info.getGroup(), event.getPlayer().getDisplayName()); - setLine(sign, signChangeEvent, 0, ChatColor.RED + ChatColor.stripColor(signChangeEvent.getLine(0))); - setLine(sign, signChangeEvent, 1, ChatColor.GREEN + ChatColor.stripColor(signChangeEvent.getLine(1))); - setLine(sign, signChangeEvent, 2, ChatColor.BOLD + ChatColor.stripColor(event.getPlayer().getDisplayName())); - sign.getPersistentDataContainer().set(Values.playerUUID, PersistentDataType.STRING, event.getPlayer().getUniqueId().toString()); - sign.update(); + if(event.getPlayer().hasPermission(Permissions.ADD)) { + if (Utils.isValidSignPosition(event.getBlockAgainst().getLocation())) { + Config.addChest(info.getPlayer(), info.getGroup(), event.getBlockAgainst().getLocation()); + Messages.CHEST_ADDED(event.getPlayer(), info.getGroup(), event.getPlayer().getDisplayName()); + setLine(sign, signChangeEvent, 0, ChatColor.RED + ChatColor.stripColor(signChangeEvent.getLine(0))); + setLine(sign, signChangeEvent, 1, ChatColor.GREEN + ChatColor.stripColor(signChangeEvent.getLine(1))); + setLine(sign, signChangeEvent, 2, ChatColor.BOLD + ChatColor.stripColor(event.getPlayer().getDisplayName())); + sign.getPersistentDataContainer().set(Values.playerUUID, PersistentDataType.STRING, event.getPlayer().getUniqueId().toString()); + sign.update(); + } else { + Messages.SIGN_FRONT_OF_CHEST(event.getPlayer()); + } } else { - Messages.SIGN_FRONT_OF_CHEST(event.getPlayer()); + Messages.NO_PERMISSION(event.getPlayer()); } } done(); @@ -58,9 +61,7 @@ public class ChestLinkListener implements Listener { } } - } else { - Messages.NO_PERMISSION(event.getPlayer()); - } + } diff --git a/src/main/java/com/jamesdpeters/minecraft/chests/listeners/InventoryListener.java b/src/main/java/com/jamesdpeters/minecraft/chests/listeners/InventoryListener.java index 19fb698..424856c 100644 --- a/src/main/java/com/jamesdpeters/minecraft/chests/listeners/InventoryListener.java +++ b/src/main/java/com/jamesdpeters/minecraft/chests/listeners/InventoryListener.java @@ -6,6 +6,7 @@ import com.jamesdpeters.minecraft.chests.Permissions; import com.jamesdpeters.minecraft.chests.Utils; import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder; import com.jamesdpeters.minecraft.chests.serialize.InventoryStorage; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -23,13 +24,14 @@ public class InventoryListener implements Listener { } } - @EventHandler + @EventHandler (priority = EventPriority.LOWEST) public void onInventoryOpen(InventoryOpenEvent event){ try { if (event.getPlayer() instanceof Player) { if (event.getInventory().getLocation() != null) { InventoryStorage storage = Config.getInventoryStorage(event.getInventory().getLocation()); if (storage != null) { + event.setCancelled(true); if (event.getPlayer().hasPermission(Permissions.OPEN) && storage.hasPermission((Player) event.getPlayer())) { Utils.openInventory((Player) event.getPlayer(), storage.getInventory()); @@ -45,11 +47,11 @@ public class InventoryListener implements Listener { @EventHandler public void onInventoryClose(InventoryCloseEvent event){ try { - if (event.getInventory().getLocation() == null) { - Utils.closeInventorySound((Player) event.getPlayer(), event.getInventory()); - } if (event.getInventory().getHolder() instanceof VirtualInventoryHolder) { Config.save(); + if (event.getInventory().getLocation() == null) { + Utils.closeInventorySound((Player) event.getPlayer(), event.getInventory()); + } } } catch (NullPointerException ignore){} //Essentials does something weird with enderchests - shit fix but works :) } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8cad28e..7edec27 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: ChestsPlusPlus -version: 1.14.4-v1 +version: 1.15.2-v1 main: com.jamesdpeters.minecraft.chests.ChestsPlusPlus -api-version: "1.14" +api-version: "1.15" commands: chestlink: