use of org.spongepowered.common.entity.player.ClientType in project SpongeCommon by SpongePowered.
the class SpongeChannelManager method handleClientType.
private void handleClientType(final EngineConnection connection, final ChannelBuf payload) {
final ClientType clientType = ClientType.from(payload.readString());
if (clientType == null) {
// TODO This shouldn't happen...what do? Terminate them?
return;
}
((ConnectionBridge) ((ServerLoginPacketListenerImpl) connection).connection).bridge$setClientType(clientType);
}
use of org.spongepowered.common.entity.player.ClientType in project SpongeCommon by SpongePowered.
the class SpongeChannelManager method handleLoginRequestPayload.
private boolean handleLoginRequestPayload(final EngineConnection connection, final ResourceKey channelKey, final int transactionId, final ChannelBuf payload) {
if (channelKey.equals(Constants.Channels.SPONGE_CLIENT_TYPE)) {
final ClientType clientType = ((MinecraftBridge) Sponge.client()).bridge$getClientType();
final ChannelBuf responsePayload = this.bufferAllocator.buffer();
responsePayload.writeString(clientType.getName());
final Packet<?> mcPacket = PacketUtil.createLoginPayloadResponse(responsePayload, transactionId);
PacketSender.sendTo(connection, mcPacket);
return true;
}
if (channelKey.equals(Constants.Channels.SPONGE_CHANNEL_REGISTRY)) {
this.handleChannelRegistry(connection, payload);
// Respond with registered channels
final ChannelBuf responsePayload = this.encodeChannelRegistry();
final Packet<?> mcPacket = PacketUtil.createLoginPayloadResponse(responsePayload, transactionId);
PacketSender.sendTo(connection, mcPacket);
return true;
}
ResourceKey actualChannelKey = channelKey;
ChannelBuf actualPayload = payload;
if (channelKey.equals(Constants.Channels.FML_LOGIN_WRAPPER_CHANNEL)) {
actualChannelKey = ResourceKey.resolve(payload.readString());
final int length = payload.readVarInt();
actualPayload = payload.readSlice(length);
}
final SpongeChannel channel = this.channels.get(actualChannelKey);
if (channel != null) {
channel.handleLoginRequestPayload(connection, transactionId, actualPayload);
return true;
}
return false;
}
Aggregations