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.location.Location;
022import com.plotsquared.core.player.PlotPlayer;
023import com.plotsquared.core.plot.Plot;
024
025/**
026 * Called when a player teleports to a plot
027 */
028public class PlayerTeleportToPlotEvent extends PlotPlayerEvent implements CancellablePlotEvent {
029
030    private final Location from;
031    private final TeleportCause cause;
032    private Result eventResult;
033
034    /**
035     * @deprecated use {@link PlayerTeleportToPlotEvent#PlayerTeleportToPlotEvent(PlotPlayer, Location, Plot, TeleportCause)}.
036     * You should not be creating events in the first place.
037     */
038    @Deprecated(forRemoval = true, since = "6.1.0")
039    public PlayerTeleportToPlotEvent(PlotPlayer<?> player, Location from, Plot plot) {
040        this(player, from, plot, TeleportCause.UNKNOWN);
041    }
042
043    /**
044     * PlayerTeleportToPlotEvent: Called when a player teleports to a plot
045     *
046     * @param player That was teleported
047     * @param from   Start location
048     * @param plot   Plot to which the player was teleported
049     * @param cause  Why the teleport is being completed
050     * @since 6.1.0
051     */
052    public PlayerTeleportToPlotEvent(PlotPlayer<?> player, Location from, Plot plot, TeleportCause cause) {
053        super(player, plot);
054        this.from = from;
055        this.cause = cause;
056    }
057
058    /**
059     * Get the teleport cause
060     *
061     * @return TeleportCause
062     * @since 6.1.0
063     */
064    public TeleportCause getCause() {
065        return cause;
066    }
067
068    /**
069     * Get the from location
070     *
071     * @return Location
072     */
073    public Location getFrom() {
074        return this.from;
075    }
076
077    @Override
078    public Result getEventResult() {
079        return eventResult;
080    }
081
082    @Override
083    public void setEventResult(Result e) {
084        this.eventResult = e;
085    }
086
087}