package fr.quark.factions.events;

import fr.quark.factions.entity.FFaction;
import fr.quark.factions.entity.FPlayer;
import fr.quark.factions.map.FLocation;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

/**
 * This event is fired when a faction lose a territory.
 */
public class FactionLoseTerritory extends FactionEvent implements Cancellable {

    private static final HandlerList handlers = new HandlerList();

    private final FPlayer player;
    private final FLocation location;
    private final Reason reason;
    private boolean cancelled;

    public FactionLoseTerritory(FFaction faction, FLocation location, FPlayer player, Reason reason, boolean async) {
        super(faction, async);
        this.player = player;
        this.location = location;
        this.reason = reason;
    }

    public FactionLoseTerritory(FFaction faction, FLocation location, FPlayer player, Reason reason) {
        this(faction, location, player, reason, false);
    }

    public static HandlerList getHandlerList() {
        return handlers;
    }

    public FPlayer getPlayer() {
        return player;
    }

    public FLocation getLocation() {
        return location;
    }

    public Reason getReason() {
        return reason;
    }

    @Override
    public boolean isCancelled() {
        return cancelled;
    }

    @Override
    public void setCancelled(boolean value) {
        this.cancelled = value;
    }

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

    public enum Reason {
        UNCLAIM,
        UNCLAIM_ALL,
        FACTION_CONQUERED,
        OTHER
    }
}
