From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:26:34 -0400 Subject: [PATCH] Entity AddTo/RemoveFrom World Events diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..982a0abd9a90fcb99f8d7c60a89021a5b1bb8264 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java @@ -0,0 +1,41 @@ +package com.destroystokyo.paper.event.entity; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.jetbrains.annotations.NotNull; + +/** + * Fired any time an entity is being added to the world for any reason (including a chunk loading). + * + * Not to be confused with {@link org.bukkit.event.entity.CreatureSpawnEvent} + */ +public class EntityAddToWorldEvent extends EntityEvent { + @NotNull private final World world; + + public EntityAddToWorldEvent(@NotNull Entity entity, @NotNull World world) { + super(entity); + this.world = world; + } + + /** + * @return The world that the entity is being added to + */ + @NotNull + public World getWorld() { + return world; + } + + private static final HandlerList handlers = new HandlerList(); + + @NotNull + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..b58e2e7b8707c6221773b8f023f58a4eb9c7d4b9 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java @@ -0,0 +1,40 @@ +package com.destroystokyo.paper.event.entity; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.jetbrains.annotations.NotNull; + +/** + * Fired any time an entity is being removed from a world for any reason (including a chunk unloading). + * Note: The entity is updated prior to this event being called, as such, the entity's world may not be equal to {@link #getWorld()}. + */ +public class EntityRemoveFromWorldEvent extends EntityEvent { + @NotNull private final World world; + + public EntityRemoveFromWorldEvent(@NotNull Entity entity, @NotNull World world) { + super(entity); + this.world = world; + } + + /** + * @return The world that the entity is being removed from + */ + @NotNull + public World getWorld() { + return world; + } + + private static final HandlerList handlers = new HandlerList(); + + @NotNull + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +}