// Path: src/main/java/net/techcable/spudcompat/protocol/PlayerConnection.java
// public interface PlayerConnection {
// 
//     public default boolean isSupportedVersion() {
//         return ProtocolVersion.getById(getVersionId()) != null;
//     }
// 
//     public default ProtocolVersion getVersion() {
//         int id = getVersionId();
//         ProtocolVersion version = ProtocolVersion.getById(id);
//         if (version != null) {
//             return version;
//         } else {
//             throw new IllegalStateException("Unsupported version: " + id);
//         }
//     }
// 
//     public ProtocolState getState();
// 
//     public int getVersionId();
// 
//     public void sendPacket(RawPacket rawPacket);
// 
//     public Channel getChannel();
// 
//     public Server getServer();
// }
// 
// Path: src/main/java/net/techcable/spudcompat/protocol/ProtocolDirection.java
// public enum ProtocolDirection {
//     CLIENTBOUND(ProtocolConstants.Direction.TO_CLIENT),
//     SERVERBOUND(ProtocolConstants.Direction.TO_SERVER);
// 
//     private ProtocolDirection(ProtocolConstants.Direction bungee) {
//         this.bungee = checkNotNull(bungee, "Null bungee direction");
//     }
// 
//     private final ProtocolConstants.Direction bungee;
// 
//     public ProtocolConstants.Direction asBungee() {
//         return bungee;
//     }
// }


import lombok.*;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.PacketWrapper;
import net.techcable.spudcompat.protocol.PlayerConnection;
import net.techcable.spudcompat.protocol.ProtocolDirection;
package net.techcable.spudcompat.protocol.injector;





@RequiredArgsConstructor
public class BungeeProtocolInjector implements Listener {
    private final PacketListener listener;

    public static final String SPUD_INCOMING_TRANSFORMER = "spud-incoming-transformer";
    public static final String SPUD_OUTGOING_TRANSFORMER = "spud-outgoing-transformer";

    @EventHandler
    public void onPostLogin(PostLoginEvent event) {
// Path: src/main/java/net/techcable/spudcompat/protocol/PlayerConnection.java
// public interface PlayerConnection {
// 
//     public default boolean isSupportedVersion() {
//         return ProtocolVersion.getById(getVersionId()) != null;
//     }
// 
//     public default ProtocolVersion getVersion() {
//         int id = getVersionId();
//         ProtocolVersion version = ProtocolVersion.getById(id);
//         if (version != null) {
//             return version;
//         } else {
//             throw new IllegalStateException("Unsupported version: " + id);
//         }
//     }
// 
//     public ProtocolState getState();
// 
//     public int getVersionId();
// 
//     public void sendPacket(RawPacket rawPacket);
// 
//     public Channel getChannel();
// 
//     public Server getServer();
// }
// 
// Path: src/main/java/net/techcable/spudcompat/protocol/ProtocolDirection.java
// public enum ProtocolDirection {
//     CLIENTBOUND(ProtocolConstants.Direction.TO_CLIENT),
//     SERVERBOUND(ProtocolConstants.Direction.TO_SERVER);
// 
//     private ProtocolDirection(ProtocolConstants.Direction bungee) {
//         this.bungee = checkNotNull(bungee, "Null bungee direction");
//     }
// 
//     private final ProtocolConstants.Direction bungee;
// 
//     public ProtocolConstants.Direction asBungee() {
//         return bungee;
//     }
// }


// Path: src/main/java/net/techcable/spudcompat/protocol/injector/BungeeProtocolInjector.java
import lombok.*;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.PacketWrapper;
import net.techcable.spudcompat.protocol.PlayerConnection;
import net.techcable.spudcompat.protocol.ProtocolDirection;

package net.techcable.spudcompat.protocol.injector;





@RequiredArgsConstructor
public class BungeeProtocolInjector implements Listener {
    private final PacketListener listener;

    public static final String SPUD_INCOMING_TRANSFORMER = "spud-incoming-transformer";
    public static final String SPUD_OUTGOING_TRANSFORMER = "spud-outgoing-transformer";

    @EventHandler
    public void onPostLogin(PostLoginEvent event) {
        PlayerConnection connection = new UserConnectionPlayerConnection((UserConnection) event.getPlayer());