diff --git a/src/main/src/me/skymc/taboolib/commands/sub/itemlist/listener/ItemLibraryPatch.java b/src/main/src/me/skymc/taboolib/commands/sub/itemlist/listener/ItemLibraryPatch.java index ca6ebfc..e9f5fba 100644 --- a/src/main/src/me/skymc/taboolib/commands/sub/itemlist/listener/ItemLibraryPatch.java +++ b/src/main/src/me/skymc/taboolib/commands/sub/itemlist/listener/ItemLibraryPatch.java @@ -31,7 +31,7 @@ public class ItemLibraryPatch implements Listener { if (e.getInventory().getHolder() instanceof ItemLibraryHolder) { e.setCancelled(true); - if (e.getCurrentItem() == null) { + if (e.getCurrentItem() == null || e.getCurrentItem().getType().equals(Material.AIR)) { return; } diff --git a/src/main/src/me/skymc/taboolib/display/TitleUtils.java b/src/main/src/me/skymc/taboolib/display/TitleUtils.java index 0145ffc..abded02 100644 --- a/src/main/src/me/skymc/taboolib/display/TitleUtils.java +++ b/src/main/src/me/skymc/taboolib/display/TitleUtils.java @@ -36,6 +36,10 @@ public class TitleUtils { return null; } + public static void sendTitle(Player p, String title, String subtitle, int fadein, int stay, int fadeout) { + sendTitle(p, title, fadein, stay, fadeout, subtitle, fadein, stay, fadeout); + } + public static void sendTitle(Player p, String title, int fadeint, int stayt, int fadeoutt, String subtitle, int fadeinst, int stayst, int fadeoutst) { if (title == null) { diff --git a/src/main/src/me/skymc/taboolib/fileutils/ConfigUtils.java b/src/main/src/me/skymc/taboolib/fileutils/ConfigUtils.java index 15443ef..b710be8 100644 --- a/src/main/src/me/skymc/taboolib/fileutils/ConfigUtils.java +++ b/src/main/src/me/skymc/taboolib/fileutils/ConfigUtils.java @@ -27,6 +27,23 @@ public class ConfigUtils { return Base64Coder.encodeLines(file.saveToString().getBytes()).replaceAll("\\s+", ""); } + /** + * 以 UTF-8 的格式释放配置文件并载入 + * + * 录入时间:2018年2月10日21:28:30 + * 录入版本:3.49 + * + * @param plugin + * @return + */ + public static FileConfiguration saveDefaultConfig(Plugin plugin, String name) { + File file = new File(plugin.getDataFolder(), name); + if (!file.exists()) { + plugin.saveResource(name, true); + } + return load(plugin, file); + } + /** * 以 UTF-8 的格式载入配置文件 * @@ -34,7 +51,7 @@ public class ConfigUtils { * @param filename * @return */ - public static YamlConfiguration load(Plugin plugin, File file) { + public static FileConfiguration load(Plugin plugin, File file) { YamlConfiguration yaml = new YamlConfiguration(); try { yaml = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8)); @@ -47,7 +64,7 @@ public class ConfigUtils { } @Deprecated - public static YamlConfiguration load(Plugin plugin, String file) { + public static FileConfiguration load(Plugin plugin, String file) { return load(plugin, FileUtils.file(file)); } } diff --git a/src/main/src/me/skymc/taboolib/inventory/ItemUtils.java b/src/main/src/me/skymc/taboolib/inventory/ItemUtils.java index 1a12e0b..71b24c1 100644 --- a/src/main/src/me/skymc/taboolib/inventory/ItemUtils.java +++ b/src/main/src/me/skymc/taboolib/inventory/ItemUtils.java @@ -93,7 +93,7 @@ public class ItemUtils { } public static void loadItemsFile(File file, boolean finalFile) { - YamlConfiguration conf = ConfigUtils.load(Main.getInst(), file); + FileConfiguration conf = ConfigUtils.load(Main.getInst(), file); for (String name : conf.getConfigurationSection("").getKeys(false)) { if (isExists(name)) { MsgUtils.warn("无法载入载入物品 &4" + name + "&c, 因为它已经存在了"); diff --git a/src/main/src/me/skymc/taboolib/timecycle/TimeCycleInitializeEvent.java b/src/main/src/me/skymc/taboolib/timecycle/TimeCycleInitializeEvent.java index eb7b527..9c1037c 100644 --- a/src/main/src/me/skymc/taboolib/timecycle/TimeCycleInitializeEvent.java +++ b/src/main/src/me/skymc/taboolib/timecycle/TimeCycleInitializeEvent.java @@ -1,5 +1,6 @@ package me.skymc.taboolib.timecycle; +import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -15,6 +16,11 @@ public class TimeCycleInitializeEvent extends Event { this.time = time; } + public TimeCycleInitializeEvent call() { + Bukkit.getPluginManager().callEvent(this); + return this; + } + public Long getTimeline() { return time; } diff --git a/src/main/src/me/skymc/taboolib/timecycle/TimeCycleManager.java b/src/main/src/me/skymc/taboolib/timecycle/TimeCycleManager.java index 515b061..cbf4e90 100644 --- a/src/main/src/me/skymc/taboolib/timecycle/TimeCycleManager.java +++ b/src/main/src/me/skymc/taboolib/timecycle/TimeCycleManager.java @@ -144,19 +144,22 @@ public class TimeCycleManager { for (TimeCycle cycle : cycles.values()) { // 调度器没有被执行过 if (!GlobalDataManager.contains("timecycle:" + cycle.getName())) { - long time = System.currentTimeMillis(); - // 触发器 - TimeCycleInitializeEvent event1 = new TimeCycleInitializeEvent(cycle, time); - Bukkit.getPluginManager().callEvent(event1); + long time = new TimeCycleInitializeEvent(cycle, System.currentTimeMillis()).call().getTimeline(); // 初始化 - GlobalDataManager.setVariable("timecycle:" + cycle.getName(), event1.getTimeline().toString()); + GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time)); // 触发器 Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle)); } - // 可执行 - else if (System.currentTimeMillis() - getAfterTimeline(cycle.getName()) >= cycle.getCycle()) { + // 如果超出刷新时间 + else if (System.currentTimeMillis() >= getAfterTimeline(cycle.getName())) { + long time = System.currentTimeMillis(); + // 如果时间差大于 30 秒 + if (time - getAfterTimeline(cycle.getName()) > 30000) { + // 初始化 + time = new TimeCycleInitializeEvent(cycle, time).call().getTimeline(); + } // 重置 - GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(System.currentTimeMillis())); + GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time)); // 触发器 Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle)); }