config to prevent ravagers from breaking blocks in claims

Defaults to true to remain consistent with behavior of preventing
enderman from taking blocks and entities from trampling crops

Closes #530

Also intellij is insistent on replacing tabs
This commit is contained in:
RoboMWM 2019-07-29 21:48:33 -07:00
parent 99a676a6d1
commit cdeac80635
2 changed files with 94 additions and 82 deletions

View File

@ -144,29 +144,37 @@ public class EntityEventHandler implements Listener
else if(!GriefPrevention.instance.config_rabbitsEatCrops && event.getEntityType() == EntityType.RABBIT) else if(!GriefPrevention.instance.config_rabbitsEatCrops && event.getEntityType() == EntityType.RABBIT)
{ {
event.setCancelled(true); event.setCancelled(true);
} else if(event.getEntityType() == EntityType.WITHER && GriefPrevention.instance.config_claims_worldModes.get(event.getBlock().getWorld()) != ClaimsMode.Disabled) }
else if(GriefPrevention.instance.config_claims_worldModes.get(event.getBlock().getWorld()) != ClaimsMode.Disabled)
{
if (event.getEntityType() == EntityType.WITHER)
{ {
Claim claim = this.dataStore.getClaimAt(event.getBlock().getLocation(), false, null); Claim claim = this.dataStore.getClaimAt(event.getBlock().getLocation(), false, null);
if(claim == null || !claim.areExplosivesAllowed || !GriefPrevention.instance.config_blockClaimExplosions) if (claim == null || !claim.areExplosivesAllowed || !GriefPrevention.instance.config_blockClaimExplosions)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
} }
//don't allow crops to be trampled, except by a player with build permission else if (!GriefPrevention.instance.config_claims_ravagersBreakBlocks && event.getEntityType() == EntityType.RAVAGER)
else if(event.getTo() == Material.DIRT && event.getBlock().getType() == Material.FARMLAND)
{
if(event.getEntityType() != EntityType.PLAYER)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
else
//don't allow crops to be trampled, except by a player with build permission
else if (event.getTo() == Material.DIRT && event.getBlock().getType() == Material.FARMLAND)
{ {
Player player = (Player)event.getEntity(); if (event.getEntityType() != EntityType.PLAYER)
Block block = event.getBlock();
if(GriefPrevention.instance.allowBreak(player, block, block.getLocation()) != null)
{ {
event.setCancelled(true); event.setCancelled(true);
} else
{
Player player = (Player) event.getEntity();
Block block = event.getBlock();
if (GriefPrevention.instance.allowBreak(player, block, block.getLocation()) != null)
{
event.setCancelled(true);
}
} }
} }
} }
@ -229,6 +237,7 @@ public class EntityEventHandler implements Listener
} }
} }
} }
}
//Used by "sand cannon" fix to ignore fallingblocks that fell through End Portals //Used by "sand cannon" fix to ignore fallingblocks that fell through End Portals
//This is largely due to a CB issue with the above event //This is largely due to a CB issue with the above event

View File

@ -187,6 +187,7 @@ public class GriefPrevention extends JavaPlugin
public boolean config_smartBan; //whether to ban accounts which very likely owned by a banned player public boolean config_smartBan; //whether to ban accounts which very likely owned by a banned player
public boolean config_endermenMoveBlocks; //whether or not endermen may move blocks around public boolean config_endermenMoveBlocks; //whether or not endermen may move blocks around
public boolean config_claims_ravagersBreakBlocks; //whether or not ravagers may break blocks in claims
public boolean config_silverfishBreakBlocks; //whether silverfish may break blocks public boolean config_silverfishBreakBlocks; //whether silverfish may break blocks
public boolean config_creaturesTrampleCrops; //whether or not non-player entities may trample crops public boolean config_creaturesTrampleCrops; //whether or not non-player entities may trample crops
public boolean config_rabbitsEatCrops; //whether or not rabbits may eat crops public boolean config_rabbitsEatCrops; //whether or not rabbits may eat crops
@ -583,6 +584,7 @@ public class GriefPrevention extends JavaPlugin
String accessTrustSlashCommands = config.getString("GriefPrevention.Claims.CommandsRequiringAccessTrust", "/sethome"); String accessTrustSlashCommands = config.getString("GriefPrevention.Claims.CommandsRequiringAccessTrust", "/sethome");
this.config_claims_supplyPlayerManual = config.getBoolean("GriefPrevention.Claims.DeliverManuals", true); this.config_claims_supplyPlayerManual = config.getBoolean("GriefPrevention.Claims.DeliverManuals", true);
this.config_claims_manualDeliveryDelaySeconds = config.getInt("GriefPrevention.Claims.ManualDeliveryDelaySeconds", 30); this.config_claims_manualDeliveryDelaySeconds = config.getInt("GriefPrevention.Claims.ManualDeliveryDelaySeconds", 30);
this.config_claims_ravagersBreakBlocks = config.getBoolean("GriefPrevention.Claims.RavagersBreakBlocks", true);
this.config_claims_firespreads = config.getBoolean("GriefPrevention.Claims.FireSpreadsInClaims", false); this.config_claims_firespreads = config.getBoolean("GriefPrevention.Claims.FireSpreadsInClaims", false);
this.config_claims_firedamages = config.getBoolean("GriefPrevention.Claims.FireDamagesInClaims", false); this.config_claims_firedamages = config.getBoolean("GriefPrevention.Claims.FireDamagesInClaims", false);
@ -834,6 +836,7 @@ public class GriefPrevention extends JavaPlugin
outConfig.set("GriefPrevention.Claims.CommandsRequiringAccessTrust", accessTrustSlashCommands); outConfig.set("GriefPrevention.Claims.CommandsRequiringAccessTrust", accessTrustSlashCommands);
outConfig.set("GriefPrevention.Claims.DeliverManuals", config_claims_supplyPlayerManual); outConfig.set("GriefPrevention.Claims.DeliverManuals", config_claims_supplyPlayerManual);
outConfig.set("GriefPrevention.Claims.ManualDeliveryDelaySeconds", config_claims_manualDeliveryDelaySeconds); outConfig.set("GriefPrevention.Claims.ManualDeliveryDelaySeconds", config_claims_manualDeliveryDelaySeconds);
outConfig.set("GriefPrevention.Claims.RavagersBreakBlocks", config_claims_ravagersBreakBlocks);
outConfig.set("GriefPrevention.Claims.FireSpreadsInClaims", config_claims_firespreads); outConfig.set("GriefPrevention.Claims.FireSpreadsInClaims", config_claims_firespreads);
outConfig.set("GriefPrevention.Claims.FireDamagesInClaims", config_claims_firedamages); outConfig.set("GriefPrevention.Claims.FireDamagesInClaims", config_claims_firedamages);