Esempio n. 1
0
  public boolean extractData(Block block, String[] lines) {
    tag = ChatColor.stripColor(lines[0]);

    price = SignHelper.extractPrice(ChatColor.stripColor(lines[1]));

    if (price == 0) {
      return false;
    }

    item = SignHelper.extractItemFromParenthesis(ChatColor.stripColor(lines[1]));

    if (!isBuyable()) {
      period = ChatColor.stripColor(lines[2]);

      if (!SignHelper.isValidPeriod(period)) {
        return false;
      }

      fieldSign =
          tag.equalsIgnoreCase(ChatBlock.format("fieldSignRent"))
              || tag.equalsIgnoreCase(ChatBlock.format("fieldSignBuy"))
              || tag.equalsIgnoreCase(ChatBlock.format("fieldSignShare"));

      if (!fieldSign) {
        return false;
      }
    }

    if (item == null) {
      if (!PreciousStones.getInstance().getPermissionsManager().hasEconomy()) {
        noEconomy = true;
        return false;
      }
    }

    Block attachedBlock = SignHelper.getAttachedBlock(block);
    field = PreciousStones.getInstance().getForceFieldManager().getField(attachedBlock);

    if (field == null) {
      return false;
    }

    if (playerName != null) {
      if (!field.isOwner(playerName)) {
        return false;
      }
    }

    if (isRentable()) {
      if (!field.hasFlag(FieldFlag.RENTABLE)) {
        return false;
      }
    }

    if (isShareable()) {
      if (!field.hasFlag(FieldFlag.SHAREABLE)) {
        return false;
      }
    }

    if (isBuyable()) {
      if (!field.hasFlag(FieldFlag.BUYABLE)) {
        return false;
      }
    }

    return true;
  }
Esempio n. 2
0
 /**
  * Returns the block the fieldSign is attacked to
  *
  * @return
  */
 public Block getAttachedBlock() {
   return SignHelper.getAttachedBlock(sign.getBlock());
 }