From ea3306d0709d8caf747184cdae79de1d99c6c417 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sun, 31 Jul 2016 20:17:35 -0400 Subject: [PATCH] Fix #1034 --- .../com/plotsquared/bukkit/listeners/PlayerEvents.java | 8 ++++---- .../plotsquared/bukkit/object/entity/EntityWrapper.java | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index b28e1eb6b..cf47f39a6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -699,7 +699,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (this.lastRadius != 0) { List nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius); for (Entity near : nearby) { - if (near instanceof TNTPrimed || near.getType() == EntityType.MINECART_TNT) { + if (near instanceof TNTPrimed || near.getType().equals(EntityType.MINECART_TNT)) { if (!near.hasMetadata("plot")) { near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot)); } @@ -952,12 +952,12 @@ public class PlayerEvents extends PlotListener implements Listener { } List blocks = event.getBlocks(); for (Block b : blocks) { - Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative)); - if (!area.contains(bloc.getX(), bloc.getZ())) { + Location bloc = BukkitUtil.getLocation(b.getLocation()); + if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) { event.setCancelled(true); return; } - if (!plot.equals(area.getOwnedPlot(bloc))) { + if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) { event.setCancelled(true); return; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java index f8c3590e6..22c0230a9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java @@ -366,7 +366,11 @@ public class EntityWrapper { } private void restoreInventory(InventoryHolder entity) { - entity.getInventory().setContents(this.inventory); + try { + entity.getInventory().setContents(this.inventory); + } catch (IllegalArgumentException e) { + PS.debug("&c[WARN] Failed to restore inventory.\n Reason: " + e.getMessage()); + } } public void storeLiving(LivingEntity lived) {