mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-27 09:55:36 -05:00
Check entity count on chunk load
This commit is contained in:
parent
aadc92ce7a
commit
3d1581d5b4
1 changed files with 13 additions and 0 deletions
|
@ -25,6 +25,8 @@ import org.bukkit.event.entity.EntitySpawnEvent;
|
|||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.destroystokyo.paper.event.block.TNTPrimeEvent;
|
||||
|
@ -34,6 +36,17 @@ import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
|
|||
import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent;
|
||||
|
||||
class EntitySpawn implements Listener {
|
||||
@EventHandler
|
||||
void onChunkLoad(ChunkLoadEvent event) {
|
||||
final int count = event.getChunk().getEntities().length;
|
||||
|
||||
if (count > 50) {
|
||||
for (int i = 51; i <= count; i++) {
|
||||
event.getChunk().getEntities()[i].remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (event.getSpawnReason() == SpawnReason.CUSTOM ||
|
||||
|
|
Loading…
Reference in a new issue