From d1676c9727bcd42be4545e393971306f0c92336d Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 16 Jan 2020 00:01:11 +0100 Subject: [PATCH] SPIGOT-5526: Add EntityEnterBlockEvent By: BlackHole --- .../event/entity/EntityEnterBlockEvent.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java new file mode 100644 index 0000000000..d5bd804a58 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java @@ -0,0 +1,59 @@ +package org.bukkit.event.entity; + +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when an {@link Entity} enters a block and is stored in that block. + *

+ * This event is called for bees entering a bee hive. + *
+ * It is not called when a silverfish "enters" a stone block. For that listen to + * the {@link EntityChangeBlockEvent}. + */ +public class EntityEnterBlockEvent extends EntityEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private final Block block; + private boolean cancel; + + public EntityEnterBlockEvent(@NotNull final Entity entity, @NotNull final Block block) { + super(entity); + + this.block = block; + } + + /** + * Get the block the entity will enter. + * + * @return the block + */ + @NotNull + public Block getBlock() { + return block; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +}