package fr.noogotte.useful_commands.component;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import fr.aumgn.bukkitutils.command.Commands;
import fr.noogotte.useful_commands.UsefulCommandsPlugin;
import fr.noogotte.useful_commands.command.VanishCommand;

public class VanishComponent extends Component implements Listener {

	private final Set<Player> vanish;
	
	public VanishComponent(UsefulCommandsPlugin plugin) {
		super(plugin);
		vanish = new HashSet<Player>();
		Bukkit.getPluginManager().registerEvents(this, plugin);
	}

	@Override
	public String getName() {
		return "vanish";
	}
	
	@Override
    public List<Commands> getCommands() {
        return Collections.<Commands>singletonList(new VanishCommand(this));
    }
	
	public void addPlayer(Player player) {
		vanish.add(player);
	}
	
	public void removePlayer(Player player) {
		vanish.remove(player);
	}
	
	public boolean isVanish(Player player) {
		return vanish.contains(player);
	}
	
	@EventHandler
	public void onPlayerJoin(PlayerJoinEvent event) {
		if(vanish.isEmpty()) {
			return;
		}
		
		event.getPlayer().hidePlayer(vanish.iterator().next().getPlayer());
	}
}

@@ -1400,61 +1400,385 @@
 %0D%0A%09%09
-event.getPlayer().hidePlayer(vanish.iterator().next()
+for (Player vanishPlayer : vanish) %7B%0D%0A%09%09%09event.getPlayer().hidePlayer(vanishPlayer);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09@EventHandler%0D%0A%09public void onPlayerQuit(PlayerQuitEvent event) %7B%0D%0A%09%09if(vanish.isEmpty()) %7B%0D%0A%09%09%09return;%0D%0A%09%09%7D%0D%0A%0D%0A%09%09if(isVanish(event.getPlayer())) %7B%0D%0A%09%09%09vanish.remove(event.getPlayer());%0D%0A%09%09%09for(Player onlinePlayer : Bukkit.getOnlinePlayers()) %7B%0D%0A%09%09%09%09onlinePlayer.showPlayer(event
 .get
@@ -1785,19 +1785,30 @@
 Player());%0D%0A
+%09%09%09%7D%0D%0A%09%09%7D%0D%0A
 %09%7D%0D%0A%7D%0D%0A

Fix vanish command.