From 10f47ed7a55e2c385bfff4de99c0e3c17ab02091 Mon Sep 17 00:00:00 2001 From: snowleo Date: Mon, 15 Oct 2012 22:42:48 +0200 Subject: [PATCH] World permissions for /time command --- Essentials/src/net/ess3/commands/Commandtime.java | 12 +++++++++++- Essentials/src/net/ess3/permissions/Permissions.java | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Essentials/src/net/ess3/commands/Commandtime.java b/Essentials/src/net/ess3/commands/Commandtime.java index 0b64be99b..c76d8850a 100644 --- a/Essentials/src/net/ess3/commands/Commandtime.java +++ b/Essentials/src/net/ess3/commands/Commandtime.java @@ -88,8 +88,15 @@ public class Commandtime extends EssentialsCommand private void setWorldsTime(final CommandSender sender, final Collection worlds, final long ticks, final boolean add) { // Update the time - for (World world : worlds) + Iterator 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(); if (!add) { @@ -98,6 +105,9 @@ public class Commandtime extends EssentialsCommand world.setTime(time + (add ? 0 : 24000) + ticks); } + if (worlds.isEmpty()) { + return; + } final StringBuilder output = new StringBuilder(); for (World world : worlds) { diff --git a/Essentials/src/net/ess3/permissions/Permissions.java b/Essentials/src/net/ess3/permissions/Permissions.java index 59bd21e9e..3baa39678 100644 --- a/Essentials/src/net/ess3/permissions/Permissions.java +++ b/Essentials/src/net/ess3/permissions/Permissions.java @@ -157,4 +157,5 @@ public enum Permissions implements IPermission public static DotStarPermission NICK = new DotStarPermission("essentials.nick"); public static DotStarPermission SIGNS = new DotStarPermission("essentials.signs"); public static DotStarPermission CHAT = new DotStarPermission("essentials.chat"); + public static DotStarPermission TIME_WORLDS = new DotStarPermission("essentials.time.worlds", PermissionDefault.TRUE); }