TabooLib v.4.325
+ 修复 TConfiguration 失效的问题 + 修复 PathfinderExecutor 工具中部分方法无法使用的问题 + 修复自动更新的问题
This commit is contained in:
@@ -4,12 +4,17 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.ilummc.tlib.resources.TLocale;
|
||||
import com.ilummc.tlib.util.Strings;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.player.PlayerUtils;
|
||||
import me.skymc.taboolib.plugin.PluginUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author sky
|
||||
* @since 2018年2月23日 下午10:39:14
|
||||
@@ -19,14 +24,6 @@ public class UpdateTask {
|
||||
private static boolean haveUpdate = false;
|
||||
private static double newVersion = 0;
|
||||
|
||||
public static boolean isHaveUpdate() {
|
||||
return haveUpdate;
|
||||
}
|
||||
|
||||
public static double getNewVersion() {
|
||||
return newVersion;
|
||||
}
|
||||
|
||||
public UpdateTask() {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@@ -35,13 +32,11 @@ public class UpdateTask {
|
||||
if (!Main.getInst().getConfig().getBoolean("UPDATE-CHECK")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String value = FileUtils.getStringFromURL("https://api.github.com/repos/Bkm016/TabooLib/tags", null);
|
||||
if (value == null) {
|
||||
TLocale.Logger.error("UPDATETASK.VERSION-FAIL");
|
||||
return;
|
||||
}
|
||||
|
||||
JsonElement json = new JsonParser().parse(value);
|
||||
if (json.isJsonArray()) {
|
||||
JsonObject latestObject = json.getAsJsonArray().get(0).getAsJsonObject();
|
||||
@@ -51,18 +46,39 @@ public class UpdateTask {
|
||||
} else {
|
||||
haveUpdate = true;
|
||||
TLocale.Logger.info("UPDATETASK.VERSION-OUTDATED", String.valueOf(TabooLib.getPluginVersion()), String.valueOf(newVersion));
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Main.getInst().getConfig().getBoolean("UPDATE-DOWNLOAD", false)) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "taboolib updatePlugin");
|
||||
}
|
||||
}
|
||||
}.runTask(Main.getInst());
|
||||
Bukkit.getScheduler().runTask(TabooLib.instance(), () -> updatePlugin(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(Main.getInst(), 100, 20 * 60 * 60 * 6);
|
||||
}
|
||||
|
||||
public static boolean isHaveUpdate() {
|
||||
return haveUpdate;
|
||||
}
|
||||
|
||||
public static double getNewVersion() {
|
||||
return newVersion;
|
||||
}
|
||||
|
||||
public static void updatePlugin(boolean shutdown) {
|
||||
if (!UpdateTask.isHaveUpdate()) {
|
||||
TLocale.Logger.info("COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-NOT-FOUND");
|
||||
return;
|
||||
}
|
||||
if (PlayerUtils.getOnlinePlayers().size() > 0) {
|
||||
TLocale.Logger.info("COMMANDS.TABOOLIB.UPDATEPLUGIN.PLAYER-ONLINE");
|
||||
return;
|
||||
}
|
||||
File pluginFile = PluginUtils.getPluginFile(Main.getInst());
|
||||
if (pluginFile == null) {
|
||||
TLocale.Logger.info("COMMANDS.TABOOLIB.UPDATEPLUGIN.FILE-NOT-FOUND");
|
||||
return;
|
||||
}
|
||||
FileUtils.download(Strings.replaceWithOrder("https://github.com/Bkm016/TabooLib/releases/download/{0}/TabooLib-{0}.jar", UpdateTask.getNewVersion()), pluginFile);
|
||||
TLocale.Logger.info("COMMANDS.TABOOLIB.UPDATEPLUGIN.UPDATE-SUCCESS");
|
||||
if (shutdown) {
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user