From c566ead9ef0d26c0599280b2ce0b768491ad621f Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sun, 2 Oct 2011 21:18:25 -0600 Subject: [PATCH] Add multiworld difficulty --- .../onarandombox/MultiverseCore/MVWorld.java | 27 +++++++++++++++++++ .../commands/ModifyCommand.java | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) 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 {