From 27f573c26b869ce96cd7443cfd5228f5e5882b7b Mon Sep 17 00:00:00 2001 From: GeekFrog Date: Sun, 16 Jul 2017 10:38:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8E=E7=89=88=E6=9C=AC=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=20fix=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ src/main/gg/frog/mc/permissionstime/PluginMain.java | 2 ++ .../mc/permissionstime/command/MainCommand.java | 2 +- .../mc/permissionstime/database/SqlManager.java | 4 ++-- .../utils/database/DatabaseUtil.java | 13 ++++++++----- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 777f5d5..443d094 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ### 支持跨服的权限限时插件 #### 构建地址:[http://ci.frog.gg/jenkins/job/PermissionsTime/](http://ci.frog.gg/jenkins/job/PermissionsTime/) +#### 前置插件SQLibrary下载地址:[https://dev.bukkit.org/projects/sqlibrary](https://dev.bukkit.org/projects/sqlibrary/) #### 已知问题(作者提醒): @@ -27,6 +28,7 @@ - **gui显示自己的权限包** - 手动删除过期的或无效数据 - 语言支持整理 +- 取消前置插件 - 支持分页? diff --git a/src/main/gg/frog/mc/permissionstime/PluginMain.java b/src/main/gg/frog/mc/permissionstime/PluginMain.java index 2d86468..fbe437d 100644 --- a/src/main/gg/frog/mc/permissionstime/PluginMain.java +++ b/src/main/gg/frog/mc/permissionstime/PluginMain.java @@ -62,10 +62,12 @@ public class PluginMain extends JavaPlugin { getServer().getScheduler().runTask(pm, new Runnable() { public void run() { if (!checkPluginDepends()) { + getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "启动失败!")); getServer().getPluginManager().disablePlugin(pm); } else { registerListeners(); registerCommands(); + getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "启动成功!")); } } }); diff --git a/src/main/gg/frog/mc/permissionstime/command/MainCommand.java b/src/main/gg/frog/mc/permissionstime/command/MainCommand.java index 41450a2..7080f41 100644 --- a/src/main/gg/frog/mc/permissionstime/command/MainCommand.java +++ b/src/main/gg/frog/mc/permissionstime/command/MainCommand.java @@ -29,7 +29,7 @@ public class MainCommand implements CommandExecutor { if (sender instanceof Player) { isPlayer = true; } - if (args[0].equalsIgnoreCase("help") || args.length == 0) { + if (args.length == 0 || args[0].equalsIgnoreCase("help")) { getHelp(sender, isPlayer); return true; } else { diff --git a/src/main/gg/frog/mc/permissionstime/database/SqlManager.java b/src/main/gg/frog/mc/permissionstime/database/SqlManager.java index cc7c67f..fc5b447 100644 --- a/src/main/gg/frog/mc/permissionstime/database/SqlManager.java +++ b/src/main/gg/frog/mc/permissionstime/database/SqlManager.java @@ -28,7 +28,7 @@ public class SqlManager { } public boolean updateDatabase() { - if (db != null && db.isOpen()) { + if (db != null) { db.close(); } if (PluginCfg.USE_MYSQL) { @@ -38,7 +38,7 @@ public class SqlManager { db = new SQLite(PluginMain.LOG, "[" + pm.PLUGIN_NAME + "] ", pm.getDataFolder().getAbsolutePath(), "playerData", ".db"); pds = new SqlitePlayerDataDao(pm, this); } - if(db.open()) { + if (db.open()) { try { if (!pds.tableExist()) { pds.creatTable(); diff --git a/src/main/gg/frog/mc/permissionstime/utils/database/DatabaseUtil.java b/src/main/gg/frog/mc/permissionstime/utils/database/DatabaseUtil.java index 9d311c3..5261471 100644 --- a/src/main/gg/frog/mc/permissionstime/utils/database/DatabaseUtil.java +++ b/src/main/gg/frog/mc/permissionstime/utils/database/DatabaseUtil.java @@ -1,5 +1,6 @@ package gg.frog.mc.permissionstime.utils.database; +import gg.frog.mc.permissionstime.config.PluginCfg; import gg.frog.mc.permissionstime.database.SqlManager; import lib.PatPeter.SQLibrary.Database; @@ -13,13 +14,15 @@ public abstract class DatabaseUtil { protected Database getDB() { Database db = sm.getDb(); - for (int i = 0; i < 3; i++) { - if (!db.isOpen()) { - if (db.open()) { + if (PluginCfg.USE_MYSQL) { + for (int i = 0; i < 3; i++) { + if (!db.isOpen()) { + if (db.open()) { + return db; + } + } else { return db; } - } else { - return db; } } return db;