diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 40509e271..6ffd551c0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -63,21 +63,21 @@ public class Plan extends JavaPlugin { databases.add(new MySQLDB(this)); databases.add(new SQLiteDB(this)); - for (Database database : databases) { - String name = database.getConfigName(); - - ConfigurationSection section = getConfig().getConfigurationSection(name); - - if (section == null) { - section = getConfig().createSection(name); - } - - database.getConfigDefaults(section); - - if (section.getKeys(false).isEmpty()) { - getConfig().set(name, null); - } - } +// for (Database database : databases) { +// String name = database.getConfigName(); +// +// ConfigurationSection section = getConfig().getConfigurationSection(name); +// +// if (section == null) { +// section = getConfig().createSection(name); +// } +// +// database.getConfigDefaults(section); +// +// if (section.getKeys(false).isEmpty()) { +// getConfig().set(name, null); +// } +// } getConfig().options().copyDefaults(true); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java index ecfa22a99..f6348e3f8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java @@ -6,6 +6,8 @@ import org.bukkit.configuration.ConfigurationSection; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import org.bukkit.configuration.file.FileConfiguration; +import static org.bukkit.plugin.java.JavaPlugin.getPlugin; /** * @@ -29,54 +31,55 @@ public class MySQLDB extends SQLDB { */ @Override protected Connection getNewConnection() { - ConfigurationSection config = getConfigSection(); - - setUserName(config.getString("tables.users")); - setLocationName(config.getString("tables.locations")); - setNicknamesName(config.getString("tables.nicknames")); - setGamemodetimesName(config.getString("tables.gamemodes")); - setIpsName(config.getString("tables.ips")); - setCommanduseName(config.getString("tables.commandusages")); - setServerdataName(config.getString("tables.serverdata")); + FileConfiguration config = getPlugin(Plan.class).getConfig(); + + setUserName(config.getString("mysql.tables.users")); + setLocationName(config.getString("mysql.tables.locations")); + setNicknamesName(config.getString("mysql.tables.nicknames")); + setGamemodetimesName(config.getString("mysql.tables.gamemodetimes")); + setIpsName(config.getString("mysql.tables.ips")); + setCommanduseName(config.getString("mysql.tables.commandusages")); + setServerdataName(config.getString("mysql.tables.serverdata")); try { Class.forName("com.mysql.jdbc.Driver"); - String url = "jdbc:mysql://" + config.getString("host") + ":" + config.getString("port") + "/" + config.getString("database"); + String url = "jdbc:mysql://" + config.getString("mysql.host") + ":" + config.getString("mysql.port") + "/" + config.getString("mysql.database"); - return DriverManager.getConnection(url, config.getString("user"), config.getString("password")); + return DriverManager.getConnection(url, config.getString("mysql.user"), config.getString("mysql.password")); } catch (ClassNotFoundException | SQLException e) { + e.printStackTrace(); return null; } } - private ConfigurationSection getSection(ConfigurationSection parent, String childName) { - ConfigurationSection child = parent.getConfigurationSection(childName); - - if (child == null) { - child = parent.createSection(childName); - } - - return child; - } +// private ConfigurationSection getSection(ConfigurationSection parent, String childName) { +// ConfigurationSection child = parent.getConfigurationSection(childName); +// +// if (child == null) { +// child = parent.createSection(childName); +// } +// +// return child; +// } @Override public void getConfigDefaults(ConfigurationSection section) { - section.addDefault("host", "localhost"); - section.addDefault("port", 3306); - section.addDefault("user", "root"); - section.addDefault("password", "minecraft"); - section.addDefault("database", "Plan"); - - ConfigurationSection tables = getSection(section, "tables"); - - tables.addDefault("users", "plan_users"); - tables.addDefault("locations", "plan_locations"); - tables.addDefault("nicknames", "plan_nicknames"); - tables.addDefault("gamemodetimes", "plan_gamemodetimes"); - tables.addDefault("ips", "plan_ips"); - tables.addDefault("commandusages", "plan_commandusages"); - tables.addDefault("serverdata", "plan_serverdata"); +// section.addDefault("host", "localhost"); +// section.addDefault("port", 3306); +// section.addDefault("user", "root"); +// section.addDefault("password", "minecraft"); +// section.addDefault("database", "Plan"); +// +// ConfigurationSection tables = getSection(section, "tables"); +// +// tables.addDefault("users", "plan_users"); +// tables.addDefault("locations", "plan_locations"); +// tables.addDefault("nicknames", "plan_nicknames"); +// tables.addDefault("gamemodetimes", "plan_gamemodetimes"); +// tables.addDefault("ips", "plan_ips"); +// tables.addDefault("commandusages", "plan_commandusages"); +// tables.addDefault("serverdata", "plan_serverdata"); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index 31cb183c4..b929dd86a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -27,7 +27,7 @@ import static org.bukkit.Bukkit.getOfflinePlayer; public abstract class SQLDB extends Database { - private final Plan plugin; + final Plan plugin; private final boolean supportsModification; diff --git a/Plan/src/main/resources/config.yml b/Plan/src/main/resources/config.yml index 3a26c3768..c84be86b3 100644 --- a/Plan/src/main/resources/config.yml +++ b/Plan/src/main/resources/config.yml @@ -46,4 +46,19 @@ Customization: IgnoreWhen: 'sure, think, with, are, you' database: - type: sqlite \ No newline at end of file + type: sqlite + +mysql: + host: localhost + port: 3306 + user: root + password: minecraft + database: Plan + tables: + users: plan_users + locations: plan_locations + nicknames: plan_nicknames + gamemodetimes: plan_gamemodetimes + ips: plan_ips + commandusages: plan_commandusages + serverdata: plan_serverdata diff --git a/Plan/src/main/resources/plugin.yml b/Plan/src/main/resources/plugin.yml index ff927b465..b7dfdd510 100644 --- a/Plan/src/main/resources/plugin.yml +++ b/Plan/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.Plan -version: 2.1.2 +version: 2.1.3 commands: plan: