版本更新至 3.51
修复:物品列表点击空白处报错 新增:TitleUtils 内方法新增简写方式 新增:ConfigUtils 内新增释放配置方法 新增:TimeCycleInitializeEvent 内新增 canll() 方法 修改:PlayerLoadedEvent 监听器改为异步 修改:ItemUtils 内 loadItemsFile 方法内变量类型修改 修改:TimeCycleManager 算法调整
This commit is contained in:
@@ -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+", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <20><> UTF-8 <20>ĸ<EFBFBD>ʽ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*
|
||||||
|
* ¼<><C2BC>ʱ<EFBFBD>䣺2018<31><38>2<EFBFBD><32>10<31><30>21:28:30
|
||||||
|
* ¼<><C2BC><EFBFBD>汾<EFBFBD><E6B1BE>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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <20><> UTF-8 <20>ĸ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
* <20><> UTF-8 <20>ĸ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
*
|
*
|
||||||
@@ -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("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ &4" + name + "&c, <20><>Ϊ<EFBFBD><CEAA><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
MsgUtils.warn("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ &4" + name + "&c, <20><>Ϊ<EFBFBD><CEAA><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
|||||||
@@ -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()) {
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD>ִ<EFBFBD>й<EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD>ִ<EFBFBD>й<EFBFBD>
|
||||||
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();
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
TimeCycleInitializeEvent event1 = new TimeCycleInitializeEvent(cycle, time);
|
|
||||||
Bukkit.getPluginManager().callEvent(event1);
|
|
||||||
// <20><>ʼ<EFBFBD><CABC>
|
// <20><>ʼ<EFBFBD><CABC>
|
||||||
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), event1.getTimeline().toString());
|
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time));
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
||||||
}
|
}
|
||||||
// <20><>ִ<EFBFBD><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||||
else if (System.currentTimeMillis() - getAfterTimeline(cycle.getName()) >= cycle.getCycle()) {
|
else if (System.currentTimeMillis() >= getAfterTimeline(cycle.getName())) {
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 30 <20><>
|
||||||
|
if (time - getAfterTimeline(cycle.getName()) > 30000) {
|
||||||
|
// <20><>ʼ<EFBFBD><CABC>
|
||||||
|
time = new TimeCycleInitializeEvent(cycle, time).call().getTimeline();
|
||||||
|
}
|
||||||
// <20><><EFBFBD><EFBFBD>
|
// <20><><EFBFBD><EFBFBD>
|
||||||
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(System.currentTimeMillis()));
|
GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time));
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user