/** Counts: - EnderDragons - EnderCrystals */ private void countEntities() { if (this.endWorld.getEnvironment() == Environment.THE_END) { this.plugin.getLogger().info("Counting existing EDs in " + this.endWorld.getName() + "..."); for (final EndChunk c : this.chunks.getSafeChunksList()) { if (this.endWorld.isChunkLoaded(c.getX(), c.getZ())) { final Chunk chunk = this.endWorld.getChunkAt(c.getX(), c.getZ()); for (final Entity e : chunk.getEntities()) { if (e.getType() == EntityType.ENDER_DRAGON) { final EnderDragon ed = (EnderDragon) e; if (!this.dragons.containsKey(ed.getUniqueId())) { ed.setMaxHealth(this.config.getEdHealth()); ed.setHealth(ed.getMaxHealth()); this.dragons.put(ed.getUniqueId(), new HashMap<String, Double>()); this.loadedDragons.add(ed.getUniqueId()); } } else if (e.getType() == EntityType.ENDER_CRYSTAL) { c.addCrystalLocation(e); } } } else { this.endWorld.loadChunk(c.getX(), c.getZ()); c.resetSavedDragons(); this.endWorld.unloadChunkRequest(c.getX(), c.getZ()); } } this.plugin .getLogger() .info("Done, " + this.getNumberOfAliveEnderDragons() + " EnderDragon(s) found."); } }