Пример #1
0
 public static final void loadSpeedRunData(ExpeditionType type) {
   try {
     PreparedStatement ps =
         DatabaseConnection.getConnection()
             .prepareStatement(
                 "SELECT * FROM speedruns WHERE type = ? ORDER BY time LIMIT 25"); // or should we
                                                                                   // do less
     ps.setString(1, type.name());
     StringBuilder ret = new StringBuilder(getPreamble(type));
     Map<Integer, String> rett = new LinkedHashMap<Integer, String>();
     ResultSet rs = ps.executeQuery();
     int rank = 1;
     Set<String> leaders = new HashSet<String>();
     boolean cont = rs.first();
     boolean changed = cont;
     long tmp = 0;
     while (cont) {
       if (!leaders.contains(rs.getString("leader"))) {
         addSpeedRunData(
             ret,
             rett,
             rs.getString("members"),
             rs.getString("leader"),
             rank,
             rs.getString("timestring"));
         rank++;
         leaders.add(rs.getString("leader"));
         tmp = rs.getLong("time");
       }
       cont = rs.next() && rank < 25;
     }
     rs.close();
     ps.close();
     if (changed) {
       speedRunData.put(
           type, new Triple<String, Map<Integer, String>, Long>(ret.toString(), rett, tmp));
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Пример #2
0
 public static final String getPreamble(ExpeditionType type) {
   return "#rThese are the speedrun times for "
       + StringUtil.makeEnumHumanReadable(type.name()).toUpperCase()
       + ".#k\r\n\r\n";
 }