Added configurable animal and monster ticks per spawn setting. Fixes #519

This commit is contained in:
Ammar Askar 2012-10-22 13:20:09 +05:00
parent 1c5c792cf3
commit 5a1fe2a9e5
2 changed files with 27 additions and 1 deletions

View File

@ -78,6 +78,8 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
PROPERTY_ALIASES.put("spawnlocation", "spawn");
PROPERTY_ALIASES.put("animals", "spawning.animals.spawn");
PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn");
PROPERTY_ALIASES.put("animalsrate", "spawning.animals.spawnrate");
PROPERTY_ALIASES.put("monstersrate", "spawning.monsters.spawnrate");
}
/*
* We have to use setCBWorld(), setPlugin() and initPerms() to prepare this object for use.
@ -233,6 +235,12 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
} else {
allowMonsters = true;
}
if (MVWorld.this.spawning.getAnimalSettings().getSpawnRate() != -1) {
world.get().setTicksPerAnimalSpawns(MVWorld.this.spawning.getAnimalSettings().getSpawnRate());
}
if (MVWorld.this.spawning.getMonsterSettings().getSpawnRate() != -1) {
world.get().setTicksPerMonsterSpawns(MVWorld.this.spawning.getMonsterSettings().getSpawnRate());
}
world.get().setSpawnFlags(allowMonsters, allowAnimals);
plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(MVWorld.this);
return super.validateChange(property, newValue, oldValue, object);

View File

@ -17,6 +17,8 @@ public class SubSpawnSettings extends SerializationConfig {
@Property
private boolean spawn;
@Property
private int spawnrate;
@Property
private List<String> exceptions;
public SubSpawnSettings() {
@ -34,6 +36,7 @@ public class SubSpawnSettings extends SerializationConfig {
public void setDefaults() {
spawn = true;
exceptions = new ArrayList<String>();
spawnrate = -1;
}
/**
@ -51,9 +54,24 @@ public class SubSpawnSettings extends SerializationConfig {
}
/**
* @return the exceptions
* @return The exceptions
*/
public List<String> getExceptions() {
return exceptions;
}
/**
*
* @param The new spawn rate
*/
public void setSpawnRate(int rate) {
this.spawnrate = rate;
}
/**
* @return The spawn rate
*/
public int getSpawnRate() {
return this.spawnrate;
}
}