summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2012-04-23 19:01:22 -0500
committerEvilSeph <evilseph@gmail.com>2012-04-23 22:54:43 -0400
commitedfc8ba92fb5aaf3ffb8419cd70548ba076a2d3f (patch)
tree31ce6908cdb0f08979499b7d580b1777b668a0dd /src/main/java
parentb7376e08651e32addce2ba986d02f6e53e3ecdf2 (diff)
downloadcraftbukkit-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')
-rw-r--r--src/main/java/net/minecraft/server/SpawnerCreature.java18
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java21
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java39
3 files changed, 77 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 1090c0da..4f4d6c0a 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 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;
+ }
}