mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 02:22:12 +01:00
SPIGOT-6547: Chunk#getEntities() doesn't return all entities immediately after chunk load
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
parent
5f7735a971
commit
891608deca
3 changed files with 89 additions and 0 deletions
|
@ -71,6 +71,7 @@ public interface Chunk extends PersistentDataHolder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all entities in the chunk.
|
* Get a list of all entities in the chunk.
|
||||||
|
* This will force load any entities, which are not loaded.
|
||||||
*
|
*
|
||||||
* @return The entities.
|
* @return The entities.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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<Entity> entities;
|
||||||
|
|
||||||
|
public EntitiesLoadEvent(@NotNull Chunk chunk, @NotNull List<Entity> entities) {
|
||||||
|
super(chunk);
|
||||||
|
this.entities = entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the entities which are being loaded.
|
||||||
|
*
|
||||||
|
* @return unmodifiable list of loaded entities.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public List<Entity> getEntities() {
|
||||||
|
return entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Entity> entities;
|
||||||
|
|
||||||
|
public EntitiesUnloadEvent(@NotNull Chunk chunk, @NotNull List<Entity> entities) {
|
||||||
|
super(chunk);
|
||||||
|
this.entities = entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the entities which are being unloaded.
|
||||||
|
*
|
||||||
|
* @return unmodifiable list of unloaded entities.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public List<Entity> getEntities() {
|
||||||
|
return entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue