Automatic claim block totals corrections.
For settings changes and data fix-ups due to damage done by old bugs.
This commit is contained in:
parent
9af7acb21e
commit
ed3347ab9b
|
|
@ -238,6 +238,13 @@ public class PlayerData
|
||||||
if(storageData.accruedClaimBlocks != null)
|
if(storageData.accruedClaimBlocks != null)
|
||||||
{
|
{
|
||||||
this.accruedClaimBlocks = storageData.accruedClaimBlocks;
|
this.accruedClaimBlocks = storageData.accruedClaimBlocks;
|
||||||
|
|
||||||
|
//ensure at least minimum accrued are accrued (in case of settings changes to increase initial amount)
|
||||||
|
if(this.accruedClaimBlocks < GriefPrevention.instance.config_claims_initialBlocks)
|
||||||
|
{
|
||||||
|
this.accruedClaimBlocks = GriefPrevention.instance.config_claims_initialBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -266,12 +273,37 @@ public class PlayerData
|
||||||
|
|
||||||
//find all the claims belonging to this player and note them for future reference
|
//find all the claims belonging to this player and note them for future reference
|
||||||
DataStore dataStore = GriefPrevention.instance.dataStore;
|
DataStore dataStore = GriefPrevention.instance.dataStore;
|
||||||
|
int totalClaimsArea = 0;
|
||||||
for(int i = 0; i < dataStore.claims.size(); i++)
|
for(int i = 0; i < dataStore.claims.size(); i++)
|
||||||
{
|
{
|
||||||
Claim claim = dataStore.claims.get(i);
|
Claim claim = dataStore.claims.get(i);
|
||||||
if(playerID.equals(claim.ownerID))
|
if(playerID.equals(claim.ownerID))
|
||||||
{
|
{
|
||||||
this.claims.add(claim);
|
this.claims.add(claim);
|
||||||
|
totalClaimsArea += claim.getArea();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//ensure player has claim blocks for his claims, and at least the minimum accrued
|
||||||
|
this.loadDataFromSecondaryStorage();
|
||||||
|
|
||||||
|
//if total claimed area is more than total blocks available
|
||||||
|
int totalBlocks = this.accruedClaimBlocks + this.getBonusClaimBlocks() + GriefPrevention.instance.dataStore.getGroupBonusBlocks(this.playerID);
|
||||||
|
if(totalBlocks < totalClaimsArea)
|
||||||
|
{
|
||||||
|
//try to fix it by adding to accrued blocks
|
||||||
|
this.accruedClaimBlocks = totalClaimsArea;
|
||||||
|
if(this.accruedClaimBlocks > GriefPrevention.instance.config_claims_maxAccruedBlocks)
|
||||||
|
{
|
||||||
|
//remember to respect the maximum on accrued blocks
|
||||||
|
this.accruedClaimBlocks = GriefPrevention.instance.config_claims_maxAccruedBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if that didn't fix it, then make up the difference with bonus blocks
|
||||||
|
totalBlocks = this.accruedClaimBlocks + this.getBonusClaimBlocks() + GriefPrevention.instance.dataStore.getGroupBonusBlocks(this.playerID);
|
||||||
|
if(totalBlocks < totalClaimsArea)
|
||||||
|
{
|
||||||
|
this.bonusClaimBlocks += totalClaimsArea - totalBlocks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user