Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void alchemistrySoul(GameStateChangeEvent event) {
- if (event.getGameStateTo().equals(GameState.ACTIVE)) {
- Game game = event.getGame();
- Map<Integer, Location> locat = event.getGame().getAlchemicsLocations();
- new BukkitRunnable() {
- @Override
- public void run() {
- if (game.getGameState().equals(GameState.ENDING)) this.cancel();
- for (Map.Entry<Integer, Location> entry : locat.entrySet()) {
- int rad = entry.getKey();
- Location loc = entry.getValue();
- Collection<Entity> nearbyEntities = loc.getWorld().getNearbyEntities(loc, rad, rad, rad);
- if (Mobs.countMobs(nearbyEntities, Skeleton.class) > 12) return;
- if (Mobs.countMobs(nearbyEntities, Player.class) != 0) {
- int randomX = Mobs.randomInRadius(rad);
- int randomZ = Mobs.randomInRadius(rad);
- if (loc.getWorld().getHighestBlockAt(randomX, randomZ) != null) {
- int y = loc.getWorld().getHighestBlockAt(randomX, randomZ).getLocation().getBlockY();
- Location spawnLoc = new Location(loc.getWorld(), randomX, y, randomZ);
- Skeleton soul = (Skeleton) spawnLoc.getWorld().spawnEntity(spawnLoc, EntityType.SKELETON);
- Mobs.soulDef(soul);
- }
- }
- }
- }
- }.runTaskTimer(plugin, 0, 240);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement