mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-30 11:17:14 -05:00
Add enderdragon limiter to PreCreatureSpawnEvent
This commit is contained in:
parent
011690f7fd
commit
eb77c8e47a
1 changed files with 14 additions and 13 deletions
|
@ -552,38 +552,39 @@ class Events implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
|
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
|
||||||
/* Entity[] chunkEntities = event.getSpawnLocation().getChunk().getEntities();
|
Entity[] chunkEntities = event.getSpawnLocation().getChunk().getEntities();
|
||||||
int onChunk = 0;
|
List<LivingEntity> worldEntities = event.getSpawnLocation().getWorld().getLivingEntities();
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
if (event.getType() == EntityType.ENDER_DRAGON) {
|
if (event.getType() == EntityType.ENDER_DRAGON) {
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
for (LivingEntity worldEntity : worldEntities) {
|
||||||
if (onChunk < 5) {
|
if (count < 25) {
|
||||||
if (chunkEntity.getType() == EntityType.ENDER_DRAGON) {
|
if (worldEntity.getType() == EntityType.ENDER_DRAGON) {
|
||||||
onChunk++;
|
count++;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onChunk == 5) {
|
if (count == 25) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (event.getType() != EntityType.PLAYER) {
|
} else if (event.getType() != EntityType.PLAYER) {
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
for (Entity chunkEntity : chunkEntities) {
|
||||||
if (onChunk < 50) {
|
if (count < 50) {
|
||||||
if (chunkEntity.getType() != EntityType.PLAYER) {
|
if (chunkEntity.getType() != EntityType.PLAYER) {
|
||||||
onChunk++;
|
count++;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onChunk == 50) {
|
if (count == 50) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
Loading…
Reference in a new issue