From 9c5c7523a29095d1485d5b08b9d2c10915d6c386 Mon Sep 17 00:00:00 2001 From: RoboMWM Date: Sat, 23 Dec 2017 08:28:12 -0800 Subject: [PATCH] add fallback to old id-based system for chunk snapshots --- .../GriefPrevention/AutoExtendClaimTask.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/AutoExtendClaimTask.java b/src/me/ryanhamshire/GriefPrevention/AutoExtendClaimTask.java index 4f3a31d..f6219f6 100644 --- a/src/me/ryanhamshire/GriefPrevention/AutoExtendClaimTask.java +++ b/src/me/ryanhamshire/GriefPrevention/AutoExtendClaimTask.java @@ -71,8 +71,34 @@ class AutoExtendClaimTask implements Runnable catch (NoSuchMethodError e) { GriefPrevention.instance.getLogger().severe("You are running an outdated build of Craftbukkit/Spigot/Paper. Please update."); - GriefPrevention.instance.AddLogEntry("Claim " + claim.getID() + " was auto-extended to maximum depth.", CustomLogEntryTypes.Debug, false); - return GriefPrevention.instance.config_claims_maxDepth; + for(ChunkSnapshot chunk : this.chunks) + { + Biome biome = chunk.getBiome(0, 0); + ArrayList playerBlockIDs = RestoreNatureProcessingTask.getPlayerBlocks(this.worldType, biome); + + boolean ychanged = true; + while(!this.yTooSmall(y) && ychanged) + { + ychanged = false; + for(int x = 0; x < 16; x++) + { + for(int z = 0; z < 16; z++) + { + int blockType = chunk.getBlockTypeId(x, y, z); + while(!this.yTooSmall(y) && playerBlockIDs.contains(Material.getMaterial(blockType))) + { + ychanged = true; + blockType = chunk.getBlockTypeId(x, --y, z); + } + + if(this.yTooSmall(y)) return y; + } + } + } + + if(this.yTooSmall(y)) return y; + } + }