版本更新至 3.51

修复:物品列表点击空白处报错
新增:TitleUtils 内方法新增简写方式
新增:ConfigUtils 内新增释放配置方法
新增:TimeCycleInitializeEvent 内新增 canll() 方法
修改:PlayerLoadedEvent 监听器改为异步
修改:ItemUtils 内 loadItemsFile 方法内变量类型修改
修改:TimeCycleManager 算法调整
master
坏黑 2018-02-12 14:58:49 +08:00
parent d647380491
commit cc005483c5
6 changed files with 42 additions and 12 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -27,6 +27,23 @@ public class ConfigUtils {
return Base64Coder.encodeLines(file.saveToString().getBytes()).replaceAll("\\s+", "");
}
/**
* UTF-8
*
* 201821021: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));
}
}

View File

@ -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, 因为它已经存在了");

View File

@ -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;
}

View File

@ -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));
}