Search in sources :

Example 1 with ResourcePacksInfoPacket

use of org.dragonet.protocol.packets.ResourcePacksInfoPacket in project DragonProxy by DragonetMC.

the class UpstreamSession method onLogin.

public void onLogin(LoginPacket packet) {
    if (username != null) {
        disconnect("Already logged in, this must be an error! ");
        return;
    }
    getDataCache().put(CacheKey.PACKET_LOGIN_PACKET, packet);
    PlayStatusPacket status = new PlayStatusPacket();
    proxy.getLogger().debug("CLIENT PROTOCOL = " + packet.protocol);
    if (packet.protocol != ProtocolInfo.CURRENT_PROTOCOL) {
        status.status = PlayStatusPacket.LOGIN_FAILED_CLIENT;
        sendPacket(status, true);
        disconnect(proxy.getLang().get(Lang.MESSAGE_UNSUPPORTED_CLIENT));
        return;
    }
    // Get the profile and read out the username!
    profile = packet.decoded;
    // Verify the integrity of the LoginPacket
    if (proxy.getConfig().authenticate_players && !packet.decoded.isLoginVerified()) {
        status.status = PlayStatusPacket.LOGIN_FAILED_INVALID_TENANT;
        sendPacket(status, true);
        disconnect(proxy.getLang().get(Lang.LOGIN_VERIFY_FAILED));
        return;
    }
    status.status = PlayStatusPacket.LOGIN_SUCCESS;
    sendPacket(status, true);
    this.username = profile.username;
    // Okay @dktapps ;)
    sendPacket(new ResourcePacksInfoPacket(), true);
    PlayerLoginEvent loginEvent = new PlayerLoginEvent(this);
    proxy.getEventManager().callEvent(loginEvent);
// now wait for response
}
Also used : PlayStatusPacket(org.dragonet.protocol.packets.PlayStatusPacket) PlayerLoginEvent(org.dragonet.proxy.events.defaults.player.PlayerLoginEvent) ResourcePacksInfoPacket(org.dragonet.protocol.packets.ResourcePacksInfoPacket)

Aggregations

PlayStatusPacket (org.dragonet.protocol.packets.PlayStatusPacket)1 ResourcePacksInfoPacket (org.dragonet.protocol.packets.ResourcePacksInfoPacket)1 PlayerLoginEvent (org.dragonet.proxy.events.defaults.player.PlayerLoginEvent)1