package com.hypixel.hytale.server.core.event.events.ecs;

import com.hypixel.hytale.component.system.CancellableEcsEvent;

/**
 * Fired when a player changes their active hotbar slot.
 */
public class ChangeHotbarSlotEvent extends CancellableEcsEvent {
    private final byte previousSlot;
    private byte newSlot;
    private final boolean serverRequest;

    public ChangeHotbarSlotEvent(byte previousSlot, byte newSlot, boolean serverRequest) {
        this.previousSlot = previousSlot;
        this.newSlot = newSlot;
        this.serverRequest = serverRequest;
    }

    public byte getPreviousSlot() {
        return previousSlot;
    }

    public byte getNewSlot() {
        return newSlot;
    }

    public void setNewSlot(byte newSlot) {
        this.newSlot = newSlot;
    }

    public boolean isServerRequest() {
        return serverRequest;
    }

    public boolean isClientRequest() {
        return !serverRequest;
    }

    @Override
    public String toString() {
        return "ChangeHotbarSlotEvent{previousSlot=" + previousSlot + ", newSlot=" + newSlot + ", serverRequest=" + serverRequest + "}";
    }
}
