版本更新至 3.51
修复:物品列表点击空白处报错 新增:TitleUtils 内方法新增简写方式 新增:ConfigUtils 内新增释放配置方法 新增:TimeCycleInitializeEvent 内新增 canll() 方法 修改:PlayerLoadedEvent 监听器改为异步 修改:ItemUtils 内 loadItemsFile 方法内变量类型修改 修改:TimeCycleManager 算法调整
This commit is contained in:
parent
d647380491
commit
cc005483c5
@ -31,7 +31,7 @@ public class ItemLibraryPatch implements Listener {
|
|||||||
if (e.getInventory().getHolder() instanceof ItemLibraryHolder) {
|
if (e.getInventory().getHolder() instanceof ItemLibraryHolder) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if (e.getCurrentItem() == null) {
|
if (e.getCurrentItem() == null || e.getCurrentItem().getType().equals(Material.AIR)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@ public class TitleUtils {
|
|||||||
return null;
|
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)
|
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) {
|
if (title == null) {
|
||||||
|
@ -27,6 +27,23 @@ public class ConfigUtils {
|
|||||||
return Base64Coder.encodeLines(file.saveToString().getBytes()).replaceAll("\\s+", "");
|
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 的格式载入配置文件
|
* 以 UTF-8 的格式载入配置文件
|
||||||
*
|
*
|
||||||
@ -34,7 +51,7 @@ public class ConfigUtils {
|
|||||||
* @param filename
|
* @param filename
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static YamlConfiguration load(Plugin plugin, File file) {
|
public static FileConfiguration load(Plugin plugin, File file) {
|
||||||
YamlConfiguration yaml = new YamlConfiguration();
|
YamlConfiguration yaml = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
yaml = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8));
|
yaml = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8));
|
||||||
@ -47,7 +64,7 @@ public class ConfigUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static YamlConfiguration load(Plugin plugin, String file) {
|
public static FileConfiguration load(Plugin plugin, String file) {
|
||||||
return load(plugin, FileUtils.file(file));
|
return load(plugin, FileUtils.file(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadItemsFile(File file, boolean finalFile) {
|
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)) {
|
for (String name : conf.getConfigurationSection("").getKeys(false)) {
|
||||||
if (isExists(name)) {
|
if (isExists(name)) {
|
||||||
MsgUtils.warn("无法载入载入物品 &4" + name + "&c, 因为它已经存在了");
|
MsgUtils.warn("无法载入载入物品 &4" + name + "&c, 因为它已经存在了");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.skymc.taboolib.timecycle;
|
package me.skymc.taboolib.timecycle;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
@ -15,6 +16,11 @@ public class TimeCycleInitializeEvent extends Event {
|
|||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimeCycleInitializeEvent call() {
|
||||||
|
Bukkit.getPluginManager().callEvent(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getTimeline() {
|
public Long getTimeline() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
@ -144,19 +144,22 @@ public class TimeCycleManager {
|
|||||||
for (TimeCycle cycle : cycles.values()) {
|
for (TimeCycle cycle : cycles.values()) {
|
||||||
// 调度器没有被执行过
|
// 调度器没有被执行过
|
||||||
if (!GlobalDataManager.contains("timecycle:" + cycle.getName())) {
|
if (!GlobalDataManager.contains("timecycle:" + cycle.getName())) {
|
||||||
long time = System.currentTimeMillis();
|
long time = new TimeCycleInitializeEvent(cycle, System.currentTimeMillis()).call().getTimeline();
|
||||||
// ´¥·¢Æ÷
|
|
||||||
TimeCycleInitializeEvent event1 = new TimeCycleInitializeEvent(cycle, time);
|
|
||||||
Bukkit.getPluginManager().callEvent(event1);
|
|
||||||
// 初始化
|
// 初始化
|
||||||
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), event1.getTimeline().toString());
|
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time));
|
||||||
// 触发器
|
// 触发器
|
||||||
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
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));
|
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user