summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-08-11 21:48:30 +0100
committerKHobbits <rob@khobbits.co.uk>2013-08-11 21:48:30 +0100
commitc7e08392f74e7777ec5fea8b5dcb6647982f210e (patch)
treeb81877d36a2ff37bd8b0ac545e2accbba38a3eb3 /Essentials/src/com/earth2me/essentials/commands/Commandvanish.java
parentdfdc519e66b6bb8b91fe962acaeb38eaab006aa6 (diff)
downloadEssentials-c7e08392f74e7777ec5fea8b5dcb6647982f210e.tar
Essentials-c7e08392f74e7777ec5fea8b5dcb6647982f210e.tar.gz
Essentials-c7e08392f74e7777ec5fea8b5dcb6647982f210e.tar.lz
Essentials-c7e08392f74e7777ec5fea8b5dcb6647982f210e.tar.xz
Essentials-c7e08392f74e7777ec5fea8b5dcb6647982f210e.zip
Allow toggling vanish for other players
Permission: essentials.vanish.others
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandvanish.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandvanish.java59
1 files changed, 41 insertions, 18 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java
index d3a876146..c44563325 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java
@@ -3,42 +3,65 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
+import org.bukkit.command.CommandSender;
-public class Commandvanish extends EssentialsCommand
+public class Commandvanish extends EssentialsToggleCommand
{
public Commandvanish()
{
- super("vanish");
+ super("vanish", "essentials.vanish.others");
+ }
+
+ @Override
+ protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ {
+ toggleOtherPlayers(server, sender, args);
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
- if (args.length < 1)
+ if (args.length == 1)
{
- if (user.isVanished())
+ Boolean toggle = matchToggleArgument(args[0]);
+ if (toggle == null && user.isAuthorized(othersPermission))
{
- user.setVanished(false);
- user.sendMessage(_("unvanished"));
+ toggleOtherPlayers(server, user.getBase(), args);
}
else
{
- user.setVanished(true);
- user.sendMessage(_("vanished"));
+ togglePlayer(user.getBase(), user, toggle);
}
}
+ else if (args.length == 2 && user.isAuthorized(othersPermission))
+ {
+ toggleOtherPlayers(server, user.getBase(), args);
+ }
else
{
- if (args[0].contains("on") || args[0].contains("ena") || args[0].equalsIgnoreCase("1"))
- {
- user.setVanished(true);
- }
- else
- {
- user.setVanished(false);
- }
- user.sendMessage(user.isVanished() ? _("vanished") : _("unvanished"));
+ togglePlayer(user.getBase(), user, null);
+ }
+ }
+
+ @Override
+ void togglePlayer(CommandSender sender, User user, Boolean enabled) throws NotEnoughArgumentsException
+ {
+ if (enabled == null)
+ {
+ enabled = !user.isVanished();
+ }
+
+ user.setVanished(enabled);
+ user.sendMessage(_("vanish", user.getDisplayName(), enabled ? _("enabled") : _("disabled")));
+
+ if (enabled == true)
+ {
+ user.sendMessage(_("vanished"));
+ }
+ if (!sender.equals(user.getBase()))
+ {
+ sender.sendMessage(_("vanish", user.getDisplayName(), enabled ? _("enabled") : _("disabled")));
}
}
-}
+} \ No newline at end of file