コード例 #1
0
ファイル: HealHp.java プロジェクト: wintermaples/NNSkill
  @Override
  protected void decodeParams(String paramsStr) {
    String[] params = paramsStr.split(" ");

    try {
      EnumTarget.valueOf(params[0].toUpperCase());
    } catch (IllegalArgumentException ex) {
      throw new IllegalArgumentException("Specified Target is not found!");
    }
    if (!Util.isNumber(params[1])) {
      throw new IllegalArgumentException("Specified HealAmount isn't number!");
    }
    if (EnumTarget.valueOf(params[0].toUpperCase()).equals(EnumTarget.RANGE)) {
      if (!(params.length >= 2))
        throw new IllegalArgumentException("Specified Range is not found!");
      if (!Util.isNumber(params[2]))
        throw new IllegalArgumentException("Specified Range isn't number!");
    }

    target = EnumTarget.valueOf(params[0].toUpperCase());
    healAmount = Integer.parseInt(params[1]);
    if (EnumTarget.valueOf(params[0].toUpperCase()).equals(EnumTarget.RANGE)) {
      range = Integer.parseInt(params[2]);
    }
  }
コード例 #2
0
ファイル: HealHp.java プロジェクト: wintermaples/NNSkill
  @Override
  protected boolean startup() {
    if (executorMonster != null) {
      switch (target) {
        case MYSELF:
          targetEntities.add(executor);
          break;
        case NEARBYMONSTER:
          Entity te =
              executor
                  .getWorld()
                  .getEntities()
                  .stream()
                  .filter(e -> monsterManager.isMonster(e))
                  .filter(e -> e.getLocation().distance(executor.getLocation()) <= 16)
                  .sorted(
                      (Entity o1, Entity o2) -> {
                        return o1.getLocation().distance(executor.getLocation())
                                < o2.getLocation().distance(executor.getLocation())
                            ? -1
                            : 1;
                      })
                  .findFirst()
                  .orElse(null);
          if (te != null) targetEntities.add(te);
          break;
        case NEARBYPLAYER:
          Player tp =
              executor
                  .getWorld()
                  .getPlayers()
                  .stream()
                  .filter(p -> p.getLocation().distance(executor.getLocation()) <= 16)
                  .sorted(
                      (Player o1, Player o2) -> {
                        return o1.getLocation().distance(executor.getLocation())
                                < o2.getLocation().distance(executor.getLocation())
                            ? -1
                            : 1;
                      })
                  .findFirst()
                  .orElse(null);
          if (tp != null) targetEntities.add(tp);
          break;
        case RANGE:
          executor
              .getWorld()
              .getEntities()
              .stream()
              .filter(e -> monsterManager.isMonster(e))
              .filter(e -> e.getLocation().distance(executor.getLocation()) <= range)
              .forEach(e -> targetEntities.add(e));
          break;
      }
    } else {
      switch (target) {
        case MYSELF:
          targetEntities.add(executor);
          break;
        case NEARBYMONSTER:
          Entity te =
              executor
                  .getWorld()
                  .getEntities()
                  .stream()
                  .filter(e -> monsterManager.isMonster(e))
                  .filter(e -> e.getLocation().distance(executor.getLocation()) <= 16)
                  .sorted(
                      (Entity o1, Entity o2) -> {
                        return o1.getLocation().distance(executor.getLocation())
                                < o2.getLocation().distance(executor.getLocation())
                            ? -1
                            : 1;
                      })
                  .findFirst()
                  .orElse(null);
          if (te != null) targetEntities.add(te);
          break;
        case NEARBYPLAYER:
          Player tp =
              executor
                  .getWorld()
                  .getPlayers()
                  .stream()
                  .filter(p -> p.getLocation().distance(executor.getLocation()) <= 16)
                  .sorted(
                      (Player o1, Player o2) -> {
                        return o1.getLocation().distance(executor.getLocation())
                                < o2.getLocation().distance(executor.getLocation())
                            ? -1
                            : 1;
                      })
                  .findFirst()
                  .orElse(null);
          if (tp != null) targetEntities.add(tp);
          break;
        case RANGE:
          Bukkit.getOnlinePlayers()
              .stream()
              .filter(p -> monsterManager.isMonster(p))
              .filter(p -> p.getLocation().distance(executor.getLocation()) <= range)
              .forEach(p -> targetEntities.add(p));
          break;
      }
    }

    if (target.equals(EnumTarget.MYSELF)) {
      Status status = currentStatusStore.get(targetEntities.get(0).getUniqueId());
      if (status.getMaxHp() == status.getHp()) return false;
    }
    return true;
  }