use of org.lanternpowered.server.network.forge.message.type.handshake.MessageForgeHandshakeInStart in project LanternServer by LanternPowered.
the class HandlerLoginFinish method handle.
@Override
public void handle(NetworkContext context, MessageLoginInFinish message) {
final LanternGameProfile gameProfile = message.getGameProfile();
final NetworkSession session = context.getSession();
int compressionThreshold = Lantern.getGame().getGlobalConfig().getNetworkCompressionThreshold();
if (compressionThreshold != -1) {
session.sendWithFuture(new MessageLoginOutSetCompression(compressionThreshold)).addListener(future -> context.getChannel().pipeline().replace(NetworkSession.COMPRESSION, NetworkSession.COMPRESSION, new MessageCompressionHandler(compressionThreshold)));
} else {
// Remove the compression handler placeholder
context.getChannel().pipeline().remove(NetworkSession.COMPRESSION);
}
final GameProfileCache gameProfileCache = Lantern.getGame().getGameProfileManager().getCache();
// Store the old profile temporarily
gameProfileCache.getById(gameProfile.getUniqueId()).ifPresent(profile -> context.getChannel().attr(NetworkSession.PREVIOUS_GAME_PROFILE).set(profile));
// Cache the new profile
gameProfileCache.add(gameProfile, true, (Instant) null);
session.sendWithFuture(new MessageLoginOutSuccess(gameProfile.getUniqueId(), gameProfile.getName().get())).addListener(future -> {
session.setGameProfile(gameProfile);
session.setProtocolState(ProtocolState.FORGE_HANDSHAKE);
session.messageReceived(new MessageForgeHandshakeInStart());
});
}
Aggregations