From e4a666f8beb4b96e9be1a408f61be6d52e22058e Mon Sep 17 00:00:00 2001 From: Frank van der Heijden <22407829+FrankHeijden@users.noreply.github.com> Date: Sun, 11 Oct 2020 20:59:17 -0700 Subject: [PATCH] Make sound of piston explosions toggleable (#996) --- .../me/ryanhamshire/GriefPrevention/BlockEventHandler.java | 7 +++++-- .../me/ryanhamshire/GriefPrevention/GriefPrevention.java | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index 9415f9d..5d1e0a2 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -664,7 +664,10 @@ public class BlockEventHandler implements Listener if (pistonClaim == null || !Objects.equals(pistonClaim.ownerID, claim.ownerID)) { event.setCancelled(true); - pistonBlock.getWorld().createExplosion(pistonBlock.getLocation(), 0); + if (GriefPrevention.instance.config_pistonExplosionSound) + { + pistonBlock.getWorld().createExplosion(pistonBlock.getLocation(), 0); + } pistonBlock.getWorld().dropItem(pistonBlock.getLocation(), new ItemStack(event.isSticky() ? Material.STICKY_PISTON : Material.PISTON)); pistonBlock.setType(Material.AIR); return; @@ -1029,7 +1032,7 @@ public class BlockEventHandler implements Listener } } } - + @EventHandler(ignoreCancelled = true) public void onItemFrameBrokenByBoat(final HangingBreakEvent event) { diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index a6d354d..211e795 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -209,6 +209,7 @@ public class GriefPrevention extends JavaPlugin public boolean config_limitTreeGrowth; //whether trees should be prevented from growing into a claim from outside public PistonMode config_pistonMovement; //Setting for piston check options + public boolean config_pistonExplosionSound; //whether pistons make an explosion sound when they get removed public boolean config_advanced_fixNegativeClaimblockAmounts; //whether to attempt to fix negative claim block amounts (some addons cause/assume players can go into negative amounts) public int config_advanced_claim_expiration_check_rate; //How often GP should check for expired claims, amount in seconds @@ -594,6 +595,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_pistonExplosionSound = config.getBoolean("GriefPrevention.PistonExplosionSound", true); this.config_pistonMovement = PistonMode.of(config.getString("GriefPrevention.PistonMovement", "CLAIMS_ONLY")); if (config.isBoolean("GriefPrevention.LimitPistonsToLandClaims") && !config.getBoolean("GriefPrevention.LimitPistonsToLandClaims")) this.config_pistonMovement = PistonMode.EVERYWHERE_SIMPLE; @@ -852,6 +854,7 @@ public class GriefPrevention extends JavaPlugin outConfig.set("GriefPrevention.PistonMovement", this.config_pistonMovement.name()); outConfig.set("GriefPrevention.CheckPistonMovement", null); outConfig.set("GriefPrevention.LimitPistonsToLandClaims", null); + outConfig.set("GriefPrevention.PistonExplosionSound", this.config_pistonExplosionSound); outConfig.set("GriefPrevention.FireSpreads", this.config_fireSpreads); outConfig.set("GriefPrevention.FireDestroys", this.config_fireDestroys);