use of org.spongepowered.common.network.channel.SpongeChannelManager in project SpongeCommon by SpongePowered.
the class ServerLoginPacketListenerImplMixin_Vanilla method impl$onTick.
@Inject(method = "tick", at = @At("HEAD"))
private void impl$onTick(final CallbackInfo ci) {
if (this.state == ServerLoginPacketListenerImpl.State.NEGOTIATING) {
final ServerSideConnection connection = (ServerSideConnection) this;
if (this.impl$handshakeState == ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_NOT_STARTED) {
this.impl$handshakeState = ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_CLIENT_TYPE;
((SpongeChannelManager) Sponge.channelManager()).requestClientType(connection).thenAccept(result -> {
this.impl$handshakeState = ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_SYNC_CHANNEL_REGISTRATIONS;
});
} else if (this.impl$handshakeState == ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_SYNC_CHANNEL_REGISTRATIONS) {
((SpongeChannelManager) Sponge.channelManager()).sendLoginChannelRegistry(connection).thenAccept(result -> {
final Cause cause = Cause.of(EventContext.empty(), this);
final ServerSideConnectionEvent.Handshake event = SpongeEventFactory.createServerSideConnectionEventHandshake(cause, connection);
SpongeCommon.post(event);
this.impl$handshakeState = ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_SYNC_PLUGIN_DATA;
});
} else if (this.impl$handshakeState == ServerLoginPacketListenerImplMixin_Vanilla.HANDSHAKE_SYNC_PLUGIN_DATA) {
final TransactionStore store = ConnectionUtil.getTransactionStore(connection);
if (store.isEmpty()) {
this.state = ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT;
}
}
}
}
Aggregations