From 58c6a818ba95dafa1393144f28b4ab38bccc6edc Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Sat, 13 Dec 2014 11:56:37 -0800 Subject: [PATCH] Allowing /ClaimExplosions to override sea level protections. Except for creepers, explosions may now destroy blocks above sea level in survival worlds when they originate in a claim with /ClaimExplosions enabled. They will not destroy blocks outside of that originating claim. --- .../GriefPrevention/BlockEventHandler.java | 3 ++- .../GriefPrevention/EntityEventHandler.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index 9c57a2b..aa4d553 100644 --- a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -292,7 +292,8 @@ public class BlockEventHandler implements Listener //warn players when they place TNT above sea level, since it doesn't destroy blocks there if( GriefPrevention.instance.config_blockSurfaceOtherExplosions && block.getType() == Material.TNT && block.getWorld().getEnvironment() != Environment.NETHER && - block.getY() > GriefPrevention.instance.getSeaLevel(block.getWorld()) - 5) + block.getY() > GriefPrevention.instance.getSeaLevel(block.getWorld()) - 5 && + claim == null) { GriefPrevention.sendMessage(player, TextMode.Warn, Messages.NoTNTDamageAboveSeaLevel); } diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 3b0bf80..128cdab 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -117,6 +117,14 @@ class EntityEventHandler implements Listener //FEATURE: explosions don't destroy blocks when they explode near or above sea level in standard worlds boolean isCreeper = (explodeEvent.getEntity() != null && explodeEvent.getEntity() instanceof Creeper); + + //exception for some land claims in survival worlds, see notes below + Claim originationClaim = null; + if(!GriefPrevention.instance.creativeRulesApply(location)) + { + originationClaim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null); + } + if( location.getWorld().getEnvironment() == Environment.NORMAL && GriefPrevention.instance.claimsEnabledForWorld(location.getWorld()) && ((isCreeper && GriefPrevention.instance.config_blockSurfaceCreeperExplosions) || (!isCreeper && GriefPrevention.instance.config_blockSurfaceOtherExplosions))) { for(int i = 0; i < blocks.size(); i++) @@ -124,6 +132,9 @@ class EntityEventHandler implements Listener Block block = blocks.get(i); if(GriefPrevention.instance.config_mods_explodableIds.Contains(new MaterialInfo(block.getTypeId(), block.getData(), null))) continue; + //in survival worlds, if claim explosions are enabled for the source claim, allow non-creeper explosions to destroy blocks in and under that claim even above sea level. + if(!isCreeper && originationClaim != null && originationClaim.areExplosivesAllowed && originationClaim.contains(block.getLocation(), true, false)) continue; + if(block.getLocation().getBlockY() > GriefPrevention.instance.getSeaLevel(location.getWorld()) - 7) { blocks.remove(i--);