3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 04:50:05 +01:00
Paper/patches/server/0709-add-per-world-spawn-limits.patch
2021-07-25 07:00:54 +00:00

50 Zeilen
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: chase <chasewhip20@gmail.com>
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 97a1ca789eb606b263ebabad188baefe4df69b85..435558eb9f3ce277c14ff5e368d489d1df4da8e1 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -660,6 +660,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 39f8ff65ae06a072ad37e80769244895e98a727a..7dc26321e20e26821096e79356a358879306cd78 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -352,6 +352,13 @@ public class CraftWorld implements World {
this.generator = gen;
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