001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.events;
020
021import com.plotsquared.core.plot.Plot;
022import com.plotsquared.core.plot.PlotArea;
023import org.checkerframework.checker.nullness.qual.NonNull;
024
025/**
026 * Event called when several merged plots are unlinked
027 * {@inheritDoc}
028 */
029public final class PlotUnlinkEvent extends PlotEvent implements CancellablePlotEvent {
030
031    private final PlotArea area;
032    boolean createRoad;
033    boolean createSign;
034    REASON reason;
035    private Result eventResult = Result.ACCEPT;
036
037    /**
038     * PlotUnlinkEvent: Called when a mega plot is unlinked
039     *
040     * @param area       The applicable plot area
041     * @param plot       The plot being unlinked from
042     * @param createRoad Whether to regenerate the road
043     * @param createSign Whether to regenerate signs
044     * @param reason     The {@link REASON} for the unlink
045     */
046    public PlotUnlinkEvent(
047            final @NonNull PlotArea area, Plot plot, boolean createRoad,
048            boolean createSign, REASON reason
049    ) {
050        super(plot);
051        this.area = area;
052        this.createRoad = createRoad;
053        this.createSign = createSign;
054        this.reason = reason;
055    }
056
057    @Override
058    public Result getEventResult() {
059        return eventResult;
060    }
061
062    @Override
063    public void setEventResult(Result e) {
064        this.eventResult = e;
065    }
066
067    public PlotArea getArea() {
068        return this.area;
069    }
070
071    public boolean isCreateRoad() {
072        return this.createRoad;
073    }
074
075    public void setCreateRoad(boolean createRoad) {
076        this.createRoad = createRoad;
077    }
078
079    public boolean isCreateSign() {
080        return this.createSign;
081    }
082
083    public void setCreateSign(boolean createSign) {
084        this.createSign = createSign;
085    }
086
087    public REASON getReason() {
088        return this.reason;
089    }
090
091    public enum REASON {
092        NEW_OWNER,
093        PLAYER_COMMAND,
094        CLEAR,
095        DELETE,
096        EXPIRE_DELETE
097    }
098
099}