diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 69c9fafed..e15d39e02 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -66,13 +66,11 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPluginLoader; -import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitTask; import org.yaml.snakeyaml.error.YAMLException; import java.io.File; -import java.io.FileReader; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -101,7 +99,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { private transient I18n i18n; private transient Metrics metrics; private transient EssentialsTimer timer; - private final transient List vanishedPlayers = new ArrayList<>(); + private final transient Set vanishedPlayers = new LinkedHashSet<>(); private transient Method oldGetOnlinePlayers; private transient SpawnerProvider spawnerProvider; private transient SpawnEggProvider spawnEggProvider; @@ -820,6 +818,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials { @Override public List getVanishedPlayers() { + return Collections.unmodifiableList(new ArrayList<>(vanishedPlayers)); + } + + @Override + public Collection getVanishedPlayersNew() { return vanishedPlayers; } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 86b31f6aa..641c79306 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -233,11 +233,14 @@ public class EssentialsPlayerListener implements Listener { user.setDisplayNick(); updateCompass(user); - if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see")) { - for (String p : ess.getVanishedPlayers()) { + if (!ess.getVanishedPlayersNew().isEmpty() && !user.isAuthorized("essentials.vanish.see")) { + for (String p : ess.getVanishedPlayersNew()) { Player toVanish = ess.getServer().getPlayerExact(p); if (toVanish != null && toVanish.isOnline()) { user.getBase().hidePlayer(toVanish); + if (ess.getSettings().isDebug()) { + ess.getLogger().info("Hiding vanished player: " + p); + } } } } diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index 31a31808e..216f3ce94 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -95,6 +95,7 @@ public interface IEssentials extends Plugin { EssentialsTimer getTimer(); + @Deprecated List getVanishedPlayers(); Collection getOnlinePlayers(); diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index a3213b595..1d58000f8 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -715,7 +715,7 @@ public class User extends UserData implements Comparable, IMessageRecipien } } setHidden(true); - ess.getVanishedPlayers().add(getName()); + ess.getVanishedPlayersNew().add(getName()); if (isAuthorized("essentials.vanish.effect")) { this.getBase().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false)); } @@ -724,7 +724,7 @@ public class User extends UserData implements Comparable, IMessageRecipien p.showPlayer(getBase()); } setHidden(false); - ess.getVanishedPlayers().remove(getName()); + ess.getVanishedPlayersNew().remove(getName()); if (isAuthorized("essentials.vanish.effect")) { this.getBase().removePotionEffect(PotionEffectType.INVISIBILITY); } diff --git a/Essentials/src/net/ess3/api/IEssentials.java b/Essentials/src/net/ess3/api/IEssentials.java index 3946d0f0e..1e76dda17 100644 --- a/Essentials/src/net/ess3/api/IEssentials.java +++ b/Essentials/src/net/ess3/api/IEssentials.java @@ -3,8 +3,12 @@ package net.ess3.api; import net.ess3.nms.PotionMetaProvider; import net.ess3.nms.SpawnEggProvider; +import java.util.Collection; + public interface IEssentials extends com.earth2me.essentials.IEssentials { + Collection getVanishedPlayersNew(); + SpawnEggProvider getSpawnEggProvider(); PotionMetaProvider getPotionMetaProvider();