diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index fe1edb4e5..60045464b 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -85,6 +85,7 @@ public class Essentials extends JavaPlugin implements IEssentials private transient I18n i18n; private transient Metrics metrics; private transient EssentialsTimer timer; + private transient List vanishedPlayers = new ArrayList(); @Override public ISettings getSettings() @@ -240,7 +241,7 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvents(tntListener, this); timer = new EssentialsTimer(this); - getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100); + getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100); Economy.setEss(this); execTimer.mark("RegListeners"); @@ -629,6 +630,12 @@ public class Essentials extends JavaPlugin implements IEssentials return timer; } + @Override + public List getVanishedPlayers() + { + return vanishedPlayers; + } + private static class EssentialsWorldListener implements Listener, Runnable { private transient final IEssentials ess; diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 4cb1d2e9e..551833fc0 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -114,6 +114,7 @@ public class EssentialsPlayerListener implements Listener { user.toggleGodModeEnabled(); } + ess.getVanishedPlayers().remove(user.getName()); user.setLastLocation(); user.updateActivity(false); user.dispose(); @@ -141,6 +142,14 @@ public class EssentialsPlayerListener implements Listener user.setLastLogin(System.currentTimeMillis()); user.updateActivity(false); + for (String p : ess.getVanishedPlayers()) + { + if (!user.isAuthorized("essentials.vanish.see")) + { + user.hidePlayer(ess.getUser(p)); + } + } + if (user.isAuthorized("essentials.sleepingignored")) { user.setSleepingIgnored(true); diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java index 0d97c2792..95cf77521 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java @@ -12,7 +12,7 @@ public class EssentialsTimer implements Runnable { private final transient IEssentials ess; private final transient Set onlineUsers = new HashSet(); - private transient long lastPoll = System.currentTimeMillis() - 3000; + private transient long lastPoll = System.currentTimeMillis(); private final transient LinkedList history = new LinkedList(); EssentialsTimer(final IEssentials ess) diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 6e1887b87..f12798db3 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.api.IJails; import com.earth2me.essentials.metrics.Metrics; import com.earth2me.essentials.perm.PermissionsHandler; import com.earth2me.essentials.register.payment.Methods; +import java.util.List; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -72,4 +73,6 @@ public interface IEssentials extends Plugin void setMetrics(Metrics metrics); EssentialsTimer getTimer(); + + List getVanishedPlayers(); } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index c6ce3a569..f9206206a 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -650,5 +650,13 @@ public class User extends UserData implements Comparable, IReplyTo, IUser public void toggleVanished() { vanished = !vanished; + if (vanished) + { + ess.getVanishedPlayers().add(getName()); + } + else + { + 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 96cf95e36..2c14f60ef 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java @@ -36,5 +36,6 @@ public class Commandvanish extends EssentialsCommand user.sendMessage(ChatColor.GREEN + _("unvanished")); } } + user.toggleVanished(); } }