From e3ef78f8f843f26b21ed8d441509a1c5afa9aa97 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Sun, 23 May 2021 14:44:38 +0200 Subject: [PATCH] Protect lilypads --- .../factions/engine/EnginePermBuild.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/massivecraft/factions/engine/EnginePermBuild.java b/src/com/massivecraft/factions/engine/EnginePermBuild.java index 25f75988..76e79f13 100644 --- a/src/com/massivecraft/factions/engine/EnginePermBuild.java +++ b/src/com/massivecraft/factions/engine/EnginePermBuild.java @@ -31,6 +31,7 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.SignChangeEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; @@ -147,6 +148,18 @@ public class EnginePermBuild extends Engine @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void build(HangingBreakByEntityEvent event) { build(event.getRemover(), event.getEntity().getLocation().getBlock(), event); } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void build(EntityChangeBlockEvent event) + { + // Handling lilypads being broken by boats + Entity entity = event.getEntity(); + if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) return; + Entity player = entity.getPassengers().stream().filter(MUtil::isPlayer).findAny().orElse(entity); + + build(player, event.getBlock(), event); + } + + // -------------------------------------------- // // USE > ITEM // -------------------------------------------- //