summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-06-23 13:31:23 +0200
committersnowleo <schneeleo@gmail.com>2011-06-23 13:31:23 +0200
commitca9364d25bc3c50698fc5a79b1d9916615c11851 (patch)
tree2203f4bcc10f66cc50119f022a1201d80e2ec1b4
parent7fc6d73241b2b4a7905a9cf072ffed562eba1f54 (diff)
downloadEssentials-ca9364d25bc3c50698fc5a79b1d9916615c11851.tar
Essentials-ca9364d25bc3c50698fc5a79b1d9916615c11851.tar.gz
Essentials-ca9364d25bc3c50698fc5a79b1d9916615c11851.tar.lz
Essentials-ca9364d25bc3c50698fc5a79b1d9916615c11851.tar.xz
Essentials-ca9364d25bc3c50698fc5a79b1d9916615c11851.zip
Update to /time command:
Supports player time now. New permissions: essentials.time.world (if the user is allowed to change the time of the world) essentials.time.player (if the user is allowed to change his own time) Backwards incompatibility!
-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);