diff --git a/src/main/java/pw/kaboom/extras/commands/CommandDestroyEntities.java b/src/main/java/pw/kaboom/extras/commands/CommandDestroyEntities.java index ca112a6..22f1c92 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandDestroyEntities.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandDestroyEntities.java @@ -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())) { - entity.remove(); - entityCount++; + try { + entity.remove(); + entityCount++; + } catch (Exception ignored) { + // Broken entity + continue; + } } } worldCount++; diff --git a/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java b/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java index f8e5d39..6e85fe0 100644 --- a/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java +++ b/src/main/java/pw/kaboom/extras/modules/entity/EntitySpawn.java @@ -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())) { - entity.remove(); + try { + entity.remove(); + } catch (Exception ignored) { + // Broken entity + continue; + } } } return true;