コード例 #1
0
ファイル: GetMaps.java プロジェクト: KWStudios/KWBungeeLobby
 public static String[] getMapNames(FileConfiguration fileConfiguration) {
   String[] names = new String[getConfigMapsCount(fileConfiguration)];
   if (ConfigFactory.getKeysUnderPath("settings.maps", false, fileConfiguration) != null) {
     ConfigFactory.getKeysUnderPath("settings.maps", false, fileConfiguration).toArray(names);
   }
   return names;
 }
コード例 #2
0
ファイル: GetMaps.java プロジェクト: KWStudios/KWBungeeLobby
 public static int getConfigMapsCount(FileConfiguration fileConfiguration) {
   int n = 0;
   if (ConfigFactory.getKeysUnderPath("settings.maps", false, fileConfiguration) == null) {
     return 0;
   }
   n = ConfigFactory.getKeysUnderPath("settings.maps", false, fileConfiguration).size();
   return n;
 }
コード例 #3
0
  /**
   * Initializes the globally unique instance of Connection for the database which should be set in
   * the config.yml.
   *
   * <p>If the values are not set yet, default values will be used instead.
   *
   * @return
   */
  public static synchronized Connection initConnection() {
    String databaseURL =
        ConfigFactory.getValueOrSetDefault(
            "settings.database", "url", "localhost", PluginLoader.getInstance().getConfig());
    int port =
        ConfigFactory.getValueOrSetDefault(
            "settings.database", "port", 3306, PluginLoader.getInstance().getConfig());
    String database =
        ConfigFactory.getValueOrSetDefault(
            "settings.database", "db", "database", PluginLoader.getInstance().getConfig());
    String userName =
        ConfigFactory.getValueOrSetDefault(
            "settings.database", "user", "username", PluginLoader.getInstance().getConfig());
    String password =
        ConfigFactory.getValueOrSetDefault(
            "settings.database", "password", "password", PluginLoader.getInstance().getConfig());

    Connection conn = null;
    Properties connectionProps = new Properties();
    connectionProps.put("user", userName);
    connectionProps.put("password", password);

    try {
      conn =
          DriverManager.getConnection(
              "jdbc:mysql://" + databaseURL + ":" + Integer.toString(port) + "/" + database,
              connectionProps);
    } catch (SQLException e) {
      e.printStackTrace();
    }

    connection = conn;

    // System.out.println("RageMode connected successfully to the
    // database!");

    return connection;
  }