From 3366d3c9b9a9833e21312d437670fd1df54b69c1 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Fri, 27 Apr 2018 17:43:30 +0200 Subject: [PATCH] Fix liquid portal protections --- .../global/GlobalProtectionListener.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtectionListener.java b/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtectionListener.java index 415c6e05..1e4e91a4 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtectionListener.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/global/GlobalProtectionListener.java @@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.player.DPermission; import io.github.dre2n.dungeonsxl.util.LegacyUtil; import io.github.dre2n.dungeonsxl.world.DEditWorld; import java.util.List; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; @@ -33,9 +34,11 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPortalEvent; @@ -86,6 +89,23 @@ public class GlobalProtectionListener implements Listener { } } + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void onBlockPlace(BlockPlaceEvent event) { + if (DPortal.getByBlock(event.getBlock()) != null) { + event.setCancelled(true); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void onPlayerBucketFill(PlayerBucketFillEvent event) { + Block block = event.getBlockClicked(); + if (DPortal.getByBlock(block) != null) { + event.setCancelled(true); + // Workaround for a bug of Bukkit + event.getPlayer().sendBlockChange(block.getLocation(), block.getType(), (byte) 0); + } + } + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onBlockSpread(BlockSpreadEvent event) { if (DPortal.getByBlock(event.getBlock()) != null) {