Archiviert
13
0

Add per-world spawn limits with fallback to server-wide bukkit.yml settings.

Fixes BUKKIT-1565
Dieser Commit ist enthalten in:
Travis Watkins 2012-04-23 19:01:22 -05:00 committet von EvilSeph
Ursprung b7376e0865
Commit edfc8ba92f
4 geänderte Dateien mit 81 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -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:

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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