Make a few entity limits configurable

This commit is contained in:
kaboom 2022-05-21 20:04:39 +03:00
parent 0cda7acb6a
commit 9c42f5d9e9
2 changed files with 8 additions and 6 deletions

View file

@ -35,7 +35,10 @@ import pw.kaboom.extras.Main;
public final class EntitySpawn implements Listener {
private static final FileConfiguration CONFIG = JavaPlugin.getPlugin(Main.class).getConfig();
private static final int MAX_ENTITIES_PER_CHUNK = CONFIG.getInt("maxEntitiesPerChunk");
private static final int MAX_ENTITIES_PER_WORLD = CONFIG.getInt("maxEntitiesPerWorld");
private static final int MAX_TNTS_PER_WORLD = CONFIG.getInt("maxTntsPerWorld");
private void applyEntityChanges(final Entity entity) {
switch (entity.getType()) {
@ -57,7 +60,7 @@ public final class EntitySpawn implements Listener {
private boolean checkShouldRemoveEntities(final World world) {
final int worldEntityCount = world.getEntities().size();
if (worldEntityCount > 1024) {
if (worldEntityCount > MAX_ENTITIES_PER_WORLD) {
for (Entity entity : world.getEntities()) {
if (!EntityType.PLAYER.equals(entity.getType())) {
entity.remove();
@ -78,16 +81,13 @@ public final class EntitySpawn implements Listener {
if (worldDragonCount >= worldDragonCountLimit) {
return true;
}
break;
case PRIMED_TNT:
final int worldTntCount = world.getEntitiesByClass(TNTPrimed.class).size();
final int worldTntCountLimit = 200;
if (worldTntCount >= worldTntCountLimit) {
if (worldTntCount >= MAX_TNTS_PER_WORLD) {
return true;
}
break;
default:
if (!EntityType.PLAYER.equals(entityType)) {

View file

@ -4,7 +4,9 @@ enableKick: false
enableJoinRestrictions: false
opOnJoin: true
randomizeSpawn: false
maxEntitiesPerChunk: 30 # Set to -1 to disable
maxEntitiesPerChunk: 50
maxEntitiesPerWorld: 5120
maxTntsPerWorld: 1024
playerJoinTitle: "§7Welcome to Kaboom!"
playerJoinSubtitle: "Free OP • Anarchy • Creative"
opTag: "§4§l[§c§lOP§4§l] §c"