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.post; 020 021import com.plotsquared.core.events.PlotPlayerEvent; 022import com.plotsquared.core.player.PlotPlayer; 023import com.plotsquared.core.plot.Plot; 024import org.checkerframework.checker.nullness.qual.Nullable; 025 026import java.util.UUID; 027 028/** 029 * Called after the owner of a plot was updated. 030 * 031 * @since 6.2.0 032 */ 033public class PostPlotChangeOwnerEvent extends PlotPlayerEvent { 034 035 @Nullable 036 private final UUID oldOwner; 037 038 /** 039 * Instantiate a new PlotChangedOwnerEvent. 040 * 041 * @param initiator The player who executed the owner change. 042 * @param plot The plot which owner was changed. 043 * @param oldOwner The previous owner - if present, otherwise {@code null}. 044 */ 045 public PostPlotChangeOwnerEvent(final PlotPlayer<?> initiator, final Plot plot, @Nullable UUID oldOwner) { 046 super(initiator, plot); 047 this.oldOwner = oldOwner; 048 } 049 050 /** 051 * @return the old owner of the plot - if present, otherwise {@code null}. 052 */ 053 public @Nullable UUID getOldOwner() { 054 return oldOwner; 055 } 056 057 /** 058 * @return {@code true} if the plot had an owner, {@code false} otherwise. 059 * @see #getOldOwner() 060 */ 061 public boolean hasOldOwner() { 062 return getOldOwner() != null; 063 } 064 065 /** 066 * @return {@code true} if the plot now has an owner, {@code false} otherwise. 067 * @see Plot#hasOwner() 068 */ 069 public boolean hasNewOwner() { 070 return getPlot().hasOwner(); 071 } 072 073}