Fix up the MySQL support.

This commit is contained in:
Brianna 2020-08-13 13:19:15 -05:00
parent 1d984cef36
commit 3bf21b27f9

View File

@ -55,6 +55,7 @@ public class UltimateModeration extends SongodaPlugin {
private ModerationManager moderationManager; private ModerationManager moderationManager;
private DatabaseConnector databaseConnector; private DatabaseConnector databaseConnector;
private DataMigrationManager dataMigrationManager;
private DataManager dataManager; private DataManager dataManager;
public static UltimateModeration getInstance() { public static UltimateModeration getInstance() {
@ -109,7 +110,7 @@ public class UltimateModeration extends SongodaPlugin {
this.staffChatManager = new StaffChatManager(); this.staffChatManager = new StaffChatManager();
this.moderationManager = new ModerationManager(this); this.moderationManager = new ModerationManager(this);
// Database stuff, go!
try { try {
if (Settings.MYSQL_ENABLED.getBoolean()) { if (Settings.MYSQL_ENABLED.getBoolean()) {
String hostname = Settings.MYSQL_HOSTNAME.getString(); String hostname = Settings.MYSQL_HOSTNAME.getString();
@ -125,15 +126,18 @@ public class UltimateModeration extends SongodaPlugin {
this.databaseConnector = new SQLiteConnector(this); this.databaseConnector = new SQLiteConnector(this);
this.getLogger().info("Data handler connected using SQLite."); this.getLogger().info("Data handler connected using SQLite.");
} }
} catch (Exception ex) {
this.getLogger().severe("Fatal error trying to connect to database. Please make sure all your connection settings are correct and try again. Plugin has been disabled.");
this.emergencyStop();
}
this.dataManager = new DataManager(this.databaseConnector, this); this.dataManager = new DataManager(this.databaseConnector, this);
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager, this.dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
new _1_InitialMigration()); new _1_InitialMigration());
dataMigrationManager.runMigrations(); this.dataMigrationManager.runMigrations();
} catch (Exception ex) {
this.getLogger().severe("Fatal error trying to connect to database. " +
"Please make sure all your connection settings are correct and try again. Plugin has been disabled.");
emergencyStop();
return;
}
Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> { Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
// Legacy Data // Legacy Data