mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-25 01:21:26 +01:00
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
This commit is contained in:
parent
705f9c267c
commit
411e96bb18
@ -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)
|
||||
{
|
||||
setWorldTime(world, args[0]);
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
setWorldTime(world, args[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user