From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Chase Whipple <chasewhip20@gmail.com>
Date: Thu, 26 Mar 2020 21:45:54 -0600
Subject: [PATCH] Per World Spawn Limits


diff --git a/src/main/java/com/tuinity/tuinity/config/TuinityConfig.java b/src/main/java/com/tuinity/tuinity/config/TuinityConfig.java
index 994c735958dc0ee0dfd8c28820fcd4f50057aad0..a302cda14aa2dd6550cca03b07be21cdcb993061 100644
--- a/src/main/java/com/tuinity/tuinity/config/TuinityConfig.java
+++ b/src/main/java/com/tuinity/tuinity/config/TuinityConfig.java
@@ -269,6 +269,23 @@ public final class TuinityConfig {
             final int threads = this.getInt("tick-threads", -1);
             this.threads = threads == -1 ? TuinityConfig.tickThreads : threads;
         }*/
+
+        public int spawnLimitMonsters;
+        public int spawnLimitAnimals;
+        public int spawnLimitWaterAmbient;
+        public int spawnLimitWaterAnimals;
+        public int spawnLimitAmbient;
+
+        private void perWorldSpawnLimit() {
+            final String path = "spawn-limits";
+
+            this.spawnLimitMonsters = this.getInt(path + ".monsters", -1);
+            this.spawnLimitAnimals = this.getInt(path + ".animals", -1);
+            this.spawnLimitWaterAmbient = this.getInt(path + ".water-ambient", -1);
+            this.spawnLimitWaterAnimals = this.getInt(path + ".water-animals", -1);
+            this.spawnLimitAmbient = this.getInt(path + ".ambient", -1);
+        }
+
     }
 
 }
\ No newline at end of file
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 3c7e3db06be46b20c417b7ef36a17affa4c6ef78..80944242cb0c16a7b2b1c6b193656e78c2e58dd5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -342,6 +342,14 @@ public class CraftWorld implements World {
         this.generator = gen;
 
         environment = env;
+
+        //Tuinity start - per world spawn limits
+        monsterSpawn = world.tuinityConfig.spawnLimitMonsters;
+        animalSpawn = world.tuinityConfig.spawnLimitAnimals;
+        waterAmbientSpawn = world.tuinityConfig.spawnLimitWaterAmbient;
+        waterAnimalSpawn = world.tuinityConfig.spawnLimitWaterAnimals;
+        ambientSpawn = world.tuinityConfig.spawnLimitAmbient;
+        //Tuinity end
     }
 
     @Override
