API: Claim expiration event.

Cancellable, with GPFlags in mind.
This commit is contained in:
ryanhamshire 2016-02-02 13:34:54 -08:00
parent 4406b83bc1
commit 32cc947fe4
2 changed files with 59 additions and 1 deletions

View File

@ -21,6 +21,10 @@
import java.util.Calendar; import java.util.Calendar;
import java.util.Vector; import java.util.Vector;
import org.bukkit.Bukkit;
import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent;
class CleanupUnusedClaimTask implements Runnable class CleanupUnusedClaimTask implements Runnable
{ {
Claim claim; Claim claim;
@ -35,6 +39,11 @@ class CleanupUnusedClaimTask implements Runnable
@Override @Override
public void run() public void run()
{ {
//see if any other plugins don't want this claim deleted
ClaimExpirationEvent event = new ClaimExpirationEvent(this.claim);
Bukkit.getPluginManager().callEvent(event);
if(event.isCancelled()) return;
//determine area of the default chest claim //determine area of the default chest claim
int areaOfDefaultClaim = 0; int areaOfDefaultClaim = 0;
if(GriefPrevention.instance.config_claims_automaticClaimsForNewPlayersRadius >= 0) if(GriefPrevention.instance.config_claims_automaticClaimsForNewPlayersRadius >= 0)

View File

@ -0,0 +1,49 @@
package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
//if cancelled, the claim will not be deleted
public class ClaimExpirationEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false;
public static HandlerList getHandlerList()
{
return handlers;
}
Claim claim;
public ClaimExpirationEvent(Claim claim)
{
this.claim = claim;
}
public Claim getClaim()
{
return this.claim;
}
@Override
public HandlerList getHandlers()
{
return handlers;
}
@Override
public boolean isCancelled()
{
return this.cancelled;
}
@Override
public void setCancelled(boolean cancelled)
{
this.cancelled = cancelled;
}
}