From abfbeffbb0755fc59abbec22a2519511b33fe7bc Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 23 Sep 2017 15:09:03 +1000 Subject: [PATCH] Skip y=255, block when finding a free spot --- .../main/java/com/plotsquared/bukkit/util/BukkitUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index 14fc9e2fe..a515cdfd6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -173,12 +173,14 @@ public class BukkitUtil extends WorldUtil { public int getHighestBlock(String world, int x, int z) { World bukkitWorld = getWorld(world); // Skip top and bottom block - for (int y = bukkitWorld.getMaxHeight() - 2; y > 0; y--) { + int air = 1; + for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) { Block block = bukkitWorld.getBlockAt(x, y, z); if (block != null) { Material type = block.getType(); if (type.isSolid()) { - return y + 1; + if (air > 1) return y + 1; + air = 0; } else { switch (type) { case WATER: @@ -187,6 +189,7 @@ public class BukkitUtil extends WorldUtil { case STATIONARY_WATER: return y; } + air++; } } }