diff options
-rw-r--r-- | Essentials/src/net/ess3/commands/Commandtime.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Essentials/src/net/ess3/commands/Commandtime.java b/Essentials/src/net/ess3/commands/Commandtime.java index caa4c6d08..29cfda36a 100644 --- a/Essentials/src/net/ess3/commands/Commandtime.java +++ b/Essentials/src/net/ess3/commands/Commandtime.java @@ -16,10 +16,16 @@ public class Commandtime extends EssentialsCommand @Override public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception { + boolean add = false; final List<String> argList = new ArrayList<String>(Arrays.asList(args)); - if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0))) + if (argList.remove("set") && !argList.isEmpty() && Util.isInt(argList.get(0))) { - ess.getLogger().info("debug edited 0" + argList.get(0).toString()); + argList.set(0, argList.get(0) + "t"); + } + if (argList.remove("add") && !argList.isEmpty() && Util.isInt(argList.get(0))) + { + add = true; + argList.set(0, argList.get(0) + "t"); } final String[] validArgs = argList.toArray(new String[0]); @@ -55,7 +61,7 @@ public class Commandtime extends EssentialsCommand throw new NotEnoughArgumentsException(e); } - setWorldsTime(sender, worlds, ticks); + setWorldsTime(sender, worlds, ticks, add); } /** @@ -79,14 +85,17 @@ public class Commandtime extends EssentialsCommand /** * Used to set the time and inform of the change */ - private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks) + private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks, final boolean add) { // Update the time for (World world : worlds) { long time = world.getTime(); - time -= time % 24000; - world.setTime(time + 24000 + ticks); + if (!add) + { + time -= time % 24000; + } + world.setTime(time + (add ? 0 : 24000) + ticks); } final StringBuilder output = new StringBuilder(); |