Protect lilypads

This commit is contained in:
Magnus Ulf 2021-05-23 14:44:38 +02:00
parent 3a83e75eb4
commit e3ef78f8f8

View File

@ -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
// -------------------------------------------- //