// Generated by delombok at Tue Dec 16 19:35:15 UTC 2025
package net.md_5.bungee.protocol.packet;

import io.netty.buffer.ByteBuf;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.ProtocolConstants;

public class SystemChat extends DefinedPacket {
    private BaseComponent message;
    private int position;

    @Override
    public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
        message = readBaseComponent(buf, 262144, protocolVersion);
        position = (protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1) ? ((buf.readBoolean()) ? ChatMessageType.ACTION_BAR.ordinal() : 0) : readVarInt(buf);
    }

    @Override
    public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
        writeBaseComponent(message, buf, protocolVersion);
        if (protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1) {
            buf.writeBoolean(position == ChatMessageType.ACTION_BAR.ordinal());
        } else {
            writeVarInt(position, buf);
        }
    }

    @Override
    public void handle(AbstractPacketHandler handler) throws Exception {
        handler.handle(this);
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public BaseComponent getMessage() {
        return this.message;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public int getPosition() {
        return this.position;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public void setMessage(final BaseComponent message) {
        this.message = message;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public void setPosition(final int position) {
        this.position = position;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public java.lang.String toString() {
        return "SystemChat(message=" + this.getMessage() + ", position=" + this.getPosition() + ")";
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public SystemChat() {
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public SystemChat(final BaseComponent message, final int position) {
        this.message = message;
        this.position = position;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public boolean equals(final java.lang.Object o) {
        if (o == this) return true;
        if (!(o instanceof SystemChat)) return false;
        final SystemChat other = (SystemChat) o;
        if (!other.canEqual((java.lang.Object) this)) return false;
        if (this.getPosition() != other.getPosition()) return false;
        final java.lang.Object this$message = this.getMessage();
        final java.lang.Object other$message = other.getMessage();
        if (this$message == null ? other$message != null : !this$message.equals(other$message)) return false;
        return true;
    }

    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    protected boolean canEqual(final java.lang.Object other) {
        return other instanceof SystemChat;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    @lombok.Generated
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        result = result * PRIME + this.getPosition();
        final java.lang.Object $message = this.getMessage();
        result = result * PRIME + ($message == null ? 43 : $message.hashCode());
        return result;
    }
}
