From 85205e9b6fcae98d2d88c3facc1192de07fc3a4a Mon Sep 17 00:00:00 2001 From: Bobcat00 Date: Sun, 15 Dec 2019 18:15:50 -0500 Subject: [PATCH] Add config option to ignore piston movements (#671) --- .../ryanhamshire/GriefPrevention/BlockEventHandler.java | 8 +++++++- .../me/ryanhamshire/GriefPrevention/GriefPrevention.java | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index ea7d156..4234772 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -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 diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 595f865..fde7224 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -203,6 +203,7 @@ public class GriefPrevention extends JavaPlugin public HashMap 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);