コード例 #1
0
  protected boolean isDetected() {

    if (!nameLine.isEmpty() && type == Type.PLAYER) {
      Player p = Bukkit.getPlayer(nameLine);
      if (p != null && area.isWithinArea(p.getLocation())) return true;
    }

    for (Player p : area.getPlayersInArea()) {

      if (p == null || !p.isValid()) continue;

      if (nameLine.isEmpty()) return true;
      else if (type == Type.PLAYER
          && p.getName()
              .toLowerCase(Locale.ENGLISH)
              .startsWith(nameLine.toLowerCase(Locale.ENGLISH))) return true;
      else if (type == Type.GROUP && CraftBookPlugin.inst().inGroup(p, nameLine)) return true;
      else if (type == Type.PERMISSION_NODE && p.hasPermission(nameLine)) return true;
    }

    return false;
  }
コード例 #2
0
  @Override
  public void load() {

    if (getLine(3).contains(":")) {
      type = Type.getFromChar(getLine(3).replace("!", "").trim().toCharArray()[0]);
    }
    if (type == null) type = Type.PLAYER;

    invertOutput = getLine(3).contains("!");

    nameLine =
        getLine(3).replace("g:", "").replace("p:", "").replace("n:", "").replace("!", "").trim();

    area = SearchArea.createArea(BukkitUtil.toSign(getSign()).getBlock(), getLine(2));
  }
コード例 #3
0
ファイル: EntitySensor.java プロジェクト: MCRUS/craftbook
  protected boolean isDetected() {

    short cur = 0;

    for (Entity entity : area.getEntitiesInArea(types))
      if (entity.isValid())
        for (EntityType type : types) // Check Type
        if (type.is(entity)) // Check Radius
          cur++;

    if (minMode == 0 && cur >= minimum) return true;
    else if (minMode == 1 && cur == minimum) return true;
    else if (minMode == 2 && cur > minimum) return true;
    else if (minMode == 3 && cur <= minimum) return true;
    else if (minMode == 4 && cur < minimum) return true;

    return false;
  }
コード例 #4
0
ファイル: EntitySensor.java プロジェクト: MCRUS/craftbook
  @Override
  public void load() {

    // lets get the types to detect first
    types =
        EntityType.getDetected(
            getLine(3)
                .split("<")[0]
                .trim()
                .split("<=")[0]
                .trim()
                .split(">=")[0]
                .trim()
                .split("==")[0]
                .trim()
                .split(">")[0]
                .trim());

    if (getLine(3).contains(">=")) minMode = 0;
    else if (getLine(3).contains("==")) minMode = 1;
    else if (getLine(3).contains(">")) minMode = 2;
    else if (getLine(3).contains("<=")) minMode = 3;
    else if (getLine(3).contains("<")) minMode = 4;
    else minMode = 0;

    try {
      if (minMode == 0) minimum = Short.parseShort(getLine(3).split(">=")[1].trim());
      else if (minMode == 1) minimum = Short.parseShort(getLine(3).split("==")[1].trim());
      else if (minMode == 2) minimum = Short.parseShort(getLine(3).split(">")[1].trim());
      else if (minMode == 3) minimum = Short.parseShort(getLine(3).split("<=")[1].trim());
      else if (minMode == 4) minimum = Short.parseShort(getLine(3).split("<")[1].trim());
    } catch (Exception e) {
      minimum = 1;
    }

    area = SearchArea.createArea(BukkitUtil.toSign(getSign()).getBlock(), getLine(2));
  }
コード例 #5
0
ファイル: EntitySensor.java プロジェクト: MCRUS/craftbook
    @Override
    public void verify(ChangedSign sign) throws ICVerificationException {

      if (!SearchArea.isValidArea(BukkitUtil.toSign(sign).getBlock(), sign.getLine(2)))
        throw new ICVerificationException("Invalid SearchArea on 3rd line!");
    }