From c15a26b29bb1b4b80692beccb1b1895c99a24a6e Mon Sep 17 00:00:00 2001 From: 502647092 Date: Wed, 25 Jan 2017 00:27:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=B1=BB=E6=9B=B4=E6=96=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../pw/yumc/YumCore/bukkit/compatible/C.java | 6 ++--- .../pw/yumc/YumCore/commands/CommandMain.java | 2 +- .../pw/yumc/YumCore/commands/CommandSub.java | 4 ++-- .../yumc/YumCore/config/AbstractConfig.java | 22 ++++++++++++----- .../pw/yumc/YumCore/config/FileConfig.java | 24 +++++++++---------- .../java/pw/yumc/YumCore/global/I18N.java | 15 ++++++------ .../java/pw/yumc/YumCore/global/L10N.java | 13 +++++----- src/main/java/pw/yumc/YumCore/kit/PKit.java | 2 +- .../yumc/YumCore/plugin/vault/VaultChat.java | 2 +- .../YumCore/plugin/vault/VaultEconomy.java | 7 +++--- .../YumCore/plugin/vault/VaultPermission.java | 2 +- .../java/pw/yumc/YumCore/sql/DataBase.java | 8 +++---- .../yumc/YumCore/sql/core/DataBaseCore.java | 2 +- 13 files changed, 60 insertions(+), 49 deletions(-) diff --git a/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java b/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java index b2dc923..2937844 100644 --- a/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java +++ b/src/main/java/pw/yumc/YumCore/bukkit/compatible/C.java @@ -56,7 +56,7 @@ public class C { sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet"))); init = true; } catch (Exception e) { - Log.warning("C 兼容性工具初始化失败 可能造成部分功能不可用!"); + Log.w("C 兼容性工具初始化失败 可能造成部分功能不可用!"); Log.d(e); } } @@ -247,7 +247,7 @@ public class C { } // getOnlinePlayers end } catch (Exception e) { - Log.warning("Player 兼容性工具初始化失败 可能造成部分功能不可用!"); + Log.w("Player 兼容性工具初始化失败 可能造成部分功能不可用!"); } try { // getOfflinePlayer start @@ -317,7 +317,7 @@ public class C { packetTitleSendConstructor = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent); packetTitleSetTimeConstructor = packetTitle.getConstructor(packetActions, nmsIChatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE); } catch (Exception ignore) { - Log.warning("Title 兼容性工具初始化失败 可能造成部分功能不可用!"); + Log.w("Title 兼容性工具初始化失败 可能造成部分功能不可用!"); } } diff --git a/src/main/java/pw/yumc/YumCore/commands/CommandMain.java b/src/main/java/pw/yumc/YumCore/commands/CommandMain.java index 846aec9..b1f9edf 100644 --- a/src/main/java/pw/yumc/YumCore/commands/CommandMain.java +++ b/src/main/java/pw/yumc/YumCore/commands/CommandMain.java @@ -91,7 +91,7 @@ public class CommandMain implements CommandExecutor { return true; } catch (ArrayIndexOutOfBoundsException | ClassCastException ignored) { } - Log.warning(String.format(argumentTypeError, method.getName(), clazz.getClass().getName())); + Log.w(argumentTypeError, method.getName(), clazz.getClass().getName()); } return false; } diff --git a/src/main/java/pw/yumc/YumCore/commands/CommandSub.java b/src/main/java/pw/yumc/YumCore/commands/CommandSub.java index 9c55bf4..262421b 100644 --- a/src/main/java/pw/yumc/YumCore/commands/CommandSub.java +++ b/src/main/java/pw/yumc/YumCore/commands/CommandSub.java @@ -265,7 +265,7 @@ public class CommandSub implements TabExecutor { return true; } catch (ArrayIndexOutOfBoundsException | ClassCastException ignored) { } - Log.warning(String.format(argumentTypeError, method.getName(), clazz.getClass().getName())); + Log.w(argumentTypeError, method.getName(), clazz.getClass().getName()); } return false; } @@ -287,7 +287,7 @@ public class CommandSub implements TabExecutor { tabs.add(ti); return true; } - Log.warning(String.format(returnTypeError, method.getName(), clazz.getClass().getName())); + Log.w(returnTypeError, method.getName(), clazz.getClass().getName()); } return false; } diff --git a/src/main/java/pw/yumc/YumCore/config/AbstractConfig.java b/src/main/java/pw/yumc/YumCore/config/AbstractConfig.java index 591fb53..1553356 100644 --- a/src/main/java/pw/yumc/YumCore/config/AbstractConfig.java +++ b/src/main/java/pw/yumc/YumCore/config/AbstractConfig.java @@ -1,6 +1,17 @@ package pw.yumc.YumCore.config; -import com.google.common.io.Files; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.Writer; +import java.nio.charset.Charset; +import java.util.Map; + import org.apache.commons.lang.Validate; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -9,15 +20,14 @@ import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.representer.Representer; + +import com.google.common.io.Files; + import pw.yumc.YumCore.bukkit.Log; import pw.yumc.YumCore.bukkit.P; import pw.yumc.YumCore.config.yaml.BukkitConstructor; import pw.yumc.YumCore.config.yaml.BukkitRepresenter; -import java.io.*; -import java.nio.charset.Charset; -import java.util.Map; - /** * 抽象配置文件 * @@ -99,7 +109,7 @@ public abstract class AbstractConfig extends YamlConfiguration { Files.createParentDirs(file); if (!file.exists()) { file.createNewFile(); - Log.info(String.format(CREATE_NEW_CONFIG, file.toPath())); + Log.i(CREATE_NEW_CONFIG, file.toPath()); } try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF_8)) { writer.write(data); diff --git a/src/main/java/pw/yumc/YumCore/config/FileConfig.java b/src/main/java/pw/yumc/YumCore/config/FileConfig.java index 0f87545..36de5d4 100644 --- a/src/main/java/pw/yumc/YumCore/config/FileConfig.java +++ b/src/main/java/pw/yumc/YumCore/config/FileConfig.java @@ -374,7 +374,7 @@ public class FileConfig extends AbstractConfig { this.save(file); return true; } catch (IOException e) { - Log.warning(String.format(CONFIG_SAVE_ERROR, file.getName())); + Log.w(CONFIG_SAVE_ERROR, file.getName()); e.printStackTrace(); return false; } @@ -414,12 +414,12 @@ public class FileConfig extends AbstractConfig { } else { plugin.saveResource(filename, true); } - Log.warning(String.format(CONFIG_BACKUP_AND_RESET, filename, errFileName)); + Log.w(CONFIG_BACKUP_AND_RESET, filename, errFileName); } catch (IOException | IllegalArgumentException e) { throw new IllegalArgumentException(e); } } else { - Log.warning(String.format(CONFIG_NOT_FOUND_IN_JAR, file != null ? file.getName() : "")); + Log.w(CONFIG_NOT_FOUND_IN_JAR, file != null ? file.getName() : ""); } } @@ -435,9 +435,9 @@ public class FileConfig extends AbstractConfig { String newCfgName = this.getBakName(filename); File newcfg = new File(file.getParent(), newCfgName); oldcfg.save(newcfg); - Log.warning(String.format(CONFIG_BACKUP, filename, newCfgName)); + Log.w(CONFIG_BACKUP, filename, newCfgName); } catch (IOException e) { - Log.warning(String.format(CONFIG_BACKUP_ERROR, filename, e.getMessage())); + Log.w(CONFIG_BACKUP_ERROR, filename, e.getMessage()); Log.d(oldcfg.getConfigName(), e); } } @@ -469,7 +469,7 @@ public class FileConfig extends AbstractConfig { } } } catch (IOException e) { - Log.warning(String.format(CONFIG_CREATE_ERROR, filename)); + Log.w(CONFIG_CREATE_ERROR, filename); } } @@ -543,12 +543,12 @@ public class FileConfig extends AbstractConfig { this.load(new InputStreamReader(stream, UTF_8)); } catch (InvalidConfigurationException | IllegalArgumentException ex) { if (file == null) { throw new IllegalArgumentException(ex); } - Log.warning(String.format(CONFIG_FORMAT_ERROR, file.getName())); - Log.warning(ex.getMessage()); + Log.w(CONFIG_FORMAT_ERROR, file.getName()); + Log.w(ex.getMessage()); saveFromJar(); } catch (IOException ex) { if (file == null) { throw new IllegalStateException(ex); } - Log.warning(String.format(CONFIG_READ_ERROR, file.getName())); + Log.w(CONFIG_READ_ERROR, file.getName()); } return this; } @@ -595,12 +595,12 @@ public class FileConfig extends AbstractConfig { String newver = newCfg.getString(VERSION); String oldver = oldCfg.getString(VERSION); Set oldConfigKeys = oldCfg.getKeys(true); - Log.warning(String.format(CONFIG_UPDATE_WARN, filename, oldver, newver)); + Log.w(CONFIG_UPDATE_WARN, filename, oldver, newver); // 保留版本字段 不更新 oldConfigKeys.remove(VERSION); // 强制更新 去除新版本存在的字段 if (force) { - Log.warning(String.format(CONFIG_OVERRIDE, filename)); + Log.w(CONFIG_OVERRIDE, filename); oldConfigKeys.removeAll(newCfg.getKeys(true)); } // 复制旧的数据 @@ -616,7 +616,7 @@ public class FileConfig extends AbstractConfig { newCfg.set(string, var); } } - Log.info(String.format(CONFIG_UPDATED, filename, newver)); + Log.i(CONFIG_UPDATED, filename, newver); return newCfg; } } diff --git a/src/main/java/pw/yumc/YumCore/global/I18N.java b/src/main/java/pw/yumc/YumCore/global/I18N.java index a909530..ba1e399 100644 --- a/src/main/java/pw/yumc/YumCore/global/I18N.java +++ b/src/main/java/pw/yumc/YumCore/global/I18N.java @@ -1,12 +1,13 @@ package pw.yumc.YumCore.global; -import org.bukkit.command.CommandSender; -import pw.yumc.YumCore.bukkit.Log; -import pw.yumc.YumCore.config.ext.YumConfig; - import java.util.HashMap; import java.util.Map; +import org.bukkit.command.CommandSender; + +import pw.yumc.YumCore.bukkit.Log; +import pw.yumc.YumCore.config.ext.YumConfig; + /** * 国际化工具类 * Created by 喵♂呜 on 2016/10/14 0014. @@ -17,7 +18,7 @@ public class I18N { static { content = new HashMap<>(); - Log.info("Async init I18N tool ..."); + Log.i("Async init I18N tool ..."); load(); } @@ -64,9 +65,9 @@ public class I18N { if (remote != null) { content.putAll(remote); } - Log.info("本地化工具初始化完毕..."); + Log.i("本地化工具初始化完毕..."); } catch (Exception e) { - Log.warning(String.format("本地化工具初始化失败: %s %s", e.getClass().getName(), e.getMessage())); + Log.w("本地化工具初始化失败: %s %s", e.getClass().getName(), e.getMessage()); Log.d(LANG, e); } } diff --git a/src/main/java/pw/yumc/YumCore/global/L10N.java b/src/main/java/pw/yumc/YumCore/global/L10N.java index b7eb806..2e86459 100644 --- a/src/main/java/pw/yumc/YumCore/global/L10N.java +++ b/src/main/java/pw/yumc/YumCore/global/L10N.java @@ -24,7 +24,7 @@ public class L10N { static { content = new HashMap<>(); - Log.info("异步初始化本地化工具..."); + Log.i("异步初始化本地化工具..."); load(); } @@ -68,7 +68,7 @@ public class L10N { * 重载LocalUtil */ public static void reload() { - Log.info("异步重载本地化工具..."); + Log.i("异步重载本地化工具..."); content.clear(); load(); } @@ -116,23 +116,22 @@ public class L10N { */ private static void load() { new Thread(new Runnable() { - @SuppressWarnings("unchecked") @Override public void run() { try { Map local = YumConfig.getLocal(CONFIG_NAME).getContentMap(); if (local != null) { - Log.info("本地汉化文件词条数量: " + local.size()); + Log.i("本地汉化文件词条数量: " + local.size()); content.putAll(local); } Map remote = YumConfig.getRemote(CONFIG_NAME).getContentMap(); if (remote != null) { - Log.info("远程汉化文件词条数量: " + remote.size()); + Log.i("远程汉化文件词条数量: " + remote.size()); content.putAll(remote); } - Log.info("本地化工具初始化完毕..."); + Log.i("本地化工具初始化完毕..."); } catch (Exception e) { - Log.warning(String.format("本地化工具初始化失败: %s %s", e.getClass().getName(), e.getMessage())); + Log.w("本地化工具初始化失败: %s %s", e.getClass().getName(), e.getMessage()); Log.d(CONFIG_NAME, e); } } diff --git a/src/main/java/pw/yumc/YumCore/kit/PKit.java b/src/main/java/pw/yumc/YumCore/kit/PKit.java index 9cbb106..40c8ebf 100644 --- a/src/main/java/pw/yumc/YumCore/kit/PKit.java +++ b/src/main/java/pw/yumc/YumCore/kit/PKit.java @@ -33,7 +33,7 @@ public class PKit { * 关闭提示 */ public static void disable(String msg) { - Log.warning(msg); + Log.w(msg); disable(); } diff --git a/src/main/java/pw/yumc/YumCore/plugin/vault/VaultChat.java b/src/main/java/pw/yumc/YumCore/plugin/vault/VaultChat.java index e5c0487..c0fe130 100644 --- a/src/main/java/pw/yumc/YumCore/plugin/vault/VaultChat.java +++ b/src/main/java/pw/yumc/YumCore/plugin/vault/VaultChat.java @@ -22,7 +22,7 @@ public class VaultChat extends VaultBase { if (rsp == null || (chat = rsp.getProvider()) == null) { PKit.disable("已加载 Vault 但是未找到聊天相关插件 停止加载..."); } else { - Log.info("发现 Vault 使用聊天管理系统 " + chat.getName()); + Log.i("发现 Vault 使用聊天管理系统 " + chat.getName()); } } diff --git a/src/main/java/pw/yumc/YumCore/plugin/vault/VaultEconomy.java b/src/main/java/pw/yumc/YumCore/plugin/vault/VaultEconomy.java index 3c602eb..5259b20 100644 --- a/src/main/java/pw/yumc/YumCore/plugin/vault/VaultEconomy.java +++ b/src/main/java/pw/yumc/YumCore/plugin/vault/VaultEconomy.java @@ -1,10 +1,11 @@ package pw.yumc.YumCore.plugin.vault; -import net.milkbowl.vault.economy.Economy; -import net.milkbowl.vault.economy.EconomyResponse; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.plugin.RegisteredServiceProvider; + +import net.milkbowl.vault.economy.Economy; +import net.milkbowl.vault.economy.EconomyResponse; import pw.yumc.YumCore.bukkit.Log; import pw.yumc.YumCore.kit.PKit; @@ -22,7 +23,7 @@ public class VaultEconomy extends VaultBase { if (rsp == null || (economy = rsp.getProvider()) == null) { PKit.disable("已加载 Vault 但是未找到经济相关插件 停止加载..."); } else { - Log.info("发现 Vault 使用经济管理系统 " + economy.getName()); + Log.i("发现 Vault 使用经济管理系统 " + economy.getName()); } } diff --git a/src/main/java/pw/yumc/YumCore/plugin/vault/VaultPermission.java b/src/main/java/pw/yumc/YumCore/plugin/vault/VaultPermission.java index 1b4c8e1..64fc3fa 100644 --- a/src/main/java/pw/yumc/YumCore/plugin/vault/VaultPermission.java +++ b/src/main/java/pw/yumc/YumCore/plugin/vault/VaultPermission.java @@ -22,7 +22,7 @@ public class VaultPermission extends VaultBase { if (rsp == null || (permission = rsp.getProvider()) == null) { PKit.disable("已加载 Vault 但是未找到权限相关插件 停止加载..."); } else { - Log.info("发现 Vault 使用权限管理系统 " + permission.getName()); + Log.i("发现 Vault 使用权限管理系统 " + permission.getName()); } } diff --git a/src/main/java/pw/yumc/YumCore/sql/DataBase.java b/src/main/java/pw/yumc/YumCore/sql/DataBase.java index d3d665d..6916cc6 100644 --- a/src/main/java/pw/yumc/YumCore/sql/DataBase.java +++ b/src/main/java/pw/yumc/YumCore/sql/DataBase.java @@ -82,7 +82,7 @@ public class DataBase { try { String src = this.dataBaseCore.getConnection().getMetaData().getURL(); String des = db.getConnection().getMetaData().getURL(); - Log.info("开始从源 " + src + " 复制数据到 " + des + " ..."); + Log.i("开始从源 " + src + " 复制数据到 " + des + " ..."); ResultSet rs = this.dataBaseCore.getConnection().getMetaData().getTables(null, null, "%", null); List tables = new LinkedList<>(); while (rs.next()) { @@ -93,11 +93,11 @@ public class DataBase { int s = 0; long start = System.currentTimeMillis(); for (String table : tables) { - Log.info("开始复制源数据库中的表 " + table + " ..."); + Log.i("开始复制源数据库中的表 " + table + " ..."); if (table.toLowerCase().startsWith("sqlite_autoindex_")) { continue; } - Log.info("清空目标数据库中的表 " + table + " ..."); + Log.i("清空目标数据库中的表 " + table + " ..."); db.execute("DELETE FROM " + table); rs = this.dataBaseCore.query("SELECT * FROM " + table); int n = 0; @@ -487,7 +487,7 @@ public class DataBase { } private void info(String info) { - Log.info(info); + Log.i(info); } public static class DataBaseParse implements Parse { diff --git a/src/main/java/pw/yumc/YumCore/sql/core/DataBaseCore.java b/src/main/java/pw/yumc/YumCore/sql/core/DataBaseCore.java index 857a068..cb880c3 100644 --- a/src/main/java/pw/yumc/YumCore/sql/core/DataBaseCore.java +++ b/src/main/java/pw/yumc/YumCore/sql/core/DataBaseCore.java @@ -144,7 +144,7 @@ public abstract class DataBaseCore { * 警告消息 */ public void warn(String warn) { - Log.warning(warn); + Log.w(warn); } /**