summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtime.java72
-rw-r--r--Essentials/src/plugin.yml4
2 files changed, 51 insertions, 25 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
index 71bfb5965..d05f8890c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
@@ -21,33 +21,28 @@ public class Commandtime extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- if (user.isAuthorized("essentials.time.world"))
+ if (args.length < 2)
{
- final World world = user.getWorld();
+ if (user.isAuthorized("essentials.time.world"))
+ {
+ final World world = user.getWorld();
- charge(user);
- setWorldTime(world, args[0]);
+ charge(user);
+ setWorldTime(world, args[0]);
+ }
+ else
+ {
+ charge(user);
+ setPlayerTime(user, commandLabel);
+ }
}
else
{
- if (user.isAuthorized("essentials.time.player"))
+ if (user.isAuthorized("essentials.time.others"))
{
-
- 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"));
+ User u = getPlayer(server, args, 1);
+ charge(user);
+ setPlayerTime(u, args[0]);
}
}
}
@@ -59,9 +54,17 @@ public class Commandtime extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- for (World world : server.getWorlds())
+ if (args.length < 2)
+ {
+ for (World world : server.getWorlds())
+ {
+ setWorldTime(world, args[0]);
+ }
+ }
+ else
{
- setWorldTime(world, args[0]);
+ User u = getPlayer(server, args, 1);
+ setPlayerTime(u, args[0]);
}
sender.sendMessage(Util.i18n("timeSet"));
@@ -83,4 +86,27 @@ public class Commandtime extends EssentialsCommand
}
throw new Exception(Util.i18n("onlyDayNight"));
}
+
+ private void setPlayerTime(final User user, final String timeString) throws Exception
+ {
+ long time = user.getPlayerTime();
+ time -= time % 24000;
+ if ("day".equalsIgnoreCase(timeString))
+ {
+ final World world = user.getWorld();
+ user.setPlayerTime(time + 24000 - world.getTime(), true);
+ return;
+ }
+ if ("night".equalsIgnoreCase(timeString))
+ {
+ final World world = user.getWorld();
+ user.setPlayerTime(time + 37700 - world.getTime(), true);
+ return;
+ }
+ if ("reset".equalsIgnoreCase(timeString))
+ {
+ user.resetPlayerTime();
+ }
+ throw new Exception(Util.i18n("onlyDayNight"));
+ }
}
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index cea6c6e30..d3113a636 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -267,8 +267,8 @@ commands:
usage: /<command> <true/false> [duration]
aliases: [ethunder]
time:
- description: Change the server time to day or night.
- usage: /<command> [day|night]
+ description: Change the time to day or night of the player (default) or world (essentials.time.world permission).
+ usage: /<command> [day|night|reset] <playername>
aliases: [etime]
togglejail:
description: Prevents a player from interacting with the world and teleports him/her to the the jail specified