diff --git a/src/com/wasteofplastic/askyblock/SafeSpotTeleport.java b/src/com/wasteofplastic/askyblock/SafeSpotTeleport.java index 3a836bb08..f8118d993 100644 --- a/src/com/wasteofplastic/askyblock/SafeSpotTeleport.java +++ b/src/com/wasteofplastic/askyblock/SafeSpotTeleport.java @@ -155,7 +155,7 @@ public void run() { // Check for safe spot, but only if it is closer than one we have found already if (!safeSpotFound || (safeDistance > islandLoc.toVector().distanceSquared(new Vector(x,y,z)))) { // No safe spot yet, or closer distance - if (checkBlock(chunk,x,y,z)) { + if (checkBlock(chunk,x,y,z, worldHeight)) { safeChunk = chunk; safeSpotFound = true; safeSpotInChunk = new Vector(x,y,z); @@ -184,7 +184,7 @@ public void run() { } //System.out.print("DEBUG: Portal teleport loc = " + (16 * portalChunk.getX() + x) + "," + (y) + "," + (16 * portalChunk.getZ() + z)); // Now check if this is a safe location - if (checkBlock(portalChunk,x,y,z)) { + if (checkBlock(portalChunk,x,y,z, worldHeight)) { // Yes, so use this instead of the highest location //System.out.print("DEBUG: Portal is safe"); safeSpotFound = true; @@ -257,15 +257,16 @@ public void run() { * @param x * @param y * @param z + * @param worldHeight * @return */ @SuppressWarnings("deprecation") - private boolean checkBlock(ChunkSnapshot chunk, int x, int y, int z) { + private boolean checkBlock(ChunkSnapshot chunk, int x, int y, int z, int worldHeight) { int type = chunk.getBlockTypeId(x, y, z); if (type != 0) { // AIR - int space1 = chunk.getBlockTypeId(x, y + 1, z); - int space2 = chunk.getBlockTypeId(x, y + 2, z); - if ((space1 == 0 && space2 == 0) || (space1 == Material.PORTAL.getId() && space2 == Material.PORTAL.getId())) { + int space1 = chunk.getBlockTypeId(x, Math.min(y + 1, worldHeight), z); + int space2 = chunk.getBlockTypeId(x, Math.min(y + 2, worldHeight), z); + if ((space1 == 0 && space2 == 0) || (space1 == Material.PORTAL.getId() || space2 == Material.PORTAL.getId())) { // Now there is a chance that this is a safe spot // Check for safe ground Material mat = Material.getMaterial(type); diff --git a/src/com/wasteofplastic/askyblock/panels/ControlPanel.java b/src/com/wasteofplastic/askyblock/panels/ControlPanel.java index 87627b4e3..90398cfe4 100644 --- a/src/com/wasteofplastic/askyblock/panels/ControlPanel.java +++ b/src/com/wasteofplastic/askyblock/panels/ControlPanel.java @@ -216,6 +216,8 @@ public void onInventoryClick(InventoryClickEvent event) { ItemStack clicked = event.getCurrentItem(); // The item that was clicked Inventory inventory = event.getInventory(); // The inventory that was clicked in if (inventory.getName() == null) { + if (DEBUG) + plugin.getLogger().info("DEBUG: inventory name is null"); return; } // ASkyBlock plugin = ASkyBlock.getPlugin(); @@ -224,12 +226,16 @@ public void onInventoryClick(InventoryClickEvent event) { if (inventory.getName().equals(plugin.myLocale(player.getUniqueId()).challengesguiTitle)) { event.setCancelled(true); if (event.getClick().equals(ClickType.SHIFT_RIGHT)) { + if (DEBUG) + plugin.getLogger().info("DEBUG: click type shift Right"); inventory.clear(); player.closeInventory(); player.updateInventory(); return; } if (event.getSlotType() == SlotType.OUTSIDE) { + if (DEBUG) + plugin.getLogger().info("DEBUG: slot type outside"); inventory.clear(); player.closeInventory(); return; @@ -248,6 +254,8 @@ public void onInventoryClick(InventoryClickEvent event) { // plugin.getLogger().info("DEBUG: Challenges size = " + // challenges.size()); if (slot >= 0 && slot < challenges.size()) { + if (DEBUG) + plugin.getLogger().info("DEBUG: slot within challenges"); CPItem item = challenges.get(slot); // TEST /* @@ -269,12 +277,15 @@ public void onInventoryClick(InventoryClickEvent event) { }*/ // END TEST - //plugin.getLogger().info("DEBUG: CP Item is " + item.getItem().toString()); - //plugin.getLogger().info("DEBUG: Clicked is " + clicked.toString()); + if (DEBUG) { + plugin.getLogger().info("DEBUG: CP Item is " + item.getItem().toString()); + plugin.getLogger().info("DEBUG: Clicked is " + clicked.toString()); + } // Check that it is the top items that are being clicked on // These two should be identical because it is made before if (clicked.equals(item.getItem())) { - // plugin.getLogger().info("DEBUG: You clicked on a challenge item"); + if (DEBUG) + plugin.getLogger().info("DEBUG: You clicked on a challenge item"); // plugin.getLogger().info("DEBUG: performing /" + // item.getCommand()); // plugin.getLogger().info("DEBUG: going to " +