Exemplo n.º 1
0
  public static void printOverlay() {
    // 输出服务器繁忙率
    Iterator<Server> its = Servers.iterator();
    Server tmp;
    while (its.hasNext()) {
      tmp = its.next();
      Output.printSTAT(
          "server"
              + tmp.getServerID()
              + ": percentage of busy time: "
              + Utilities.displayPercentage(tmp.getUtilizationRate())
              + "%");
    }

    // 输出每个Overlay信息。
    Iterator<Overlay> ito = p2pOverlay.iterator();

    while (ito.hasNext()) {
      ito.next().printInfo();
    }
  }
Exemplo n.º 2
0
  public static void saveServer(Server server) {
    Connection c = null;
    PreparedStatement ps = null;

    String query =
        "INSERT INTO servers VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE xp_min=?,xp_max=?,xp_min_twitch=?,xp_max_twitch=?,xp_base=?,xp_multiplier=?,cleverbot_channel=?,twitch_channel=?,welcome_message=?,goodbye_message=?,welcome_goodbye_chan=?,admin_role=?,role_on_join=?,vr_mode=?";

    try {
      c = hikari.getConnection();
      ps = c.prepareStatement(query);

      ps.setString(1, server.getServerID());
      ps.setInt(2, server.getMinXP());
      ps.setInt(3, server.getMaxXP());
      ps.setInt(4, server.getMinXpTwitch());
      ps.setInt(5, server.getMaxXpTwitch());
      ps.setInt(6, server.getXpBase());
      ps.setDouble(7, server.getXpMultiplier());
      ps.setString(8, server.getCleverbotChannel());
      ps.setString(9, server.getTwitchChannel());
      ps.setString(10, server.getWelcomeMessage());
      ps.setString(11, server.getGoodbyeMessage());
      ps.setString(12, server.getWelcomeGoodbyeChannel());
      ps.setString(13, server.getAdminRole());
      ps.setString(14, server.getRoleOnJoin());
      ps.setBoolean(15, server.isVrMode());
      ps.setInt(16, server.getMinXP());
      ps.setInt(17, server.getMaxXP());
      ps.setInt(18, server.getMinXpTwitch());
      ps.setInt(19, server.getMaxXpTwitch());
      ps.setInt(20, server.getXpBase());
      ps.setDouble(21, server.getXpMultiplier());
      ps.setString(22, server.getCleverbotChannel());
      ps.setString(23, server.getTwitchChannel());
      ps.setString(24, server.getWelcomeMessage());
      ps.setString(25, server.getGoodbyeMessage());
      ps.setString(26, server.getWelcomeGoodbyeChannel());
      ps.setString(27, server.getAdminRole());
      ps.setString(28, server.getRoleOnJoin());
      ps.setBoolean(29, server.isVrMode());

      ps.execute();
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      if (c != null) {
        try {
          c.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
      if (ps != null) {
        try {
          ps.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
  }