package pers.neige.neigeitems.event;

import lombok.NonNull;
import org.bukkit.event.HandlerList;

import java.util.UUID;

/**
 * 数据包接收事件.
 *
 * @property uuid   接收数据包的玩家 UUID
 * @property packet 发送的数据包
 */
public final class PacketReceiveEvent extends CancellableEvent {
    private static final HandlerList handlers = new HandlerList();
    private final @NonNull UUID uuid;
    private final @NonNull Object packet;

    /**
     * @param uuid   接收数据包的玩家 UUID
     * @param packet 发送的数据包
     */
    public PacketReceiveEvent(
        @NonNull UUID uuid,
        @NonNull Object packet
    ) {
        this.uuid = uuid;
        this.packet = packet;
    }

    public static @NonNull HandlerList getHandlerList() {
        return handlers;
    }

    /**
     * 获取发送数据包的玩家 UUID
     */
    public @NonNull UUID getUuid() {
        return uuid;
    }

    /**
     * 获取接收的数据包
     */
    public @NonNull Object getPacket() {
        return packet;
    }


    @Override
    public @NonNull HandlerList getHandlers() {
        return handlers;
    }
}
