From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: chase Date: Wed, 2 Dec 2020 22:43:39 -0800 Subject: [PATCH] add per world spawn limits Taken from #2982. Credit to Chasewhip8 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index ba8ae4d1c86293ca5c95d830d145023b4fe21d71..fc9b69d87364b578327dffb657746c08ab505be3 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -681,6 +681,19 @@ public class PaperWorldConfig { zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance); } + public int spawnLimitMonsters = -1; + public int spawnLimitAnimals = -1; + public int spawnLimitWaterAnimals = -1; + public int spawnLimitWaterAmbient = -1; + public int spawnLimitAmbient = -1; + private void perWorldSpawnLimits() { + spawnLimitMonsters = getInt("spawn-limits.monsters", spawnLimitMonsters); + spawnLimitAnimals = getInt("spawn-limits.animals", spawnLimitAnimals); + spawnLimitWaterAnimals = getInt("spawn-limits.water-animals", spawnLimitWaterAnimals); + spawnLimitWaterAmbient = getInt("spawn-limits.water-ambient", spawnLimitWaterAmbient); + spawnLimitAmbient = getInt("spawn-limits.ambient", spawnLimitAmbient); + } + public int lightQueueSize = 20; private void lightQueueSize() { lightQueueSize = getInt("light-queue-size", lightQueueSize); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 7d6c2889a07c99412a47700f001ec1a3f72a3b45..527a1b5c523718af96009b4c52c40ed32906d49a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -208,6 +208,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { this.biomeProvider = biomeProvider; this.environment = env; + // Paper start - per world spawn limits + this.monsterSpawn = this.world.paperConfig.spawnLimitMonsters; + this.animalSpawn = this.world.paperConfig.spawnLimitAnimals; + this.waterAnimalSpawn = this.world.paperConfig.spawnLimitWaterAnimals; + this.waterAmbientSpawn = this.world.paperConfig.spawnLimitWaterAmbient; + this.ambientSpawn = this.world.paperConfig.spawnLimitAmbient; + // Paper end } @Override