From 4c6b215407c3dc7ae6a450f35d717ebf19119922 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Wed, 5 Nov 2014 16:27:06 -0800 Subject: [PATCH] Fixed claims with subdivisions living on as ghosts. Claims like this, when deleted, would still protect the area for any players who have that claim cached. This change seems to have fixed the issue. --- .../GriefPrevention/DataStore.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index cadb14f..2d3a463 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -466,44 +466,49 @@ public abstract class DataStore //deletes a claim or subdivision synchronized public void deleteClaim(Claim claim) { - //subdivisions are simple - just remove them from their parent claim and save that claim + //subdivisions are simple - just remove them from their parent claim and save that claim if(claim.parent != null) { Claim parentClaim = claim.parent; parentClaim.children.remove(claim); - this.saveClaim(parentClaim); + claim.inDataStore = false; + this.saveClaim(parentClaim); return; } + //delete any children + for(int j = 0; j < claim.children.size(); j++) + { + this.deleteClaim(claim.children.get(j)); + } + + //mark as deleted so any references elsewhere can be ignored + claim.inDataStore = false; + //remove from memory for(int i = 0; i < this.claims.size(); i++) { if(claims.get(i).id.equals(claim.id)) { this.claims.remove(i); - claim.inDataStore = false; - for(int j = 0; j < claim.children.size(); j++) - { - claim.children.get(j).inDataStore = false; - } break; } - - ArrayList chunkStrings = claim.getChunkStrings(); - for(String chunkString : chunkStrings) - { - ArrayList claimsInChunk = this.chunksToClaimsMap.get(chunkString); - for(int j = 0; j < claimsInChunk.size(); j++) - { - if(claimsInChunk.get(j).id.equals(claim.id)) - { - claimsInChunk.remove(j); - break; - } - } - } } + ArrayList chunkStrings = claim.getChunkStrings(); + for(String chunkString : chunkStrings) + { + ArrayList claimsInChunk = this.chunksToClaimsMap.get(chunkString); + for(int j = 0; j < claimsInChunk.size(); j++) + { + if(claimsInChunk.get(j).id.equals(claim.id)) + { + claimsInChunk.remove(j); + break; + } + } + } + //remove from secondary storage this.deleteClaimFromSecondaryStorage(claim);