Add multiworld difficulty

This commit is contained in:
Eric Stokes 2011-10-02 21:18:25 -06:00
parent d97bbfb1b1
commit c566ead9ef
2 changed files with 28 additions and 1 deletions

View File

@ -406,6 +406,9 @@ public class MVWorld {
* @return
*/
public boolean setVariable(String name, String value) {
if (name.equalsIgnoreCase("diff") || name.equalsIgnoreCase("difficulty")) {
return this.setDifficulty(value);
}
if (name.equalsIgnoreCase("alias")) {
this.setAlias(value);
return true;
@ -733,4 +736,28 @@ public class MVWorld {
public Location getSpawnLocation() {
return this.spawnLocation;
}
public World.Difficulty getDifficulty() {
return this.getCBWorld().getDifficulty();
}
public boolean setDifficulty(String difficulty) {
try {
World.Difficulty worlddiff = World.Difficulty.valueOf(difficulty);
this.getCBWorld().setDifficulty(worlddiff);
return true;
} catch (Exception e) {
try {
int diff = Integer.parseInt(difficulty);
if(diff >= 0 && diff <= 3) {
World.Difficulty worlddiff = World.Difficulty.getDifficulty(diff);
this.getCBWorld().setDifficulty(worlddiff);
return true;
}
} catch (Exception e2) {
}
return false;
}
}
}

View File

@ -27,7 +27,7 @@ enum Action {
// Color == Aliascolor
enum SetProperties {
alias, animals, monsters, pvp, scaling, aliascolor, color, respawn, currency, curr, price, scale, spawnmemory, memory, weather, storm, gamemode, mode, hunger, food
alias, animals, monsters, pvp, scaling, aliascolor, color, respawn, currency, curr, price, scale, spawnmemory, memory, weather, storm, gamemode, mode, hunger, food, diff, difficulty
}
public class ModifyCommand extends MultiverseCommand {