diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java index a40e4f81..807220ac 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java @@ -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; + } + + } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java index 0b26177e..6bcdc175 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java @@ -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 {