summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-07-15 21:16:06 +0200
committersnowleo <schneeleo@gmail.com>2011-07-15 21:16:06 +0200
commit411e96bb18df840cdb2517b4ee49cea58be68b7d (patch)
tree1aa3bd9dd4a2a381eef4e9e084393772312c98f7
parent705f9c267c28d99876a9774bd0886ed1ffe464f8 (diff)
downloadEssentials-411e96bb18df840cdb2517b4ee49cea58be68b7d.tar
Essentials-411e96bb18df840cdb2517b4ee49cea58be68b7d.tar.gz
Essentials-411e96bb18df840cdb2517b4ee49cea58be68b7d.tar.lz
Essentials-411e96bb18df840cdb2517b4ee49cea58be68b7d.tar.xz
Essentials-411e96bb18df840cdb2517b4ee49cea58be68b7d.zip
Fix /time command:
Removed essentials.time.player permission (this is now default) Added essentials.time.others permission Admins can now set the time of players Added reset option, that sets the time of the player to the world time
-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