From c3e261d60ac9e406442858856ca1e90bea7e2be0 Mon Sep 17 00:00:00 2001 From: snowleo Date: Thu, 12 Jul 2012 12:13:05 +0200 Subject: Fix /time command --- Essentials/src/net/ess3/commands/Commandtime.java | 21 +++++++++++++++------ 1 file 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 argList = new ArrayList(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 worlds, final long ticks) + private void setWorldsTime(final CommandSender sender, final Collection 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(); -- cgit v1.2.3