    001package co.aikar.commands;
    002
    003import net.md_5.bungee.api.connection.ProxiedPlayer;
    004import net.md_5.bungee.api.event.PlayerDisconnectEvent;
    005import net.md_5.bungee.api.event.PostLoginEvent;
    006import net.md_5.bungee.api.plugin.Listener;
    007import net.md_5.bungee.api.plugin.Plugin;
    008import net.md_5.bungee.event.EventHandler;
    009
    010import java.util.concurrent.TimeUnit;
    011
    012public class ACFBungeeListener implements Listener {
    013
    014    private final BungeeCommandManager manager;
    015    private final Plugin plugin;
    016
    017    public ACFBungeeListener(BungeeCommandManager manager, Plugin plugin) {
    018        this.manager = manager;
    019        this.plugin = plugin;
    020    }
    021
    022    @EventHandler
    023    public void onPlayerJoin(PostLoginEvent loginEvent) {
    024        ProxiedPlayer player = loginEvent.getPlayer();
    025
    026        //the client settings are sent after a successful login
    027        Runnable task = () -> manager.readLocale(player);
    028        plugin.getProxy().getScheduler().schedule(plugin, task, 1, TimeUnit.SECONDS);
    029    }
    030
    031    @EventHandler
    032    public void onDisconnect(PlayerDisconnectEvent disconnectEvent) {
    033        //cleanup
    034        ProxiedPlayer player = disconnectEvent.getPlayer();
    035        manager.issuersLocale.remove(player.getUniqueId());
    036    }
    037}