diff --git a/paper-api/src/main/java/org/bukkit/Chunk.java b/paper-api/src/main/java/org/bukkit/Chunk.java index beac1439c7..40e9e375a6 100644 --- a/paper-api/src/main/java/org/bukkit/Chunk.java +++ b/paper-api/src/main/java/org/bukkit/Chunk.java @@ -71,6 +71,7 @@ public interface Chunk extends PersistentDataHolder { /** * Get a list of all entities in the chunk. + * This will force load any entities, which are not loaded. * * @return The entities. */ diff --git a/paper-api/src/main/java/org/bukkit/event/world/EntitiesLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/EntitiesLoadEvent.java new file mode 100644 index 0000000000..88b13a481e --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/world/EntitiesLoadEvent.java @@ -0,0 +1,44 @@ +package org.bukkit.event.world; + +import java.util.List; +import org.bukkit.Chunk; +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when entities are loaded. + * + * The provided chunk may or may not be loaded. + */ +public class EntitiesLoadEvent extends ChunkEvent { + + private static final HandlerList handlers = new HandlerList(); + private final List entities; + + public EntitiesLoadEvent(@NotNull Chunk chunk, @NotNull List entities) { + super(chunk); + this.entities = entities; + } + + /** + * Get the entities which are being loaded. + * + * @return unmodifiable list of loaded entities. + */ + @NotNull + public List getEntities() { + return entities; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/world/EntitiesUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/EntitiesUnloadEvent.java new file mode 100644 index 0000000000..1e3f144f1f --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/world/EntitiesUnloadEvent.java @@ -0,0 +1,44 @@ +package org.bukkit.event.world; + +import java.util.List; +import org.bukkit.Chunk; +import org.bukkit.entity.Entity; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when entities are unloaded. + * + * The provided chunk may or may not be loaded. + */ +public class EntitiesUnloadEvent extends ChunkEvent { + + private static final HandlerList handlers = new HandlerList(); + private final List entities; + + public EntitiesUnloadEvent(@NotNull Chunk chunk, @NotNull List entities) { + super(chunk); + this.entities = entities; + } + + /** + * Get the entities which are being unloaded. + * + * @return unmodifiable list of unloaded entities. + */ + @NotNull + public List getEntities() { + return entities; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +}