Search in sources :

Example 1 with ClientPlaySessionHandler

use of com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler in project LimboAPI by Elytrium.

the class LoginListener method hookPlaySession.

@Subscribe
public void hookPlaySession(ServerConnectedEvent event) {
    ConnectedPlayer player = (ConnectedPlayer) event.getPlayer();
    MinecraftConnection connection = player.getConnection();
    connection.eventLoop().execute(() -> {
        if (!(connection.getSessionHandler() instanceof ClientPlaySessionHandler)) {
            ClientPlaySessionHandler playHandler = new ClientPlaySessionHandler(this.server, player);
            try {
                spawned.set(playHandler, this.plugin.isLimboJoined(player));
            } catch (IllegalAccessException ex) {
                this.plugin.getLogger().error("Exception while hooking into ClientPlaySessionHandler of {}", player, ex);
            }
            connection.setSessionHandler(playHandler);
        }
    });
}
Also used : ClientPlaySessionHandler(com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler) ClosedMinecraftConnection(net.elytrium.limboapi.injection.dummy.ClosedMinecraftConnection) MinecraftConnection(com.velocitypowered.proxy.connection.MinecraftConnection) ConnectedPlayer(com.velocitypowered.proxy.connection.client.ConnectedPlayer) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

Subscribe (com.velocitypowered.api.event.Subscribe)1 MinecraftConnection (com.velocitypowered.proxy.connection.MinecraftConnection)1 ClientPlaySessionHandler (com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler)1 ConnectedPlayer (com.velocitypowered.proxy.connection.client.ConnectedPlayer)1 ClosedMinecraftConnection (net.elytrium.limboapi.injection.dummy.ClosedMinecraftConnection)1