Add config option to ignore piston movements (#671)

This commit is contained in:
Bobcat00 2019-12-15 18:15:50 -05:00 committed by RoboMWM
parent 9048811454
commit 85205e9b6f
2 changed files with 10 additions and 1 deletions

View File

@ -461,6 +461,9 @@ public class BlockEventHandler implements Listener
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockPistonExtend (BlockPistonExtendEvent event)
{
//return if piston checks are not enabled
if(!GriefPrevention.instance.config_checkPistonMovement) return;
//pushing down is ALWAYS safe
if(event.getDirection() == BlockFace.DOWN) return;
@ -583,7 +586,10 @@ public class BlockEventHandler implements Listener
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockPistonRetract (BlockPistonRetractEvent event)
{
//pulling up is always safe
//return if piston checks are not enabled
if(!GriefPrevention.instance.config_checkPistonMovement) return;
//pulling up is always safe
if(event.getDirection() == BlockFace.UP) return;
try

View File

@ -203,6 +203,7 @@ public class GriefPrevention extends JavaPlugin
public HashMap<String, Integer> config_seaLevelOverride; //override for sea level, because bukkit doesn't report the right value for all situations
public boolean config_limitTreeGrowth; //whether trees should be prevented from growing into a claim from outside
public boolean config_checkPistonMovement; //whether to check piston movement
public boolean config_pistonsInClaimsOnly; //whether pistons are limited to only move blocks located within the piston's land claim
public boolean config_advanced_fixNegativeClaimblockAmounts; //whether to attempt to fix negative claim block amounts (some addons cause/assume players can go into negative amounts)
@ -622,6 +623,7 @@ public class GriefPrevention extends JavaPlugin
this.config_blockSurfaceOtherExplosions = config.getBoolean("GriefPrevention.BlockSurfaceOtherExplosions", true);
this.config_blockSkyTrees = config.getBoolean("GriefPrevention.LimitSkyTrees", true);
this.config_limitTreeGrowth = config.getBoolean("GriefPrevention.LimitTreeGrowth", false);
this.config_checkPistonMovement = config.getBoolean("GriefPrevention.CheckPistonMovement", true);
this.config_pistonsInClaimsOnly = config.getBoolean("GriefPrevention.LimitPistonsToLandClaims", true);
this.config_fireSpreads = config.getBoolean("GriefPrevention.FireSpreads", false);
@ -887,6 +889,7 @@ public class GriefPrevention extends JavaPlugin
outConfig.set("GriefPrevention.BlockSurfaceOtherExplosions", this.config_blockSurfaceOtherExplosions);
outConfig.set("GriefPrevention.LimitSkyTrees", this.config_blockSkyTrees);
outConfig.set("GriefPrevention.LimitTreeGrowth", this.config_limitTreeGrowth);
outConfig.set("GriefPrevention.CheckPistonMovement", this.config_checkPistonMovement);
outConfig.set("GriefPrevention.LimitPistonsToLandClaims", this.config_pistonsInClaimsOnly);
outConfig.set("GriefPrevention.FireSpreads", this.config_fireSpreads);