forked from kaboomserver/extras
Don't attempt to remove broken entities
This commit is contained in:
parent
9c42f5d9e9
commit
afdd1c1b4f
2 changed files with 13 additions and 3 deletions
|
@ -18,8 +18,13 @@ public final class CommandDestroyEntities implements CommandExecutor {
|
|||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (!EntityType.PLAYER.equals(entity.getType())) {
|
||||
try {
|
||||
entity.remove();
|
||||
entityCount++;
|
||||
} catch (Exception ignored) {
|
||||
// Broken entity
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
worldCount++;
|
||||
|
|
|
@ -63,7 +63,12 @@ public final class EntitySpawn implements Listener {
|
|||
if (worldEntityCount > MAX_ENTITIES_PER_WORLD) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (!EntityType.PLAYER.equals(entity.getType())) {
|
||||
try {
|
||||
entity.remove();
|
||||
} catch (Exception ignored) {
|
||||
// Broken entity
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue