mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Add PlotChangeOwner Event
This commit is contained in:
@ -0,0 +1,108 @@
|
||||
package com.plotsquared.nukkit.events;
|
||||
|
||||
import cn.nukkit.Player;
|
||||
import cn.nukkit.event.Cancellable;
|
||||
import cn.nukkit.event.HandlerList;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Plot plot;
|
||||
private final Player initiator;
|
||||
private final UUID newOwner;
|
||||
private final UUID oldOwner;
|
||||
private final 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.plot = plot;
|
||||
this.initiator = initiator;
|
||||
this.newOwner = newOwner;
|
||||
this.hasOldOwner = hasOldOwner;
|
||||
this.oldOwner = oldOwner;
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b) {
|
||||
this.cancelled = b;
|
||||
}
|
||||
}
|
@ -13,22 +13,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.plotsquared.nukkit.NukkitMain;
|
||||
import com.plotsquared.nukkit.events.ClusterFlagRemoveEvent;
|
||||
import com.plotsquared.nukkit.events.PlayerClaimPlotEvent;
|
||||
import com.plotsquared.nukkit.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.nukkit.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.nukkit.events.PlayerPlotDeniedEvent;
|
||||
import com.plotsquared.nukkit.events.PlayerPlotHelperEvent;
|
||||
import com.plotsquared.nukkit.events.PlayerPlotTrustedEvent;
|
||||
import com.plotsquared.nukkit.events.PlayerTeleportToPlotEvent;
|
||||
import com.plotsquared.nukkit.events.PlotClearEvent;
|
||||
import com.plotsquared.nukkit.events.PlotComponentSetEvent;
|
||||
import com.plotsquared.nukkit.events.PlotDeleteEvent;
|
||||
import com.plotsquared.nukkit.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.nukkit.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.nukkit.events.PlotMergeEvent;
|
||||
import com.plotsquared.nukkit.events.PlotRateEvent;
|
||||
import com.plotsquared.nukkit.events.PlotUnlinkEvent;
|
||||
import com.plotsquared.nukkit.events.*;
|
||||
import com.plotsquared.nukkit.object.NukkitPlayer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -125,6 +110,11 @@ public class NukkitEventUtil 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