package uk.co.drnaylor.minecraft.hammer.sponge.listeners;

import org.spongepowered.api.event.Subscribe;
import org.spongepowered.api.event.network.PlayerConnectionEvent;
import uk.co.drnaylor.minecraft.hammer.sponge.HammerSponge;

import java.util.UUID;

public class PlayerConnectListener {

    private final HammerSponge plugin;

    public PlayerConnectListener(HammerSponge plugin) {
        this.plugin = plugin;
    }

    @Subscribe
    public void onPlayerConnection(PlayerConnectionEvent event) {
        UUID playerId = event.getConnection().getPlayer().getUniqueId();

    }
}

@@ -63,173 +63,829 @@
 ort 
-org.spongepowered.api.event.Subscribe;%0Aimport org.spongepowered.api.event.network.PlayerConnectionEvent;%0Aimport uk.co.drnaylor.minecraft.hammer.sponge.HammerSponge;%0A
+com.google.common.base.Optional;%0Aimport org.slf4j.Logger;%0Aimport org.spongepowered.api.Game;%0Aimport org.spongepowered.api.entity.player.Player;%0Aimport org.spongepowered.api.event.Subscribe;%0Aimport org.spongepowered.api.event.network.PlayerConnectionEvent;%0Aimport org.spongepowered.api.service.ban.BanService;%0Aimport org.spongepowered.api.text.Texts;%0Aimport org.spongepowered.api.util.ban.Ban;%0Aimport org.spongepowered.api.util.ban.Bans;%0Aimport uk.co.drnaylor.minecraft.hammer.core.data.HammerBan;%0Aimport uk.co.drnaylor.minecraft.hammer.core.data.HammerPlayerBan;%0Aimport uk.co.drnaylor.minecraft.hammer.core.exceptions.HammerException;%0Aimport uk.co.drnaylor.minecraft.hammer.core.listenercores.PlayerConnectListenerCore;%0Aimport uk.co.drnaylor.minecraft.hammer.sponge.text.HammerTextConverter;%0A%0Aimport java.util.Collection;
 %0Aimp
@@ -965,277 +965,1612 @@
 nal 
-HammerSponge plugin;%0A%0A    public PlayerConnectListener(HammerSponge plugin) %7B%0A        this.plugin = plugin;%0A    %7D%0A%0A    @Subscribe%0A    public void onPlayerConnection(PlayerConnectionEvent event) %7B%0A        UUID playerId = event.getConnection().getPlayer().getUniqueId();%0A
+Game game;%0A    private final PlayerConnectListenerCore eventCore;%0A    private final Logger logger;%0A%0A    public PlayerConnectListener(Logger logger, Game game, PlayerConnectListenerCore eventCore) %7B%0A        this.logger = logger;%0A        this.game = game;%0A        this.eventCore = eventCore;%0A    %7D%0A%0A    @Subscribe%0A    public void onPlayerConnection(PlayerConnectionEvent event) %7B%0A        try %7B%0A            Player pl = event.getConnection().getPlayer();%0A            UUID uuid = pl.getUniqueId();%0A            String host = event.getConnection().getAddress().getAddress().getHostAddress();%0A%0A            HammerBan ban = eventCore.getBan(uuid, host);%0A            if (ban == null) %7B%0A                Optional%3CBanService%3E service = game.getServiceManager().provide(BanService.class);%0A                service.get().pardon(pl);%0A                return;%0A            %7D%0A%0A            // Set their ban on the server too - in case Hammer goes down.%0A            if (ban instanceof HammerPlayerBan) %7B%0A                BanService service = game.getServiceManager().provide(BanService.class).get();%0A                Collection%3CBan.User%3E bans = service.getBansFor(pl);%0A%0A                if (bans.isEmpty()) %7B%0A                    service.ban(Bans.of(pl, Texts.of(ban.getReason())));%0A                %7D%0A            %7D%0A%0A            event.getConnection().getPlayer().kick(HammerTextConverter.constructMessage(eventCore.constructBanMessage(ban)));%0A        %7D catch (HammerException e) %7B%0A            logger.error(%22Connection to the MySQL database failed. Falling back to the Minecraft ban list.%22);%0A            e.printStackTrace();%0A        %7D
 %0A   

Update Sponge player connection listener.