Compare commits

..

No commits in common. "kitchen-sink" and "31b0a8a-production" have entirely different histories.

3 changed files with 4 additions and 15 deletions

View File

@ -102,7 +102,7 @@ public final class Traverse extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
this.SQLManager = new DBConnectionHandler(new DBProperties(this, "db.properties")); this.SQLManager = new DBConnectionHandler(new DBProperties("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);

View File

@ -1,11 +1,8 @@
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;
@ -20,21 +17,13 @@ public class DBProperties {
private final String username; private final String username;
private final String password; private final String password;
public DBProperties(Plugin plugin, String fileName) { public DBProperties(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("Error loading properties file!" + e.getMessage()); Bukkit.getLogger().severe("Could not load database properties file!");
} }
driver = properties.getProperty("driver"); driver = properties.getProperty("driver");
databaseType = properties.getProperty("databaseType"); databaseType = properties.getProperty("databaseType");
databaseFile = properties.getProperty("databaseFile"); databaseFile = properties.getProperty("databaseFile");