diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java index 1090c0da42..4f4d6c0aa9 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -93,7 +93,23 @@ public final class SpawnerCreature { for (int j1 = 0; j1 < j; ++j1) { EnumCreatureType enumcreaturetype = aenumcreaturetype[j1]; - if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= enumcreaturetype.b() * b.size() / 256) { + // CraftBukkit start - use per-world spawn limits + int limit = 0; + switch(enumcreaturetype) { + case MONSTER: + limit = world.getWorld().getMonsterSpawnLimit(); + case CREATURE: + limit = world.getWorld().getAnimalSpawnLimit(); + case WATER_CREATURE: + limit = world.getWorld().getWaterAnimalSpawnLimit(); + } + + if (limit == 0) { + return 0; + } + // CraftBukkit end + + if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits // CraftBukkit start label108: diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 170e091143..04d825d6ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -142,6 +142,9 @@ public final class CraftServer implements Server { private final EntityMetadataStore entityMetadata = new EntityMetadataStore(); private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore(); private final WorldMetadataStore worldMetadata = new WorldMetadataStore(); + private int monsterSpawn = -1; + private int animalSpawn = -1; + private int waterAnimalSpawn = -1; static { ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); @@ -172,6 +175,9 @@ public final class CraftServer implements Server { configuration.setDefaults(YamlConfiguration.loadConfiguration(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"))); saveConfig(); ((SimplePluginManager) pluginManager).useTimings(configuration.getBoolean("settings.plugin-profiling")); + monsterSpawn = configuration.getInt("spawn-limits.monsters"); + animalSpawn = configuration.getInt("spawn-limits.animals"); + waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); updater = new AutoUpdater(new BukkitDLUpdaterService(configuration.getString("auto-updater.host")), getLogger(), configuration.getString("auto-updater.preferred-channel")); updater.setEnabled(configuration.getBoolean("auto-updater.enabled")); @@ -493,6 +499,9 @@ public final class CraftServer implements Server { console.spawnAnimals = config.getBoolean("spawn-animals", console.spawnAnimals); console.pvpMode = config.getBoolean("pvp", console.pvpMode); console.allowFlight = config.getBoolean("allow-flight", console.allowFlight); + monsterSpawn = configuration.getInt("spawn-limits.monsters"); + animalSpawn = configuration.getInt("spawn-limits.animals"); + waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); for (WorldServer world : console.worlds) { world.difficulty = difficulty; @@ -1161,4 +1170,16 @@ public final class CraftServer implements Server { public SimpleCommandMap getCommandMap() { return commandMap; } + + public int getMonsterSpawnLimit() { + return monsterSpawn; + } + + public int getAnimalSpawnLimit() { + return animalSpawn; + } + + public int getWaterAnimalSpawnLimit() { + return waterAnimalSpawn; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 25967d9126..8603f9e270 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -56,6 +56,9 @@ public class CraftWorld implements World { private final ChunkGenerator generator; private final List populators = new ArrayList(); private final BlockMetadataStore blockMetadata = new BlockMetadataStore(this); + private int monsterSpawn = -1; + private int animalSpawn = -1; + private int waterAnimalSpawn = -1; private static final Random rand = new Random(); @@ -1119,4 +1122,40 @@ public class CraftWorld implements World { public void removeMetadata(String metadataKey, Plugin owningPlugin) { server.getWorldMetadata().removeMetadata(this, metadataKey, owningPlugin); } + + public int getMonsterSpawnLimit() { + if (monsterSpawn < 0) { + return server.getMonsterSpawnLimit(); + } + + return monsterSpawn; + } + + public void setMonsterSpawnLimit(int limit) { + monsterSpawn = limit; + } + + public int getAnimalSpawnLimit() { + if (animalSpawn < 0) { + return server.getAnimalSpawnLimit(); + } + + return animalSpawn; + } + + public void setAnimalSpawnLimit(int limit) { + animalSpawn = limit; + } + + public int getWaterAnimalSpawnLimit() { + if (waterAnimalSpawn < 0) { + return server.getWaterAnimalSpawnLimit(); + } + + return waterAnimalSpawn; + } + + public void setWaterAnimalSpawnLimit(int limit) { + waterAnimalSpawn = limit; + } } diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml index a1ebd98a68..ebd6d02ae0 100644 --- a/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml @@ -23,6 +23,10 @@ settings: use-exact-login-location: false plugin-profiling: false connection-throttle: 4000 +spawn-limits: + monsters: 70 + animals: 15 + water-animals: 5 ticks-per: animal-spawns: 400 monster-spawns: 1