Ejemplo n.º 1
0
  private SignResult getUpDown(StatSign ss) {
    Sign s = getSign(ss.getLocation());
    if (s == null) return null;
    Sign sign = null;
    World w = s.getLocation().getWorld();
    List<Sign> signList = new ArrayList<Sign>();
    boolean foundUpStatSign = false;
    /// Search up
    int x = s.getLocation().getBlockX();
    int y = s.getLocation().getBlockY();
    int z = s.getLocation().getBlockZ();
    LinkedList<Sign> upsignList = new LinkedList<Sign>();
    while ((sign = getSign(w, x, ++y, z)) != null) {
      /// another command sign, don't continue
      if (breakLine(sign.getLine(0))) {
        foundUpStatSign = true;
        break;
      }
      upsignList.addFirst(sign);
    }
    /// If there isnt a conflicting sign above, then add all those signs as well
    if (!foundUpStatSign) {
      signList.addAll(upsignList);
    }

    /// Add self
    int originalSignIndex = signList.size();
    signList.add(s);

    sign = null;
    /// Search down
    x = s.getLocation().getBlockX();
    y = s.getLocation().getBlockY();
    z = s.getLocation().getBlockZ();
    while ((sign = getSign(w, x, --y, z)) != null) {
      String line = sign.getLine(0);
      /// another command sign, don't continue
      if (breakLine(line)) break;
      signList.add(sign);
    }
    return new SignResult(signList, originalSignIndex);
  }
Ejemplo n.º 2
0
  private int getUpDownCount(StatSign ss) {
    Sign s = getSign(ss.getLocation());
    if (s == null) return 0;
    int count = 1;

    World w = s.getLocation().getWorld();
    /// Search up
    int x = s.getLocation().getBlockX();
    int y = s.getLocation().getBlockY();
    int z = s.getLocation().getBlockZ();
    while (getSign(w, x, ++y, z) != null) {
      count++;
    }

    /// Search down
    x = s.getLocation().getBlockX();
    y = s.getLocation().getBlockY();
    z = s.getLocation().getBlockZ();
    while (getSign(w, x, --y, z) != null) {
      count++;
    }
    return count;
  }
Ejemplo n.º 3
0
    @Override
    public void run() {
      for (StatSign ss : statSignList) {
        Sign s = getSign(ss.getLocation());
        if (s == null) continue;
        SignResult sr = getUpDown(ss);
        if (sr == null || sr.signs.isEmpty()) continue;
        List<Sign> signList = sr.signs;

        boolean quit = false;
        int curTop = 0;
        for (int i = 0; i < signList.size() && !quit; i++) {
          int startIndex = 0;
          s = signList.get(i);
          if (i == sr.statSignIndex) {
            s.setLine(0, MessageController.colorChat("[&e" + dbName + "&0]"));
            s.setLine(
                1,
                MessageController.colorChat(
                    "[" + ss.getStatType().color() + ss.getStatType() + "&0]"));
            s.setLine(2, MessageController.colorChat("&cNo Records"));
            startIndex = 2;
          }
          for (int j = startIndex; j < 4; j++) {
            if (curTop >= statList.size()) {
              quit = true;
              break;
            }
            int val = (int) statList.get(curTop).getStat(ss.getStatType());
            String statLine = formatStatLine(statList.get(curTop).getName(), val, curTop);
            if (!s.getLine(j).equals(statLine)) s.setLine(j, statLine + "         ");
            curTop++;
          }
          s.update(true);
        }
      }
    }