package net.thenextlvl.worlds.event;

import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.world.WorldEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;

/**
 * Represents an event triggered when a {@link World} is deleted.
 * This event allows developers to listen to or cancel the deletion of a world.
 *
 * @see WorldActionScheduledEvent
 * @since 4.0.0
 */
public final class WorldDeleteEvent extends WorldEvent implements Cancellable {
    private static final HandlerList handlerList = new HandlerList();

    private boolean cancelled = false;

    @ApiStatus.Internal
    public WorldDeleteEvent(final World world) {
        super(world, false);
    }

    @Override
    @Contract(pure = true)
    public boolean isCancelled() {
        return this.cancelled;
    }

    @Override
    @Contract(mutates = "this")
    public void setCancelled(final boolean cancel) {
        this.cancelled = cancel;
    }

    @Override
    public HandlerList getHandlers() {
        return handlerList;
    }

    public static HandlerList getHandlerList() {
        return handlerList;
    }
}
