From e5ca8597dab380c49fecc928bfbb5591b6e1cec5 Mon Sep 17 00:00:00 2001 From: Marcus Rokatis <39190460+CommandDan@users.noreply.github.com> Date: Sat, 16 Jul 2022 14:49:40 +0200 Subject: [PATCH 1/3] Allow pistons to break blocks at borders Pistons are now able to break blocks when pushing against a plot border or plot area border --- .../com/plotsquared/bukkit/listener/BlockEventListener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 198710578..3bc9297b6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -69,6 +69,7 @@ import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import org.bukkit.block.PistonMoveReaction; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Entity; import org.bukkit.entity.Fireball; @@ -828,6 +829,7 @@ public class BlockEventListener implements Listener { } for (Block block1 : event.getBlocks()) { Location bloc = BukkitUtil.adapt(block1.getLocation()); + if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; if (bloc.isPlotArea() || bloc .add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()) .isPlotArea()) { @@ -850,6 +852,7 @@ public class BlockEventListener implements Listener { for (Block block1 : event.getBlocks()) { Location bloc = BukkitUtil.adapt(block1.getLocation()); Location newLoc = bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); + if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(newLoc)) { event.setCancelled(true); return; From fcc70364235be0abc99c9c3229ec79b17f0c1847 Mon Sep 17 00:00:00 2001 From: Marcus Rokatis <39190460+CommandDan@users.noreply.github.com> Date: Sun, 17 Jul 2022 08:22:06 +0200 Subject: [PATCH 2/3] Do not break blocks on the border Only break if the pushed block is within plot or outside plot area --- .../bukkit/listener/BlockEventListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 3bc9297b6..f5dfcd963 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -829,10 +829,10 @@ public class BlockEventListener implements Listener { } for (Block block1 : event.getBlocks()) { Location bloc = BukkitUtil.adapt(block1.getLocation()); - if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; + //if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; if (bloc.isPlotArea() || bloc .add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()) - .isPlotArea()) { + .isPlotArea() && block1.getPistonMoveReaction() != PistonMoveReaction.BREAK) { event.setCancelled(true); return; } @@ -852,12 +852,12 @@ public class BlockEventListener implements Listener { for (Block block1 : event.getBlocks()) { Location bloc = BukkitUtil.adapt(block1.getLocation()); Location newLoc = bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); - if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; - if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(newLoc)) { + //if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; + if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(newLoc) && block1.getPistonMoveReaction() != PistonMoveReaction.BREAK) { event.setCancelled(true); return; } - if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(newLoc))) { + if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(newLoc)) && block1.getPistonMoveReaction() != PistonMoveReaction.BREAK) { event.setCancelled(true); return; } From cd6e63a1ec7fd8c168c952be827773ba02c06103 Mon Sep 17 00:00:00 2001 From: Marcus Rokatis <39190460+CommandDan@users.noreply.github.com> Date: Sun, 17 Jul 2022 08:24:26 +0200 Subject: [PATCH 3/3] Remove comments --- .../com/plotsquared/bukkit/listener/BlockEventListener.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index f5dfcd963..9d21c52e7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -829,7 +829,6 @@ public class BlockEventListener implements Listener { } for (Block block1 : event.getBlocks()) { Location bloc = BukkitUtil.adapt(block1.getLocation()); - //if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; if (bloc.isPlotArea() || bloc .add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()) .isPlotArea() && block1.getPistonMoveReaction() != PistonMoveReaction.BREAK) { @@ -852,7 +851,6 @@ public class BlockEventListener implements Listener { for (Block block1 : event.getBlocks()) { Location bloc = BukkitUtil.adapt(block1.getLocation()); Location newLoc = bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); - //if (block1.getPistonMoveReaction() == PistonMoveReaction.BREAK) return; if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(newLoc) && block1.getPistonMoveReaction() != PistonMoveReaction.BREAK) { event.setCancelled(true); return;