mirror of
https://github.com/SimplexDevelopment/Traverse.git
synced 2024-12-22 05:57:36 +00:00
Fix DBProperties not writing to disk
This commit is contained in:
parent
31b0a8a3fe
commit
c698ced937
Binary file not shown.
@ -102,7 +102,7 @@ public final class Traverse extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
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.commandLoader = new CommandLoader(this, "TRAVERSE");
|
||||||
this.dataManager = new DataManager(this);
|
this.dataManager = new DataManager(this);
|
||||||
this.banManager = new BanManager(this);
|
this.banManager = new BanManager(this);
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package mc.unraveled.reforged.storage;
|
package mc.unraveled.reforged.storage;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -17,13 +20,21 @@ public class DBProperties {
|
|||||||
private final String username;
|
private final String username;
|
||||||
private final String password;
|
private final String password;
|
||||||
|
|
||||||
public DBProperties(String fileName) {
|
public DBProperties(Plugin plugin, String fileName) {
|
||||||
|
File file = new File(plugin.getDataFolder(), fileName);
|
||||||
properties = new Properties();
|
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);
|
properties.load(fileInputStream);
|
||||||
} catch (IOException e) {
|
} 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");
|
driver = properties.getProperty("driver");
|
||||||
databaseType = properties.getProperty("databaseType");
|
databaseType = properties.getProperty("databaseType");
|
||||||
databaseFile = properties.getProperty("databaseFile");
|
databaseFile = properties.getProperty("databaseFile");
|
||||||
|
Loading…
Reference in New Issue
Block a user