11package me .mrnavastar .sqlib .impl .config ;
22
33import com .fasterxml .jackson .dataformat .toml .TomlMapper ;
4- import lombok .Setter ;
54import lombok .SneakyThrows ;
65import me .mrnavastar .sqlib .SQLib ;
76import me .mrnavastar .sqlib .api .database .MySQL ;
1615import java .nio .file .Path ;
1716import java .util .Objects ;
1817
19- public class SQLibConfig {
18+ public class Config {
2019
21- public static SQLibConfig INSTANCE ;
20+ public static Config INSTANCE ;
2221
2322 public Database database ;
2423 public Local local ;
@@ -62,24 +61,14 @@ public boolean validate() {
6261 return database .type .equalsIgnoreCase ("postgres" ) && server .validate ();
6362 }
6463
65- @ Setter
66- private static Path customConfigPath ;
67- @ Setter
68- private static Path customDefaultDirectory ;
69-
7064 @ SneakyThrows
7165 public static void load () {
7266 if (INSTANCE != null ) return ;
7367
7468 Class .forName ("org.sqlite.JDBC" );
7569 Class .forName ("org.mariadb.jdbc.Driver" );
7670 Class .forName ("org.postgresql.Driver" );
77-
78- if (customConfigPath != null && customDefaultDirectory != null ) {
79- load (customDefaultDirectory , customConfigPath );
80- return ;
81- }
82-
71+
8372 try {
8473 Class .forName ("net.fabricmc.loader.api.FabricLoader" );
8574 Fabric .load ();
@@ -95,9 +84,9 @@ public static void load() {
9584 try {
9685 Class .forName ("com.velocitypowered.api.plugin.Plugin" );
9786 Velocity .load ();
98- } catch (ClassNotFoundException ignore ) {
99- throw new RuntimeException ( "SQLib currently only supports Fabric, Quilt, and Velocity!" );
100- }
87+ } catch (ClassNotFoundException ignore ) {}
88+
89+ if (! NonMinecraft . load ()) throw new RuntimeException ( "SQLib currently only supports Fabric, Quilt, and Velocity!" );
10190 }
10291
10392 public static me .mrnavastar .sqlib .api .database .Database load (Path localDir , Path configDir ) {
@@ -112,7 +101,7 @@ public static me.mrnavastar.sqlib.api.database.Database load(Path localDir, Path
112101 writer .write (data );
113102 }
114103 }
115- INSTANCE = new TomlMapper ().readValue (configFile , SQLibConfig .class );
104+ INSTANCE = new TomlMapper ().readValue (configFile , Config .class );
116105 } catch (IOException e ) {
117106 e .printStackTrace ();
118107 }
0 commit comments