/*
 * This file is part of LanternServer, licensed under the MIT License (MIT).
 *
 * Copyright (c) LanternPowered <https://www.lanternpowered.org>
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the Software), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.lanternpowered.server.network.protocol;

import org.lanternpowered.server.network.forge.message.codec.handshake.CodecPlayInOutCustomPayload;
import org.lanternpowered.server.network.forge.message.codec.handshake.ProcessorForgeHandshakeOutRegistryData;
import org.lanternpowered.server.network.forge.message.handler.handshake.HandlerForgeHandshakeInAck;
import org.lanternpowered.server.network.forge.message.handler.handshake.HandlerForgeHandshakeInHello;
import org.lanternpowered.server.network.forge.message.handler.handshake.HandlerForgeHandshakeInModList;
import org.lanternpowered.server.network.forge.message.handler.handshake.HandlerForgeHandshakeInStart;
import org.lanternpowered.server.network.forge.message.type.handshake.MessageForgeHandshakeInOutAck;
import org.lanternpowered.server.network.forge.message.type.handshake.MessageForgeHandshakeInOutHello;
import org.lanternpowered.server.network.forge.message.type.handshake.MessageForgeHandshakeInOutModList;
import org.lanternpowered.server.network.forge.message.type.handshake.MessageForgeHandshakeInStart;
import org.lanternpowered.server.network.forge.message.type.handshake.MessageForgeHandshakeOutRegistryData;
import org.lanternpowered.server.network.forge.message.type.handshake.MessageForgeHandshakeOutReset;
import org.lanternpowered.server.network.message.CodecRegistration;
import org.lanternpowered.server.network.message.Message;
import org.lanternpowered.server.network.message.MessageRegistry;
import org.lanternpowered.server.network.vanilla.message.codec.connection.CodecInOutPing;
import org.lanternpowered.server.network.vanilla.message.codec.connection.CodecOutDisconnect;
import org.lanternpowered.server.network.vanilla.message.handler.play.HandlerPlayInChannelPayload;
import org.lanternpowered.server.network.vanilla.message.handler.play.HandlerPlayInRegisterChannels;
import org.lanternpowered.server.network.vanilla.message.handler.play.HandlerPlayInUnregisterChannels;
import org.lanternpowered.server.network.vanilla.message.type.connection.MessageInOutKeepAlive;
import org.lanternpowered.server.network.vanilla.message.type.connection.MessageOutDisconnect;
import org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInOutChannelPayload;
import org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInOutRegisterChannels;
import org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInOutUnregisterChannels;

/**
 * A custom protocol instance used to handle the forge handshake messages,
 * the protocol is basically just a limited play protocol version with all
 * the message types and processors needed for the forge handshake.
 */
final class ProtocolForgeHandshake extends ProtocolBase {

    ProtocolForgeHandshake() {
        final MessageRegistry inbound = inbound();
        final MessageRegistry outbound = outbound();

        inbound.bind(0x0c, CodecInOutPing.class, MessageInOutKeepAlive.class);
        final CodecRegistration<Message, CodecPlayInOutCustomPayload> codecPlayInCustomPayloadRegistration =
                inbound.bind(0x0a, CodecPlayInOutCustomPayload.class);
        codecPlayInCustomPayloadRegistration.bind(MessagePlayInOutChannelPayload.class)
                .bindHandler(new HandlerPlayInChannelPayload());
        codecPlayInCustomPayloadRegistration.bind(MessageForgeHandshakeInOutAck.class)
                .bindHandler(new HandlerForgeHandshakeInAck());
        codecPlayInCustomPayloadRegistration.bind(MessageForgeHandshakeInOutHello.class)
                .bindHandler(new HandlerForgeHandshakeInHello());
        codecPlayInCustomPayloadRegistration.bind(MessageForgeHandshakeInOutModList.class)
                .bindHandler(new HandlerForgeHandshakeInModList());
        codecPlayInCustomPayloadRegistration.bind(MessageForgeHandshakeInStart.class)
                .bindHandler(new HandlerForgeHandshakeInStart());
        codecPlayInCustomPayloadRegistration.bind(MessagePlayInOutRegisterChannels.class)
                .bindHandler(new HandlerPlayInRegisterChannels());
        codecPlayInCustomPayloadRegistration.bind(MessagePlayInOutUnregisterChannels.class)
                .bindHandler(new HandlerPlayInUnregisterChannels());

        outbound.bind(0x20, CodecInOutPing.class, MessageInOutKeepAlive.class);
        final CodecRegistration<Message, CodecPlayInOutCustomPayload> codecPlayOutCustomPayloadRegistration =
                outbound.bind(0x19, CodecPlayInOutCustomPayload.class);
        codecPlayOutCustomPayloadRegistration.bind(MessagePlayInOutChannelPayload.class);
        codecPlayOutCustomPayloadRegistration.bind(MessageForgeHandshakeInOutAck.class);
        codecPlayOutCustomPayloadRegistration.bind(MessageForgeHandshakeInOutHello.class);
        codecPlayOutCustomPayloadRegistration.bind(MessageForgeHandshakeInOutModList.class);
        codecPlayOutCustomPayloadRegistration.bind(MessageForgeHandshakeOutReset.class);
        codecPlayOutCustomPayloadRegistration.bind(MessagePlayInOutRegisterChannels.class);
        codecPlayOutCustomPayloadRegistration.bind(MessagePlayInOutUnregisterChannels.class);
        outbound.bind(0x1b, CodecOutDisconnect.class, MessageOutDisconnect.class);
        outbound.bindProcessor(MessageForgeHandshakeOutRegistryData.class, new ProcessorForgeHandshakeOutRegistryData());
    }
}

@@ -4221,17 +4221,17 @@
 bind(0x0
-c
+b
 , CodecI
@@ -4417,17 +4417,17 @@
 bind(0x0
-a
+9
 , CodecP
@@ -5573,10 +5573,10 @@
 d(0x
-20
+1f
 , Co
@@ -5768,17 +5768,17 @@
 bind(0x1
-9
+8
 , CodecP
@@ -6470,17 +6470,17 @@
 bind(0x1
-b
+a
 , CodecO

Fix the forge protocol message opcodes.