Пример #1
0
  // the number of claim blocks a player has available for claiming land
  public int getRemainingClaimBlocks() {
    // accrued blocks + bonus blocks + permission bonus blocks
    int remainingBlocks =
        this.getAccruedClaimBlocks()
            + this.getBonusClaimBlocks()
            + GriefPreventionPlus.getInstance().getDataStore().getGroupBonusBlocks(this.playerID);
    for (final Claim claim : this.getClaims()) {
      remainingBlocks -= claim.getArea();
    }

    return remainingBlocks;
  }
Пример #2
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;
  }
  // restores nature in multiple chunks, as described by a claim instance
  // this restores all chunks which have ANY number of claim blocks from this claim in them
  // if the claim is still active (in the data store), then the claimed blocks will not be changed
  // (only the area bordering the claim)
  public void restoreClaim(Claim claim, long delayInTicks) {
    // admin claims aren't automatically cleaned up when deleted or abandoned
    if (claim.isAdminClaim()) return;

    // it's too expensive to do this for huge claims
    if (claim.getArea() > 10000) return;

    Chunk lesserChunk = claim.getLesserBoundaryCorner().getChunk();
    Chunk greaterChunk = claim.getGreaterBoundaryCorner().getChunk();

    for (int x = lesserChunk.getX(); x <= greaterChunk.getX(); x++)
      for (int z = lesserChunk.getZ(); z <= greaterChunk.getZ(); z++) {
        Chunk chunk = lesserChunk.getWorld().getChunkAt(x, z);
        this.restoreChunk(
            chunk, this.getSeaLevel(chunk.getWorld()) - 15, false, delayInTicks, null);
      }
  }