Release pets on claim delete.
Except for owner-initiated deletes (/AbandonClaim).
This commit is contained in:
parent
da920488b7
commit
709bb55e98
|
|
@ -89,7 +89,7 @@ class CleanupUnusedClaimsTask implements Runnable
|
|||
if(newPlayerClaimsExpired && playerData.getClaims().size() == 1)
|
||||
{
|
||||
claim.removeSurfaceFluids(null);
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true);
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true, true);
|
||||
cleanupChunks = true;
|
||||
|
||||
//if configured to do so, restore the land to natural
|
||||
|
|
@ -155,7 +155,7 @@ class CleanupUnusedClaimsTask implements Runnable
|
|||
boolean claimExpired = sevenDaysAgo.getTime().after(playerData.getLastLogin());
|
||||
if(claimExpired)
|
||||
{
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true);
|
||||
GriefPrevention.instance.dataStore.deleteClaim(claim, true, true);
|
||||
GriefPrevention.AddLogEntry("Removed " + claim.getOwnerName() + "'s unused claim @ " + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()), CustomLogEntryTypes.AdminActivity);
|
||||
|
||||
//restore the claim area to natural state
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ import me.ryanhamshire.GriefPrevention.events.ClaimDeletedEvent;
|
|||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
|
|
@ -537,10 +539,16 @@ public abstract class DataStore
|
|||
//deletes a claim or subdivision
|
||||
synchronized public void deleteClaim(Claim claim)
|
||||
{
|
||||
this.deleteClaim(claim, true);
|
||||
this.deleteClaim(claim, true, false);
|
||||
}
|
||||
|
||||
synchronized void deleteClaim(Claim claim, boolean fireEvent)
|
||||
//deletes a claim or subdivision
|
||||
synchronized public void deleteClaim(Claim claim, boolean releasePets)
|
||||
{
|
||||
this.deleteClaim(claim, true, releasePets);
|
||||
}
|
||||
|
||||
synchronized void deleteClaim(Claim claim, boolean fireEvent, boolean releasePets)
|
||||
{
|
||||
//delete any children
|
||||
for(int j = 0; j < claim.children.size(); j++)
|
||||
|
|
@ -605,6 +613,26 @@ public abstract class DataStore
|
|||
ClaimDeletedEvent ev = new ClaimDeletedEvent(claim);
|
||||
Bukkit.getPluginManager().callEvent(ev);
|
||||
}
|
||||
|
||||
//optionally set any pets free which belong to the claim owner
|
||||
if(releasePets && claim.ownerID != null && claim.parent == null)
|
||||
{
|
||||
for(Chunk chunk : claim.getChunks())
|
||||
{
|
||||
Entity [] entities = chunk.getEntities();
|
||||
for(Entity entity : entities)
|
||||
{
|
||||
if(entity instanceof Tameable)
|
||||
{
|
||||
Tameable pet = (Tameable)entity;
|
||||
if(pet.isTamed() && pet.getOwner().getUniqueId().equals(claim.ownerID))
|
||||
{
|
||||
pet.setTamed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract void deleteClaimFromSecondaryStorage(Claim claim);
|
||||
|
|
|
|||
|
|
@ -1561,7 +1561,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
else
|
||||
{
|
||||
claim.removeSurfaceFluids(null);
|
||||
this.dataStore.deleteClaim(claim, true);
|
||||
this.dataStore.deleteClaim(claim, true, true);
|
||||
|
||||
//if in a creative mode world, /restorenature the claim
|
||||
if(GriefPrevention.instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
|
||||
|
|
@ -2354,7 +2354,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
{
|
||||
//delete it
|
||||
claim.removeSurfaceFluids(null);
|
||||
this.dataStore.deleteClaim(claim, true);
|
||||
this.dataStore.deleteClaim(claim, true, false);
|
||||
|
||||
//if in a creative mode world, restore the claim area
|
||||
if(GriefPrevention.instance.creativeRulesApply(claim.getLesserBoundaryCorner()))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user