mirror of
https://github.com/kaboomserver/extras.git
synced 2024-06-01 01:41:22 +00:00
Logic improvements
This commit is contained in:
parent
38265afa49
commit
90059ddab4
|
@ -48,6 +48,7 @@ import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.MagmaCube;
|
import org.bukkit.entity.MagmaCube;
|
||||||
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Slime;
|
import org.bukkit.entity.Slime;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -441,7 +442,6 @@ class Events implements Listener {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Entity[] chunkEntities = entity.getLocation().getChunk().getEntities();
|
Entity[] chunkEntities = entity.getLocation().getChunk().getEntities();
|
||||||
double tps = Bukkit.getServer().getTPS()[0];
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
for (Entity chunkEntity : chunkEntities) {
|
||||||
|
@ -450,11 +450,13 @@ class Events implements Listener {
|
||||||
count++;
|
count++;
|
||||||
} else {
|
} else {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double tps = Bukkit.getServer().getTPS()[0];
|
||||||
|
|
||||||
if (tps < 14 && entity.getType() == EntityType.PRIMED_TNT) {
|
if (tps < 14 && entity.getType() == EntityType.PRIMED_TNT) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
|
@ -487,33 +489,6 @@ class Events implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onEntitySpawn(EntitySpawnEvent event) {
|
void onEntitySpawn(EntitySpawnEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Entity[] chunkEntities = event.getLocation().getChunk().getEntities();
|
|
||||||
List<LivingEntity> worldEntities = event.getLocation().getWorld().getLivingEntities();
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
if (entity.getType() == EntityType.ENDER_DRAGON) {
|
|
||||||
for (LivingEntity worldEntity : worldEntities) {
|
|
||||||
if (worldEntity.getType() == EntityType.ENDER_DRAGON) {
|
|
||||||
if (count < 25) {
|
|
||||||
count++;
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (entity.getType() != EntityType.PLAYER) {
|
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
|
||||||
if (chunkEntity.getType() != EntityType.PLAYER) {
|
|
||||||
if (count < 50) {
|
|
||||||
count++;
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
LivingEntity mob = (LivingEntity) entity;
|
LivingEntity mob = (LivingEntity) entity;
|
||||||
|
@ -549,17 +524,53 @@ class Events implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getType() == EntityType.MAGMA_CUBE) {
|
if (entity.getType() != EntityType.PLAYER) {
|
||||||
MagmaCube magmacube = (MagmaCube) entity;
|
int count = 0;
|
||||||
if (magmacube.getSize() > 100) {
|
Entity[] chunkEntities = event.getLocation().getChunk().getEntities();
|
||||||
magmacube.setSize(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.getType() == EntityType.SLIME) {
|
for (Entity chunkEntity : chunkEntities) {
|
||||||
Slime slime = (Slime) entity;
|
if (chunkEntity.getType() != EntityType.PLAYER) {
|
||||||
if (slime.getSize() > 100) {
|
if (count < 50) {
|
||||||
slime.setSize(100);
|
count++;
|
||||||
|
} else {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.getType() == EntityType.ENDER_DRAGON) {
|
||||||
|
List<LivingEntity> worldEntities = event.getLocation().getWorld().getLivingEntities();
|
||||||
|
|
||||||
|
for (LivingEntity worldEntity : worldEntities) {
|
||||||
|
if (worldEntity.getType() == EntityType.ENDER_DRAGON) {
|
||||||
|
if (count < 25) {
|
||||||
|
count++;
|
||||||
|
} else {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.getType() == EntityType.MAGMA_CUBE) {
|
||||||
|
MagmaCube magmacube = (MagmaCube) entity;
|
||||||
|
if (magmacube.getSize() > 100) {
|
||||||
|
magmacube.setSize(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.getType() == EntityType.MINECART_MOB_SPAWNER) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.getType() == EntityType.SLIME) {
|
||||||
|
Slime slime = (Slime) entity;
|
||||||
|
if (slime.getSize() > 100) {
|
||||||
|
slime.setSize(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -674,7 +685,7 @@ class Events implements Listener {
|
||||||
if (coordBlock.getType().isTransparent() &&
|
if (coordBlock.getType().isTransparent() &&
|
||||||
coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) {
|
coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) {
|
||||||
player.teleport(yLoc);
|
player.teleport(yLoc);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -771,32 +782,41 @@ class Events implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
|
void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
|
||||||
Entity[] chunkEntities = event.getSpawnLocation().getChunk().getEntities();
|
|
||||||
List<LivingEntity> worldEntities = event.getSpawnLocation().getWorld().getLivingEntities();
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (event.getType() == EntityType.ENDER_DRAGON) {
|
if (event.getType() != EntityType.PLAYER) {
|
||||||
for (LivingEntity worldEntity : worldEntities) {
|
Entity[] chunkEntities = event.getSpawnLocation().getChunk().getEntities();
|
||||||
if (worldEntity.getType() == EntityType.ENDER_DRAGON) {
|
|
||||||
if (count < 25) {
|
|
||||||
count++;
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (event.getType() != EntityType.PLAYER) {
|
|
||||||
for (Entity chunkEntity : chunkEntities) {
|
for (Entity chunkEntity : chunkEntities) {
|
||||||
if (chunkEntity.getType() != EntityType.PLAYER) {
|
if (chunkEntity.getType() != EntityType.PLAYER) {
|
||||||
if (count < 50) {
|
if (count < 50) {
|
||||||
count++;
|
count++;
|
||||||
} else {
|
} else {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getType() == EntityType.ENDER_DRAGON) {
|
||||||
|
List<LivingEntity> worldEntities = event.getSpawnLocation().getWorld().getLivingEntities();
|
||||||
|
|
||||||
|
for (LivingEntity worldEntity : worldEntities) {
|
||||||
|
if (worldEntity.getType() == EntityType.ENDER_DRAGON) {
|
||||||
|
if (count < 25) {
|
||||||
|
count++;
|
||||||
|
} else {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getType() == EntityType.MINECART_MOB_SPAWNER) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,9 +875,13 @@ class Events implements Listener {
|
||||||
void onSpawnerSpawn(SpawnerSpawnEvent event) {
|
void onSpawnerSpawn(SpawnerSpawnEvent event) {
|
||||||
CreatureSpawner spawner = event.getSpawner();
|
CreatureSpawner spawner = event.getSpawner();
|
||||||
|
|
||||||
if (spawner.getSpawnCount() > 200) {
|
try {
|
||||||
spawner.setSpawnCount(200);
|
if (spawner.getSpawnCount() > 200) {
|
||||||
spawner.update();
|
spawner.setSpawnCount(200);
|
||||||
|
spawner.update();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue