diff --git a/pom.xml b/pom.xml index f46e183..03fd0b4 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,12 @@ 3.3.0 compile + + org.mariadb.jdbc + mariadb-java-client + 2.6.2 + compile + diff --git a/src/main/java/me/totalfreedom/plex/Plex.java b/src/main/java/me/totalfreedom/plex/Plex.java index 7ddfbe7..d10cfd3 100644 --- a/src/main/java/me/totalfreedom/plex/Plex.java +++ b/src/main/java/me/totalfreedom/plex/Plex.java @@ -21,7 +21,7 @@ import org.bukkit.plugin.java.JavaPlugin; @Setter public class Plex extends JavaPlugin { - public static Plex plugin; + private static Plex plugin; public MainConfig config; private StorageType storageType = StorageType.SQLITE; diff --git a/src/main/java/me/totalfreedom/plex/PlexBase.java b/src/main/java/me/totalfreedom/plex/PlexBase.java index 9878637..12d7df5 100644 --- a/src/main/java/me/totalfreedom/plex/PlexBase.java +++ b/src/main/java/me/totalfreedom/plex/PlexBase.java @@ -2,5 +2,5 @@ package me.totalfreedom.plex; public class PlexBase { - protected static Plex plugin = Plex.plugin; + protected static Plex plugin = Plex.get(); } diff --git a/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java b/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java index 814dbf6..a2feb84 100644 --- a/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java +++ b/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java @@ -2,15 +2,15 @@ package me.totalfreedom.plex.cache; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; +import me.totalfreedom.plex.Plex; +import me.totalfreedom.plex.player.PlexPlayer; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import java.util.UUID; -import me.totalfreedom.plex.Plex; -import me.totalfreedom.plex.player.PlexPlayer; -import me.totalfreedom.plex.rank.enums.Rank; public class SQLPlayerData { diff --git a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java index aff84cc..5c072bd 100644 --- a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java +++ b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java @@ -18,7 +18,6 @@ public class SQLConnection extends PlexBase String username = plugin.config.getString("data.central.user"); String password = plugin.config.getString("data.central.password"); String database = plugin.config.getString("data.central.db"); - try { if (plugin.config.getString("data.central.storage").equalsIgnoreCase("sqlite")) @@ -26,13 +25,14 @@ public class SQLConnection extends PlexBase connection = DriverManager.getConnection("jdbc:sqlite:" + new File(plugin.getDataFolder(), "database.db").getAbsolutePath()); plugin.setStorageType(StorageType.SQLITE); } - else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mysql")) + else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mariadb")) { - connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password); + Class.forName("org.mariadb.jdbc.Driver"); + connection = DriverManager.getConnection("jdbc:mariadb://" + host + ":" + port + "/" + database, username, password); Plex.get().setStorageType(StorageType.SQL); } } - catch (SQLException throwables) + catch (SQLException | ClassNotFoundException throwables) { throwables.printStackTrace(); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2944693..6e27a2f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -5,7 +5,7 @@ server: data: central: - storage: sqlite + storage: sqlite # use mariadb, mongodb, or sqlite here user: "" password: "" hostname: 127.0.0.1