mirror of
https://github.com/kaboomserver/extras.git
synced 2024-12-03 20:51:06 -05:00
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 (World world : Bukkit.getWorlds()) {
|
||||||
for (Entity entity : world.getEntities()) {
|
for (Entity entity : world.getEntities()) {
|
||||||
if (!EntityType.PLAYER.equals(entity.getType())) {
|
if (!EntityType.PLAYER.equals(entity.getType())) {
|
||||||
|
try {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
entityCount++;
|
entityCount++;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Broken entity
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
worldCount++;
|
worldCount++;
|
||||||
|
|
|
@ -63,7 +63,12 @@ public final class EntitySpawn implements Listener {
|
||||||
if (worldEntityCount > MAX_ENTITIES_PER_WORLD) {
|
if (worldEntityCount > MAX_ENTITIES_PER_WORLD) {
|
||||||
for (Entity entity : world.getEntities()) {
|
for (Entity entity : world.getEntities()) {
|
||||||
if (!EntityType.PLAYER.equals(entity.getType())) {
|
if (!EntityType.PLAYER.equals(entity.getType())) {
|
||||||
|
try {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Broken entity
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue