summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtime.java39
1 files changed, 32 insertions, 7 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
index 9c4aa8c74..71bfb5965 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
@@ -15,20 +15,45 @@ public class Commandtime extends EssentialsCommand
}
@Override
- public void run(Server server, User user, String commandLabel, String[] args) throws Exception
+ public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
- World world = user.getWorld();
+ if (user.isAuthorized("essentials.time.world"))
+ {
+ final World world = user.getWorld();
+
+ charge(user);
+ setWorldTime(world, args[0]);
+ }
+ else
+ {
+ if (user.isAuthorized("essentials.time.player"))
+ {
- charge(user);
- setWorldTime(world, args[0]);
+ long time = user.getPlayerTime();
+ time -= time % 24000;
+ if ("day".equalsIgnoreCase(args[0]))
+ {
+ final World world = user.getWorld();
+ user.setPlayerTime(time + 24000 - world.getTime(), true);
+ return;
+ }
+ if ("night".equalsIgnoreCase(args[0]))
+ {
+ final World world = user.getWorld();
+ user.setPlayerTime(time + 37700 - world.getTime(), true);
+ return;
+ }
+ throw new Exception(Util.i18n("onlyDayNight"));
+ }
+ }
}
@Override
- public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
+ public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -42,10 +67,10 @@ public class Commandtime extends EssentialsCommand
sender.sendMessage(Util.i18n("timeSet"));
}
- private void setWorldTime(World world, String timeString) throws Exception
+ private void setWorldTime(final World world, final String timeString) throws Exception
{
long time = world.getTime();
- time = time - time % 24000;
+ time -= time % 24000;
if ("day".equalsIgnoreCase(timeString))
{
world.setTime(time + 24000);