Пример #1
0
  public Vector<Claim> getClaims() {
    if (this.claims == null) {
      int totalClaimsArea = 0;
      this.claims = new Vector<Claim>();

      // find all the claims belonging to this player and note them for
      // future reference
      for (final Claim claim : GriefPreventionPlus.getInstance().getDataStore().claims.values()) {
        if (this.playerID.equals(claim.getOwnerID())) {
          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()
              + GriefPreventionPlus.getInstance().getDataStore().getGroupBonusBlocks(this.playerID);
      if (totalBlocks < totalClaimsArea) {
        // try to fix it by adding to accrued blocks
        this.accruedClaimBlocks = totalClaimsArea;
        if (this.accruedClaimBlocks
            > GriefPreventionPlus.getInstance().config.claims_maxAccruedBlocks) {
          // remember to respect the maximum on accrued blocks
          this.accruedClaimBlocks =
              GriefPreventionPlus.getInstance().config.claims_maxAccruedBlocks;
        }

        // if that didn't fix it, then make up the difference with bonus
        // blocks
        totalBlocks =
            this.accruedClaimBlocks
                + this.getBonusClaimBlocks()
                + GriefPreventionPlus.getInstance()
                    .getDataStore()
                    .getGroupBonusBlocks(this.playerID);
        if (totalBlocks < totalClaimsArea) {
          this.bonusClaimBlocks += totalClaimsArea - totalBlocks;
        }
      }
    }

    return this.claims;
  }