From 2e113425f22fe4de2c716092ef8ab0ca911099bf Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 11 Jun 2012 09:17:19 +1000 Subject: Fix the vanish command for good. --- .../src/com/earth2me/essentials/Essentials.java | 4 +++- .../earth2me/essentials/EssentialsPlayerListener.java | 5 ++++- Essentials/src/com/earth2me/essentials/User.java | 11 +++++++++++ .../earth2me/essentials/commands/Commandvanish.java | 19 ++++--------------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 5b6236c30..6f97a23d7 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -269,8 +269,10 @@ public class Essentials extends JavaPlugin implements IEssentials { for (Player p : getServer().getOnlinePlayers()) { - if (getUser(p).isVanished()) + User user = getUser(p); + if (user.isVanished()) { + user.toggleVanished(); p.sendMessage(_("unvanishedReload")); } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 0672f087a..8a0347cb8 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -116,7 +116,10 @@ public class EssentialsPlayerListener implements Listener { user.setGodModeEnabled(false); } - ess.getVanishedPlayers().remove(user.getName()); + if (user.isVanished()) + { + user.toggleVanished(); + } user.setLastLocation(); user.updateActivity(false); user.dispose(); diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index b752458ba..06cf375a1 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -642,11 +642,22 @@ public class User extends UserData implements Comparable, IReplyTo, IUser vanished = !vanished; if (vanished) { + for (Player p : ess.getServer().getOnlinePlayers()) + { + if (!ess.getUser(p).isAuthorized("essentials.vanish.see")) + { + p.hidePlayer(getBase()); + } + } setHidden(true); ess.getVanishedPlayers().add(getName()); } else { + for (Player p : ess.getServer().getOnlinePlayers()) + { + p.showPlayer(getBase()); + } setHidden(false); ess.getVanishedPlayers().remove(getName()); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java index b1e033b46..2dd0f4ebd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java @@ -16,25 +16,14 @@ public class Commandvanish extends EssentialsCommand @Override protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { - if (user.isVanished()) + user.toggleVanished(); + if (!user.isVanished()) { - for (Player p : server.getOnlinePlayers()) - { - p.showPlayer(user); - } - user.sendMessage(_("vanished")); + user.sendMessage(_("unvanished")); } else { - for (Player p : server.getOnlinePlayers()) - { - if (!ess.getUser(p).isAuthorized("essentials.vanish.see")) - { - p.hidePlayer(user); - } - user.sendMessage(_("unvanished")); - } + user.sendMessage(_("vanished")); } - user.toggleVanished(); } } -- cgit v1.2.3