diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-12-02 00:57:29 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-12-02 00:59:04 +0000 |
commit | 032c35c90df51ea8dcc3dec4ce262689b1c85100 (patch) | |
tree | 3804a3fa141036dad20b0a2f247eb973e651aaa2 | |
parent | f79fe70a86d29e0f9f14e3bc111f4f289101b4d5 (diff) | |
download | Essentials-032c35c90df51ea8dcc3dec4ce262689b1c85100.tar Essentials-032c35c90df51ea8dcc3dec4ce262689b1c85100.tar.gz Essentials-032c35c90df51ea8dcc3dec4ce262689b1c85100.tar.lz Essentials-032c35c90df51ea8dcc3dec4ce262689b1c85100.tar.xz Essentials-032c35c90df51ea8dcc3dec4ce262689b1c85100.zip |
Don't allow toggling offline players with /fly and /vanish
-rw-r--r-- | Essentials/src/net/ess3/commands/Commandfly.java | 8 | ||||
-rw-r--r-- | Essentials/src/net/ess3/commands/Commandvanish.java | 4 | ||||
-rw-r--r-- | Essentials/src/net/ess3/commands/EssentialsSettingsCommand.java | 14 |
3 files changed, 21 insertions, 5 deletions
diff --git a/Essentials/src/net/ess3/commands/Commandfly.java b/Essentials/src/net/ess3/commands/Commandfly.java index c609a2a5d..95b2c92d5 100644 --- a/Essentials/src/net/ess3/commands/Commandfly.java +++ b/Essentials/src/net/ess3/commands/Commandfly.java @@ -1,10 +1,9 @@ package net.ess3.commands; import static net.ess3.I18n._; +import org.bukkit.command.CommandSender; import net.ess3.api.IUser; import net.ess3.permissions.Permissions; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; public class Commandfly extends EssentialsSettingsCommand @@ -49,4 +48,9 @@ public class Commandfly extends EssentialsSettingsCommand { return Permissions.FLY_EXEMPT.isAuthorized(player); } + + protected boolean toggleOfflinePlayers() + { + return false; + } } diff --git a/Essentials/src/net/ess3/commands/Commandvanish.java b/Essentials/src/net/ess3/commands/Commandvanish.java index 34b63842f..c6bedafaa 100644 --- a/Essentials/src/net/ess3/commands/Commandvanish.java +++ b/Essentials/src/net/ess3/commands/Commandvanish.java @@ -44,4 +44,8 @@ public class Commandvanish extends EssentialsSettingsCommand return Permissions.VANISH_EXEMPT.isAuthorized(player); } + protected boolean toggleOfflinePlayers() + { + return false; + } } diff --git a/Essentials/src/net/ess3/commands/EssentialsSettingsCommand.java b/Essentials/src/net/ess3/commands/EssentialsSettingsCommand.java index 9d060cbdb..d63df7253 100644 --- a/Essentials/src/net/ess3/commands/EssentialsSettingsCommand.java +++ b/Essentials/src/net/ess3/commands/EssentialsSettingsCommand.java @@ -1,10 +1,9 @@ package net.ess3.commands; -import static net.ess3.I18n._; +import java.util.Set; import org.bukkit.Server; import org.bukkit.command.CommandSender; import net.ess3.api.IUser; -import net.ess3.permissions.Permissions; public abstract class EssentialsSettingsCommand extends EssentialsCommand @@ -40,6 +39,11 @@ public abstract class EssentialsSettingsCommand extends EssentialsCommand throw new UnsupportedOperationException("Not supported yet."); } + protected boolean toggleOfflinePlayers() + { + return true; + } + @Override protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception { @@ -84,7 +88,11 @@ public abstract class EssentialsSettingsCommand extends EssentialsCommand private void toggleOtherPlayers(final Server server, final CommandSender sender, final String[] args) { - for (IUser matchPlayer : ess.getUserMap().matchUsersExcludingHidden(args[0], getPlayerOrNull(sender))) + Set<IUser> matches = toggleOfflinePlayers() ? ess.getUserMap().matchUsers(args[0], true) : ess.getUserMap().matchUsersExcludingHidden( + args[0], getPlayerOrNull( + sender)); + + for (IUser matchPlayer : matches) { if (isExempt(sender, matchPlayer)) { |