Ejemplo n.º 1
0
  public FieldSign(Block block, String[] lines, Player player) {
    if (!SignHelper.isSign(block)) {
      valid = false;
      return;
    }

    valid = extractData(block, lines);
    playerName = player.getName();
  }
Ejemplo n.º 2
0
  public FieldSign(Block block) {
    if (!SignHelper.isSign(block)) {
      valid = false;
      return;
    }

    sign = ((Sign) block.getState());

    String[] lines = sign.getLines();

    valid = extractData(block, lines);
  }
Ejemplo n.º 3
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;
  }
Ejemplo n.º 4
0
 /**
  * Returns the block the fieldSign is attacked to
  *
  * @return
  */
 public Block getAttachedBlock() {
   return SignHelper.getAttachedBlock(sign.getBlock());
 }
Ejemplo n.º 5
0
 public void updateRemainingTime(int seconds) {
   sign.setLine(3, ChatColor.BOLD + SignHelper.secondsToPeriods(seconds) + ChatColor.BOLD);
   sign.update();
 }