Exemple #1
0
  /**
   * This method launches near by entities
   *
   * @return true if a entity was thrown.
   */
  protected boolean shoot() {

    boolean resultBoolean = false;
    Location location = BukkitUtil.toSign(getSign()).getLocation();
    EntityType type = EntityType.MOB_HOSTILE;

    if (!getSign().getLine(3).isEmpty()) {
      type = EntityType.fromString(getSign().getLine(3));
    }

    try {
      for (Entity e : LocationUtil.getNearbyEntities(location, new Vector(3, 3, 3))) {
        if (e.isDead() || !e.isValid()) {
          continue;
        }
        if (!type.is(e)) {
          continue;
        }

        String[] split = RegexUtil.COLON_PATTERN.split(getSign().getLine(2));
        double x = Double.parseDouble(split[0]);
        double y = Double.parseDouble(split[1]);
        double z = Double.parseDouble(split[2]);

        e.setVelocity(new org.bukkit.util.Vector(x, y, z).add(e.getVelocity()));

        resultBoolean = true;
      }
    } catch (Exception ignored) {
    }

    return resultBoolean;
  }
Exemple #2
0
  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;
  }
Exemple #3
0
  @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));
  }