Implement SQL database and refactor onEnable method

In this commit, an SQLite database is set up in the onEnable method of the PreventStabby class, which will be used to store plugin data. To facilitate this, java.io.File is being imported. By doing this, we ensure that the database file exists and is connected to as soon as the plugin is enabled.
This commit is contained in:
2024-02-24 19:36:55 +01:00
parent 1aeb245666
commit 3c7904786e
@@ -12,6 +12,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
public final class PreventStabby extends JavaPlugin { public final class PreventStabby extends JavaPlugin {
private static PreventStabby plugin; private static PreventStabby plugin;
@@ -24,6 +26,8 @@ public final class PreventStabby extends JavaPlugin {
public void onEnable() { public void onEnable() {
plugin = this; plugin = this;
reloadPluginConfig(); reloadPluginConfig();
File dbFile = new File("plugins/PreventStabby");
sqLite = new DatabaseSQLite("jdbc:sqlite:plugins/PreventStabby/database.db", dbFile, getLogger());
playerManager = new PlayerManager(this); playerManager = new PlayerManager(this);
// Register listeners TODO // Register listeners TODO