Added ClaimDeletedEvent.
Fires only for top-level claims (not subclaims), and not for resizes(horizontal) or extensions (vertical).
This commit is contained in:
parent
bea31f340e
commit
4dd791fa08
|
|
@ -89,7 +89,7 @@ class CleanupUnusedClaimsTask implements Runnable
|
|||
if(newPlayerClaimsExpired && playerData.getClaims().size() == 1)
|
||||
{
|
||||
claim.removeSurfaceFluids(null);
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim);
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true);
|
||||
cleanupChunks = true;
|
||||
|
||||
//if configured to do so, restore the land to natural
|
||||
|
|
@ -147,7 +147,7 @@ class CleanupUnusedClaimsTask implements Runnable
|
|||
|
||||
if(investmentScore < minInvestment)
|
||||
{
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim);
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true);
|
||||
GriefPrevention.AddLogEntry("Removed " + claim.getOwnerName() + "'s unused claim @ " + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()));
|
||||
|
||||
//if configured to do so, restore the claim area to natural state
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import java.util.*;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import me.ryanhamshire.GriefPrevention.events.ClaimDeletedEvent;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
|
@ -484,6 +486,11 @@ public abstract class DataStore
|
|||
|
||||
//deletes a claim or subdivision
|
||||
synchronized public void deleteClaim(Claim claim)
|
||||
{
|
||||
this.deleteClaim(claim, true);
|
||||
}
|
||||
|
||||
synchronized void deleteClaim(Claim claim, boolean fireEvent)
|
||||
{
|
||||
//subdivisions are simple - just remove them from their parent claim and save that claim
|
||||
if(claim.parent != null)
|
||||
|
|
@ -498,7 +505,7 @@ public abstract class DataStore
|
|||
//delete any children
|
||||
for(int j = 0; j < claim.children.size(); j++)
|
||||
{
|
||||
this.deleteClaim(claim.children.get(j));
|
||||
this.deleteClaim(claim.children.get(j), false);
|
||||
}
|
||||
|
||||
//mark as deleted so any references elsewhere can be ignored
|
||||
|
|
@ -545,6 +552,12 @@ public abstract class DataStore
|
|||
}
|
||||
this.savePlayerData(claim.ownerID, ownerData);
|
||||
}
|
||||
|
||||
if(fireEvent)
|
||||
{
|
||||
ClaimDeletedEvent ev = new ClaimDeletedEvent(claim);
|
||||
Bukkit.getPluginManager().callEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
abstract void deleteClaimFromSecondaryStorage(Claim claim);
|
||||
|
|
@ -752,7 +765,7 @@ public abstract class DataStore
|
|||
ArrayList<Claim> subdivisions = new ArrayList<Claim>(claim.children);
|
||||
|
||||
//delete the claim
|
||||
this.deleteClaim(claim);
|
||||
this.deleteClaim(claim, false);
|
||||
|
||||
//re-create it at the new depth
|
||||
claim.lesserBoundaryCorner.setY(newDepth);
|
||||
|
|
@ -985,7 +998,7 @@ public abstract class DataStore
|
|||
Claim claim = claimsToDelete.get(i);
|
||||
claim.removeSurfaceFluids(null);
|
||||
|
||||
this.deleteClaim(claim);
|
||||
this.deleteClaim(claim, true);
|
||||
|
||||
//if in a creative mode world, delete the claim
|
||||
if(GriefPrevention.instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
|
||||
|
|
@ -1003,7 +1016,7 @@ public abstract class DataStore
|
|||
ArrayList<Claim> subdivisions = new ArrayList<Claim>(claim.children);
|
||||
|
||||
//remove old claim
|
||||
this.deleteClaim(claim);
|
||||
this.deleteClaim(claim, false);
|
||||
|
||||
//try to create this new claim, ignoring the original when checking for overlap
|
||||
CreateClaimResult result = this.createClaim(claim.getLesserBoundaryCorner().getWorld(), newx1, newx2, newy1, newy2, newz1, newz2, claim.ownerID, claim.parent, claim.id, resizingPlayer);
|
||||
|
|
|
|||
|
|
@ -1476,7 +1476,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
else
|
||||
{
|
||||
claim.removeSurfaceFluids(null);
|
||||
this.dataStore.deleteClaim(claim);
|
||||
this.dataStore.deleteClaim(claim, true);
|
||||
|
||||
//if in a creative mode world, /restorenature the claim
|
||||
if(GriefPrevention.instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
|
||||
|
|
@ -2001,7 +2001,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
{
|
||||
//delete it
|
||||
claim.removeSurfaceFluids(null);
|
||||
this.dataStore.deleteClaim(claim);
|
||||
this.dataStore.deleteClaim(claim, true);
|
||||
|
||||
//if in a creative mode world, restore the claim area
|
||||
if(GriefPrevention.instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package me.ryanhamshire.GriefPrevention.events;
|
||||
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* This event gets called whenever a claim is going to be deleted. This event is
|
||||
* not called when a claim is resized.
|
||||
*
|
||||
* @author Tux2
|
||||
*
|
||||
*/
|
||||
public class ClaimDeletedEvent extends Event{
|
||||
|
||||
// Custom Event Requirements
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private Claim claim;
|
||||
|
||||
public ClaimDeletedEvent(Claim claim) {
|
||||
this.claim = claim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the claim to be deleted.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Claim getClaim() {
|
||||
return claim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author Ryan
|
||||
*
|
||||
*/
|
||||
package me.ryanhamshire.GriefPrevention.events;
|
||||
Loading…
Reference in New Issue
Block a user