Added experimental tp ignore support

This commit is contained in:
BuildTools committed 2021-07-08 02:11:50 +03:00
1 parent b186d4813d
commit c6ad5ece5c
15 files changed
+185 -49

No files matched your search

@@ -0,0 +1,34 @@
package me.william278.huskhomes2.migrators;
import me.william278.huskhomes2.HuskHomes;
import org.bukkit.Bukkit;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
public class UpgradeDatabase {
private static final HuskHomes plugin = HuskHomes.getInstance();
// Upgrade the database system if the config file version is not high enough
public static void upgradeDatabase() {
plugin.reloadConfig();
if (plugin.getConfig().getInt("config_file_version", 1) > 5) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try (PreparedStatement statement = HuskHomes.getConnection().prepareStatement("ALTER TABLE " + HuskHomes.getSettings().getPlayerDataTable() + " ADD `is_ignoring_requests` boolean NOT NULL DEFAULT 0")) {
statement.executeUpdate();
} catch (SQLException e) {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred upgrading the database format!", e);
} finally {
// Update the config file version
Bukkit.getScheduler().runTask(plugin, () -> {
plugin.getConfig().set("config_file_version", 6);
plugin.saveConfig();
});
}
});
}
}
}