summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-11-16 02:52:19 +0000
committerKHobbits <rob@khobbits.co.uk>2012-11-16 02:52:19 +0000
commit7eab8aa6f8b846f3992265b89457cf1a62d4aeae (patch)
treedf2e769182950e5e9107a95a88a8f58fa0237db3
parente382a6c92338314d138ad62cd5a718ce49758f88 (diff)
downloadEssentials-7eab8aa6f8b846f3992265b89457cf1a62d4aeae.tar
Essentials-7eab8aa6f8b846f3992265b89457cf1a62d4aeae.tar.gz
Essentials-7eab8aa6f8b846f3992265b89457cf1a62d4aeae.tar.lz
Essentials-7eab8aa6f8b846f3992265b89457cf1a62d4aeae.tar.xz
Essentials-7eab8aa6f8b846f3992265b89457cf1a62d4aeae.zip
Add vanish toggle to abstract
-rw-r--r--Essentials/src/net/ess3/api/IUser.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandtptoggle.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandvanish.java61
-rw-r--r--Essentials/src/net/ess3/permissions/Permissions.java4
4 files changed, 40 insertions, 33 deletions
diff --git a/Essentials/src/net/ess3/api/IUser.java b/Essentials/src/net/ess3/api/IUser.java
index 40c3f39c1..bcfb2610f 100644
--- a/Essentials/src/net/ess3/api/IUser.java
+++ b/Essentials/src/net/ess3/api/IUser.java
@@ -69,8 +69,6 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
boolean isGodModeEnabled();
- boolean isTeleportEnabled();
-
boolean isIgnoringPlayer(IUser user);
void setIgnoredPlayer(IUser user, boolean set);
@@ -121,8 +119,6 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
void setGodModeEnabled(boolean set);
- void setTeleportEnabled(boolean set);
-
void setVanished(boolean set);
boolean checkSignThrottle(int throttle);
diff --git a/Essentials/src/net/ess3/commands/Commandtptoggle.java b/Essentials/src/net/ess3/commands/Commandtptoggle.java
index 3e1b17371..73c05e6a9 100644
--- a/Essentials/src/net/ess3/commands/Commandtptoggle.java
+++ b/Essentials/src/net/ess3/commands/Commandtptoggle.java
@@ -11,12 +11,12 @@ public class Commandtptoggle extends EssentialsSettingsCommand
protected void setValue(final IUser player, final boolean value)
{
- player.setTeleportEnabled(value);
+ player.getData().setTeleportEnabled(value);
}
protected boolean getValue(final IUser player)
{
- return player.isTeleportEnabled();
+ return player.getData().isTeleportEnabled();
}
protected void informSender(final CommandSender sender, final boolean value, final IUser player)
diff --git a/Essentials/src/net/ess3/commands/Commandvanish.java b/Essentials/src/net/ess3/commands/Commandvanish.java
index 16cab5a51..cc57b1203 100644
--- a/Essentials/src/net/ess3/commands/Commandvanish.java
+++ b/Essentials/src/net/ess3/commands/Commandvanish.java
@@ -1,37 +1,46 @@
package net.ess3.commands;
import static net.ess3.I18n._;
+import org.bukkit.command.CommandSender;
import net.ess3.api.IUser;
+import net.ess3.permissions.Permissions;
-public class Commandvanish extends EssentialsCommand
+public class Commandvanish extends EssentialsSettingsCommand
{
- @Override
- protected void run(IUser user, String commandLabel, String[] args) throws Exception
+ protected void setValue(final IUser player, final boolean value)
{
- if (args.length < 1)
- {
- user.toggleVanished();
- if (user.isVanished())
- {
- user.sendMessage(_("vanished"));
- }
- else
- {
- user.sendMessage(_("unvanished"));
- }
+ player.setVanished(value);
+ }
+
+ protected boolean getValue(final IUser player)
+ {
+ return player.isVanished();
+ }
+
+ protected void informSender(final CommandSender sender, final boolean value, final IUser player)
+ {
+ if (value) {
+ sender.sendMessage( _("vanishMode", _(getValue(player) ? "enabled" : "disabled"), player.getPlayer().getDisplayName()));
}
- 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"));
+ else {
+ sender.sendMessage("Can't change vanish mode for player " + player.getName());
}
- }
+ }
+
+ protected void informPlayer(final IUser player)
+ {
+ player.sendMessage(getValue(player) ? _("vanished") : _("unvanished"));
+ }
+
+ protected boolean canToggleOthers(final IUser user)
+ {
+ return Permissions.VANISH_OTHERS.isAuthorized(user);
+ }
+
+ protected boolean isExempt(final CommandSender sender, final IUser player)
+ {
+ return Permissions.VANISH_EXEMPT.isAuthorized(player);
+ }
+
}
diff --git a/Essentials/src/net/ess3/permissions/Permissions.java b/Essentials/src/net/ess3/permissions/Permissions.java
index 089f8b902..d4f2e763c 100644
--- a/Essentials/src/net/ess3/permissions/Permissions.java
+++ b/Essentials/src/net/ess3/permissions/Permissions.java
@@ -111,8 +111,10 @@ public enum Permissions implements IPermission
WARP_LIST(PermissionDefault.TRUE),
WARP_HIDDEN,
WARP_OTHERS,
+ VANISH_EXEMPT,
VANISH_SEE_OTHERS,
- VANISH_PVP;
+ VANISH_PVP,
+ VANISH_OTHERS;
private static final String base = "essentials.";
private final String permission;
private final PermissionDefault defaultPerm;