diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index ee31e97..bcec3fb 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/src/main/java/mc/unraveled/reforged/plugin/Traverse.java b/src/main/java/mc/unraveled/reforged/plugin/Traverse.java index f63bc67..617ce80 100644 --- a/src/main/java/mc/unraveled/reforged/plugin/Traverse.java +++ b/src/main/java/mc/unraveled/reforged/plugin/Traverse.java @@ -102,7 +102,7 @@ public final class Traverse extends JavaPlugin { @Override public void onEnable() { - this.SQLManager = new DBConnectionHandler(new DBProperties("db.properties")); + this.SQLManager = new DBConnectionHandler(new DBProperties(this, "db.properties")); this.commandLoader = new CommandLoader(this, "TRAVERSE"); this.dataManager = new DataManager(this); this.banManager = new BanManager(this); diff --git a/src/main/java/mc/unraveled/reforged/storage/DBProperties.java b/src/main/java/mc/unraveled/reforged/storage/DBProperties.java index e1b064e..90222e7 100644 --- a/src/main/java/mc/unraveled/reforged/storage/DBProperties.java +++ b/src/main/java/mc/unraveled/reforged/storage/DBProperties.java @@ -1,8 +1,11 @@ package mc.unraveled.reforged.storage; import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; +import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; @@ -17,13 +20,21 @@ public class DBProperties { private final String username; private final String password; - public DBProperties(String fileName) { + public DBProperties(Plugin plugin, String fileName) { + File file = new File(plugin.getDataFolder(), fileName); properties = new Properties(); - try (FileInputStream fileInputStream = new FileInputStream(fileName)) { + + try (FileInputStream fileInputStream = new FileInputStream(file)) { + if (file.createNewFile()) { + Bukkit.getLogger().info("Created new properties file."); + plugin.saveResource("db.properties", true); + } + properties.load(fileInputStream); } catch (IOException e) { - Bukkit.getLogger().severe("Could not load database properties file!"); + Bukkit.getLogger().severe("Error loading properties file!" + e.getMessage()); } + driver = properties.getProperty("driver"); databaseType = properties.getProperty("databaseType"); databaseFile = properties.getProperty("databaseFile");