From 17962aed1a10c41762a2468b0d82887fcb3ed6ca Mon Sep 17 00:00:00 2001 From: fromgate Date: Sat, 12 Mar 2016 08:29:09 +0300 Subject: [PATCH] v0.0.7 - Fix NPE for first plugin start --- .../java/ru/nukkit/dblib/DbLibPlugin.java | 2 +- .../java/ru/nukkit/dblib/util/DbLibCfg.java | 22 ++++++++++--------- src/main/resources/plugin.yml | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/ru/nukkit/dblib/DbLibPlugin.java b/src/main/java/ru/nukkit/dblib/DbLibPlugin.java index 67f8b53..b952924 100644 --- a/src/main/java/ru/nukkit/dblib/DbLibPlugin.java +++ b/src/main/java/ru/nukkit/dblib/DbLibPlugin.java @@ -12,7 +12,7 @@ public class DbLibPlugin extends PluginBase { ConnectionSource connectionSource = null; private static DbLibPlugin plugin; - static DbLibPlugin getPlugin() { + public static DbLibPlugin getPlugin() { return plugin; } diff --git a/src/main/java/ru/nukkit/dblib/util/DbLibCfg.java b/src/main/java/ru/nukkit/dblib/util/DbLibCfg.java index 3e4d84f..ed8cf25 100644 --- a/src/main/java/ru/nukkit/dblib/util/DbLibCfg.java +++ b/src/main/java/ru/nukkit/dblib/util/DbLibCfg.java @@ -2,34 +2,36 @@ import cn.nukkit.plugin.Plugin; import cn.nukkit.utils.SimpleConfig; +import ru.nukkit.dblib.DbLibPlugin; + +import java.io.File; public class DbLibCfg extends SimpleConfig { - public DbLibCfg(Plugin plugin) { - super(plugin); + public DbLibCfg(Plugin plugin) { super(plugin); } @Path(value = "DbLib.use-MySQL") - public boolean dbUseMySQL; + public boolean dbUseMySQL=false; @Path(value = "SQLite.file-name") - public String dbFileName; + public String dbFileName = DbLibPlugin.getPlugin().getDataFolder().getParentFile().getParent() + File.separator + "nukkit.db"; @Path(value = "MySQL.host") - public String dbMySqlUrl; + public String dbMySqlUrl = "localhost"; @SimpleConfig.Path(value ="MySQL.port") - public int dbMySqlPort; + public int dbMySqlPort=3306; @SimpleConfig.Path(value ="MySQL.database") - public String dbMySqlDatabase; + public String dbMySqlDatabase="db"; @SimpleConfig.Path(value ="MySQL.username") - public String dbMySqlUsername; + public String dbMySqlUsername="nukkit"; @SimpleConfig.Path(value = "MySQL.password") - public String dbMySqlPassword; + public String dbMySqlPassword="tikkun"; @SimpleConfig.Path(value ="DbLib.ORMLite-debug") - public boolean debugLog; + public boolean debugLog=false; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2745309..fe3f94e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: DbLib main: ru.nukkit.dblib.DbLibPlugin -version: "0.0.6" +version: "0.0.7" author: fromgate, nukkit.ru api: ["1.0.0"] description: SQLite/MySQL library for Nukkit plugins