diff options
author | snowleo <schneeleo@gmail.com> | 2012-07-12 12:13:05 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2012-07-12 12:30:25 +0200 |
commit | c3e261d60ac9e406442858856ca1e90bea7e2be0 (patch) | |
tree | 6877dd19880b6d20c3b3136644065bc0a299580e | |
parent | cfb93e97f005a03e01357a503954473ba1dbca72 (diff) | |
download | Essentials-c3e261d60ac9e406442858856ca1e90bea7e2be0.tar Essentials-c3e261d60ac9e406442858856ca1e90bea7e2be0.tar.gz Essentials-c3e261d60ac9e406442858856ca1e90bea7e2be0.tar.lz Essentials-c3e261d60ac9e406442858856ca1e90bea7e2be0.tar.xz Essentials-c3e261d60ac9e406442858856ca1e90bea7e2be0.zip |
Fix /time command
-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(); |