Only call ClaimExpirationEvent if a player's claims are actually going to be expired
Fixes #380
This commit is contained in:
parent
bce2eaf6c4
commit
b3a54e16dc
|
|
@ -43,10 +43,7 @@ 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;
|
||||||
|
|
@ -64,6 +61,8 @@ class CleanupUnusedClaimTask implements Runnable
|
||||||
boolean newPlayerClaimsExpired = sevenDaysAgo.getTime().after(new Date(ownerInfo.getLastPlayed()));
|
boolean newPlayerClaimsExpired = sevenDaysAgo.getTime().after(new Date(ownerInfo.getLastPlayed()));
|
||||||
if(newPlayerClaimsExpired && ownerData.getClaims().size() == 1)
|
if(newPlayerClaimsExpired && ownerData.getClaims().size() == 1)
|
||||||
{
|
{
|
||||||
|
if (expireEventCanceled())
|
||||||
|
return;
|
||||||
claim.removeSurfaceFluids(null);
|
claim.removeSurfaceFluids(null);
|
||||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true, true);
|
GriefPrevention.instance.dataStore.deleteClaim(claim, true, true);
|
||||||
|
|
||||||
|
|
@ -85,6 +84,8 @@ class CleanupUnusedClaimTask implements Runnable
|
||||||
|
|
||||||
if(earliestPermissibleLastLogin.getTime().after(new Date(ownerInfo.getLastPlayed())))
|
if(earliestPermissibleLastLogin.getTime().after(new Date(ownerInfo.getLastPlayed())))
|
||||||
{
|
{
|
||||||
|
if (expireEventCanceled())
|
||||||
|
return;
|
||||||
//make a copy of this player's claim list
|
//make a copy of this player's claim list
|
||||||
Vector<Claim> claims = new Vector<Claim>();
|
Vector<Claim> claims = new Vector<Claim>();
|
||||||
for(int i = 0; i < ownerData.getClaims().size(); i++)
|
for(int i = 0; i < ownerData.getClaims().size(); i++)
|
||||||
|
|
@ -125,6 +126,8 @@ class CleanupUnusedClaimTask implements Runnable
|
||||||
boolean claimExpired = sevenDaysAgo.getTime().after(new Date(ownerInfo.getLastPlayed()));
|
boolean claimExpired = sevenDaysAgo.getTime().after(new Date(ownerInfo.getLastPlayed()));
|
||||||
if(claimExpired)
|
if(claimExpired)
|
||||||
{
|
{
|
||||||
|
if (expireEventCanceled())
|
||||||
|
return;
|
||||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true, true);
|
GriefPrevention.instance.dataStore.deleteClaim(claim, true, true);
|
||||||
GriefPrevention.AddLogEntry("Removed " + claim.getOwnerName() + "'s unused claim @ " + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()), CustomLogEntryTypes.AdminActivity);
|
GriefPrevention.AddLogEntry("Removed " + claim.getOwnerName() + "'s unused claim @ " + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()), CustomLogEntryTypes.AdminActivity);
|
||||||
|
|
||||||
|
|
@ -134,4 +137,12 @@ class CleanupUnusedClaimTask implements Runnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean expireEventCanceled()
|
||||||
|
{
|
||||||
|
//see if any other plugins don't want this claim deleted
|
||||||
|
ClaimExpirationEvent event = new ClaimExpirationEvent(this.claim);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event.isCancelled();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user