diff --git a/build.gradle.kts b/build.gradle.kts index 17d7236..b9106ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "dev.booky" -version = "1.0.2-SNAPSHOT" +version = "1.0.3-SNAPSHOT" val plugin: Configuration by configurations.creating { isTransitive = false diff --git a/src/main/java/dev/booky/cloudprotections/listener/ProtectionListener.java b/src/main/java/dev/booky/cloudprotections/listener/ProtectionListener.java index 00039b1..7d74192 100644 --- a/src/main/java/dev/booky/cloudprotections/listener/ProtectionListener.java +++ b/src/main/java/dev/booky/cloudprotections/listener/ProtectionListener.java @@ -197,9 +197,9 @@ public void onRedstone(BlockRedstoneEvent event) { } } - private boolean onPiston(Block piston, Iterable moved) { + private boolean checkPiston(Block piston, Iterable moved) { if (this.manager.isProtected(piston, ProtectionFlag.REDSTONE, null)) { - return true; + return false; } for (Block block : moved) { @@ -207,17 +207,24 @@ private boolean onPiston(Block piston, Iterable moved) { return false; } } - return true; + + return true; // allowed } @EventHandler(ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent event) { - this.onPiston(event.getBlock(), event.getBlocks()); + boolean allowed = this.checkPiston(event.getBlock(), event.getBlocks()); + if (!allowed) { + event.setCancelled(true); + } } @EventHandler(ignoreCancelled = true) public void onPistonRetract(BlockPistonRetractEvent event) { - this.onPiston(event.getBlock(), event.getBlocks()); + boolean allowed = this.checkPiston(event.getBlock(), event.getBlocks()); + if (!allowed) { + event.setCancelled(true); + } } @EventHandler(ignoreCancelled = true)