Fix town children not transferring to new owner.

This commit is contained in:
bloodshot 2020-08-30 17:24:55 -04:00
parent d65a8a5f86
commit 221399d93b
2 changed files with 26 additions and 0 deletions

View File

@ -1005,6 +1005,19 @@ public ClaimResult transferOwner(UUID newOwnerID, boolean checkEconomy, boolean
this.ownerPlayerData = newOwnerData;
this.getClaimStorage().save();
if (this.isTown()) {
// update children
for (Claim child : this.children) {
if (child.getOwnerUniqueId().equals(ownerData.getUniqueId())) {
((GDClaim) child).claimData.setOwnerUniqueId(newOwnerID);
((GDClaim) child).ownerPlayerData = newOwnerData;
if (ownerData.getInternalClaims().remove(child)) {
newOwnerData.getInternalClaims().add(child);
}
((GDClaim) child).getClaimStorage().save();
}
}
}
return new GDClaimResult(this, ClaimResultType.SUCCESS);
}

View File

@ -1022,6 +1022,19 @@ public ClaimResult transferOwner(UUID newOwnerID, boolean checkEconomy, boolean
this.ownerPlayerData = newOwnerData;
this.getClaimStorage().save();
if (this.isTown()) {
// update children
for (Claim child : this.children) {
if (child.getOwnerUniqueId().equals(ownerData.getUniqueId())) {
((GDClaim) child).claimData.setOwnerUniqueId(newOwnerID);
((GDClaim) child).ownerPlayerData = newOwnerData;
if (ownerData.getInternalClaims().remove(child)) {
newOwnerData.getInternalClaims().add(child);
}
((GDClaim) child).getClaimStorage().save();
}
}
}
return new GDClaimResult(this, ClaimResultType.SUCCESS);
}