mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Add PlotChangeOwner Event
This commit is contained in:
@ -0,0 +1,107 @@
|
||||
package com.plotsquared.bukkit.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player initiator;
|
||||
private final UUID newOwner;
|
||||
private final UUID oldOwner;
|
||||
private boolean hasOldOwner;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlotChangeOwnerEvent: Called when a plot's owner is change.
|
||||
*
|
||||
* @param newOwner The new owner of the plot
|
||||
* @param oldOwner The old owner of the plot
|
||||
* @param plot The plot having its owner changed
|
||||
*/
|
||||
public PlotChangeOwnerEvent(Player initiator, Plot plot, UUID oldOwner, UUID newOwner, boolean hasOldOwner) {
|
||||
super(plot);
|
||||
this.initiator = initiator;
|
||||
this.newOwner = newOwner;
|
||||
this.oldOwner = oldOwner;
|
||||
this.hasOldOwner = hasOldOwner;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotId.
|
||||
*
|
||||
* @return PlotId
|
||||
*/
|
||||
public PlotId getPlotId() {
|
||||
return getPlot().getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world name.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the change-owner initator
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getInitiator() {
|
||||
return this.initiator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the old owner of the plot. Null if not exists.
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
public UUID getOldOwner() {
|
||||
return this.oldOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the new owner of the plot
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
public UUID getNewOwner() {
|
||||
return this.newOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the plot had an old owner
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean hasOldOwner() {
|
||||
return this.hasOldOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b) {
|
||||
this.cancelled = b;
|
||||
}
|
||||
}
|
@ -9,22 +9,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.plotsquared.bukkit.events.ClusterFlagRemoveEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerClaimPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerPlotDeniedEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerPlotHelperEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlotClearEvent;
|
||||
import com.plotsquared.bukkit.events.PlotComponentSetEvent;
|
||||
import com.plotsquared.bukkit.events.PlotDeleteEvent;
|
||||
import com.plotsquared.bukkit.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.bukkit.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.bukkit.events.PlotMergeEvent;
|
||||
import com.plotsquared.bukkit.events.PlotRateEvent;
|
||||
import com.plotsquared.bukkit.events.PlotUnlinkEvent;
|
||||
import com.plotsquared.bukkit.events.*;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -119,6 +104,11 @@ public class BukkitEventUtil extends EventUtil {
|
||||
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner, UUID newOwner, boolean hasOldOwner) {
|
||||
return callEvent(new PlotChangeOwnerEvent(getPlayer(initiator), plot, oldOwner, newOwner, hasOldOwner));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
|
||||
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
|
||||
|
Reference in New Issue
Block a user