diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-04-23 19:01:22 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-04-23 22:54:43 -0400 |
commit | edfc8ba92fb5aaf3ffb8419cd70548ba076a2d3f (patch) | |
tree | 31ce6908cdb0f08979499b7d580b1777b668a0dd /src/main/java/org/bukkit | |
parent | b7376e08651e32addce2ba986d02f6e53e3ecdf2 (diff) | |
download | craftbukkit-edfc8ba92fb5aaf3ffb8419cd70548ba076a2d3f.tar craftbukkit-edfc8ba92fb5aaf3ffb8419cd70548ba076a2d3f.tar.gz craftbukkit-edfc8ba92fb5aaf3ffb8419cd70548ba076a2d3f.tar.lz craftbukkit-edfc8ba92fb5aaf3ffb8419cd70548ba076a2d3f.tar.xz craftbukkit-edfc8ba92fb5aaf3ffb8419cd70548ba076a2d3f.zip |
Add per-world spawn limits with fallback to server-wide bukkit.yml settings.
Fixes BUKKIT-1565
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 21 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 39 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 170e0911..04d825d6 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 25967d91..8603f9e2 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<BlockPopulator> populators = new ArrayList<BlockPopulator>(); 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; + } } |