use of org.lanternpowered.server.network.forge.handshake.ForgeClientHandshakePhase in project LanternServer by LanternPowered.
the class CodecPlayInOutCustomPayload method decode0.
@Override
protected Message decode0(CodecContext context, String channel, ByteBuffer content) throws CodecException {
if ("FML|HS".equals(channel)) {
int type = content.readByte();
switch(type) {
case FML_HANDSHAKE_RESET:
// server -> client message: ignore
break;
case FML_HANDSHAKE_ACK:
ForgeClientHandshakePhase phase = ForgeClientHandshakePhase.values()[content.readByte()];
return new MessageForgeHandshakeInOutAck(phase);
case FML_HANDSHAKE_SERVER_HELLO:
// server -> client message: ignore
break;
case FML_HANDSHAKE_CLIENT_HELLO:
// The forge protocol version on the client
content.readByte();
return new MessageForgeHandshakeInOutHello();
case FML_HANDSHAKE_MOD_LIST:
int size = content.readVarInt();
Map<String, String> entries = Maps.newHashMapWithExpectedSize(size);
for (int i = 0; i < size; i++) {
entries.put(content.readString(), content.readString());
}
return new MessageForgeHandshakeInOutModList(entries);
case FML_HANDSHAKE_REGISTRY_DATA:
// server -> client message: ignore
break;
default:
throw new DecoderException("Unknown forge handshake message with opcode: " + type);
}
throw new DecoderException("Received an unexpected forge message with opcode: " + type);
} else {
throw new DecoderException("Received an unexpected message with channel: " + channel);
}
}
Aggregations