1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-30 01:39:51 +02:00

World permissions for /time command

This commit is contained in:
snowleo
2012-10-15 22:42:48 +02:00
parent 7c8f7ba3ed
commit 10f47ed7a5
2 changed files with 12 additions and 1 deletions

View File

@@ -88,8 +88,15 @@ public class Commandtime extends EssentialsCommand
private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks, final boolean add) private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks, final boolean add)
{ {
// Update the time // Update the time
for (World world : worlds) Iterator<World> iterator = worlds.iterator();
while (iterator.hasNext())
{ {
World world = iterator.next();
if (!Permissions.TIME_WORLDS.isAuthorized(sender, world.getName())) {
iterator.remove();
sender.sendMessage("You are not allowed to set the time in world "+world.getName()); //TODO:I18n
continue;
}
long time = world.getTime(); long time = world.getTime();
if (!add) if (!add)
{ {
@@ -98,6 +105,9 @@ public class Commandtime extends EssentialsCommand
world.setTime(time + (add ? 0 : 24000) + ticks); world.setTime(time + (add ? 0 : 24000) + ticks);
} }
if (worlds.isEmpty()) {
return;
}
final StringBuilder output = new StringBuilder(); final StringBuilder output = new StringBuilder();
for (World world : worlds) for (World world : worlds)
{ {

View File

@@ -157,4 +157,5 @@ public enum Permissions implements IPermission
public static DotStarPermission NICK = new DotStarPermission("essentials.nick"); public static DotStarPermission NICK = new DotStarPermission("essentials.nick");
public static DotStarPermission SIGNS = new DotStarPermission("essentials.signs"); public static DotStarPermission SIGNS = new DotStarPermission("essentials.signs");
public static DotStarPermission CHAT = new DotStarPermission("essentials.chat"); public static DotStarPermission CHAT = new DotStarPermission("essentials.chat");
public static DotStarPermission TIME_WORLDS = new DotStarPermission("essentials.time.worlds", PermissionDefault.TRUE);
} }