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.
This commit is contained in:
ryanhamshire 2014-12-13 11:56:37 -08:00
parent 3f33679424
commit 58c6a818ba
2 changed files with 13 additions and 1 deletions

View File

@ -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 //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 && if( GriefPrevention.instance.config_blockSurfaceOtherExplosions && block.getType() == Material.TNT &&
block.getWorld().getEnvironment() != Environment.NETHER && 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); GriefPrevention.sendMessage(player, TextMode.Warn, Messages.NoTNTDamageAboveSeaLevel);
} }

View File

@ -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 //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); 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))) 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++) for(int i = 0; i < blocks.size(); i++)
@ -124,6 +132,9 @@ class EntityEventHandler implements Listener
Block block = blocks.get(i); Block block = blocks.get(i);
if(GriefPrevention.instance.config_mods_explodableIds.Contains(new MaterialInfo(block.getTypeId(), block.getData(), null))) continue; 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) if(block.getLocation().getBlockY() > GriefPrevention.instance.getSeaLevel(location.getWorld()) - 7)
{ {
blocks.remove(i--); blocks.remove(i--);