    001package co.aikar.commands;
    002
    003import org.spongepowered.api.entity.living.player.Player;
    004import org.spongepowered.api.event.Listener;
    005import org.spongepowered.api.event.Order;
    006import org.spongepowered.api.event.entity.living.humanoid.player.PlayerChangeClientSettingsEvent;
    007import org.spongepowered.api.event.filter.cause.First;
    008import org.spongepowered.api.event.network.ClientConnectionEvent;
    009
    010public class ACFSpongeListener {
    011
    012    private final SpongeCommandManager manager;
    013
    014    public ACFSpongeListener(SpongeCommandManager manager) {
    015        this.manager = manager;
    016    }
    017
    018    @Listener(order = Order.POST)
    019    public void onSettingsChange(PlayerChangeClientSettingsEvent changeSettingsEvent, @First Player targetPlayer) {
    020        //this event will be fired on join as well as every time the player changes it
    021        manager.setIssuerLocale(targetPlayer, targetPlayer.getLocale());
    022    }
    023
    024    @Listener
    025    public void onDisconnectCleanup(ClientConnectionEvent.Disconnect disconnectEvent, @First Player player) {
    026        manager.issuersLocale.remove(player.getUniqueId());
    027    }
    028}