From 311e749723af7ad6edefcd8c4bc5396eafc61a74 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Sun, 17 May 2015 12:47:37 +0800 Subject: [PATCH] fix can't zhuanhuan date... Signed-off-by: j502647092 --- src/cn/citycraft/plugins/MainCommand.java | 41 ++++++++++------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/cn/citycraft/plugins/MainCommand.java b/src/cn/citycraft/plugins/MainCommand.java index b2c4790..5e0d411 100644 --- a/src/cn/citycraft/plugins/MainCommand.java +++ b/src/cn/citycraft/plugins/MainCommand.java @@ -12,12 +12,12 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import cn.citycraft.Utils.config.FileConfig; +import cn.citycraft.Utils.config.PlayerConfig; import cn.citycraft.plugins.util.MysqlFunctions; import cn.citycraft.plugins.util.RBUtil; import cn.citycraft.plugins.util.Serialization; @@ -28,15 +28,14 @@ public class MainCommand implements CommandExecutor { private boolean exist = false; - private String[] helps = new String[]{ - "§6====== 真实背包插件 By:喵♂呜 ======", - "§4* §a查看可购买列表 §7/rb list ", - "§4* §a购买背包 §7/rb buy <背包名称> ", - "§4* §a给玩家指定背包 §7/rb give <玩家名称> <背包名称>", - "§4* §a查看玩家指定背包 §7/rb view <玩家名称> <背包名称>" , - "§4* §a数据转移至MySQL §7/rb filetomysql" - }; - + private String[] helps = new String[] { + "§6====== 真实背包插件 By:喵♂呜 ======", + "§4* §a查看可购买列表 §7/rb list ", + "§4* §a购买背包 §7/rb buy <背包名称> ", + "§4* §a给玩家指定背包 §7/rb give <玩家名称> <背包名称>", + "§4* §a查看玩家指定背包 §7/rb view <玩家名称> <背包名称>", + "§4* §a数据转移至MySQL §7/rb filetomysql" }; + public MainCommand(final RealBackpacks plugin) { this.plugin = plugin; } @@ -112,8 +111,7 @@ public class MainCommand implements CommandExecutor { final ItemStack backpackItem = plugin.backpackItems .get(backpack); if (inv.firstEmpty() != -1) { - RealBackpacks.econ.withdrawPlayer(p.getName(), - price); + RealBackpacks.econ.withdrawPlayer(p.getName(), price); if (plugin.backpackData.get(backpack).get(18) != null && plugin.backpackData.get(backpack).get(18) .equalsIgnoreCase("true")) { @@ -123,8 +121,7 @@ public class MainCommand implements CommandExecutor { && plugin.backpackData.get(backpack) .get(17).equalsIgnoreCase("true")) { inv.setItem(inv.firstEmpty(), - RealBackpacks.NMS - .addGlow(backpackItem)); + RealBackpacks.NMS.addGlow(backpackItem)); } else { inv.setItem(inv.firstEmpty(), backpackItem); } @@ -251,8 +248,7 @@ public class MainCommand implements CommandExecutor { && plugin.backpackData.get(backpack) .get(17).equalsIgnoreCase("true")) { inv.setItem(inv.firstEmpty(), - RealBackpacks.NMS - .addGlow(backpackItem)); + RealBackpacks.NMS.addGlow(backpackItem)); } else { inv.setItem(inv.firstEmpty(), backpackItem); } @@ -305,11 +301,12 @@ public class MainCommand implements CommandExecutor { int i = 0, times = 0; final int files = dir.listFiles().length; for (final File child : dir.listFiles()) { - final FileConfiguration config = YamlConfiguration - .loadConfiguration(child); final String player = child .getName().replace(".yml", ""); + final FileConfig config = PlayerConfig + .getInstance(plugin, player); + i++; PreparedStatement statement = null; PreparedStatement state = null; @@ -426,7 +423,6 @@ public class MainCommand implements CommandExecutor { if (!plugin.isUsingMysql()) { boolean fileExists = false; String fullName = null; - File file = null; final File dir = new File(plugin.getDataFolder() + File.separator + "userdata"); for (final File f : dir.listFiles()) { @@ -434,7 +430,6 @@ public class MainCommand implements CommandExecutor { fullName = fileName.replace(".yml", ""); if (fullName.equalsIgnoreCase(name)) { name = fullName; - file = f; fileExists = true; break; } @@ -444,8 +439,8 @@ public class MainCommand implements CommandExecutor { + "这货从来没打开过背包,所以是空的,2333."); return false; } - final FileConfiguration config = YamlConfiguration - .loadConfiguration(file); + final FileConfig config = PlayerConfig + .getInstance(plugin, fullName); if (config.getStringList(backpack + ".Inventory") == null) { inv = plugin.getServer().createInventory( p,