diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java b/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java index 73106dc4b..dcf854dfa 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotInventory.java @@ -51,6 +51,9 @@ public class PlotInventory { } public PlotItemStack getItem(int index) { + if (index < 0 || index >= items.length) { + return null; + } return items[index]; } diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index 310e2e916..56f26f715 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -913,13 +913,16 @@ public class BukkitChunkManager extends ChunkManager { final int tz = pos2.getZ(); for (final Entity entity : entities) { if (entity instanceof Player) { - final Player player = (Player) entity; - final PlotPlayer pp = BukkitUtil.getPlayer(player); - Plot plot = pp.getCurrentPlot(); - if (plot != null) { - final Location plotHome = MainUtil.getDefaultHome(plot); - if (pp.getLocation().getY() <= plotHome.getY()) { - pp.teleport(plotHome); + org.bukkit.Location loc = entity.getLocation(); + if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) { + final Player player = (Player) entity; + final PlotPlayer pp = BukkitUtil.getPlayer(player); + Plot plot = pp.getCurrentPlot(); + if (plot != null) { + final Location plotHome = MainUtil.getDefaultHome(plot); + if (pp.getLocation().getY() <= plotHome.getY()) { + pp.teleport(plotHome); + } } } }