fix: 修复检测更新时获取版本号错误的问题

This commit is contained in:
2024-03-19 17:57:27 +08:00
parent 98300804fe
commit 03b0d62b19
4 changed files with 65 additions and 63 deletions

View File

@@ -35,7 +35,6 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.logging.Logger;
@SuppressWarnings("CallToPrintStackTrace")
public class HamsterCorePlugin extends JavaPlugin {
@Getter
private static HamsterCorePlugin instance;
@@ -117,26 +116,7 @@ public class HamsterCorePlugin extends JavaPlugin {
sync(() -> {
PointAPI.reloadPlayerPointAPIHook();
VaultAPI.reloadVaultHook();
async(() -> {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
try (InputStream stream = plugin.getResource("plugin.yml")) {
if (stream == null) {
continue;
}
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
YamlConfig config = YamlConfig.load(reader);
ConfigSection section = config.getSection("UPDATE_CHECKER");
if (section == null) {
continue;
}
UpdateCheckUtils.checkUpdate(plugin.getName(), section);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
async(this::checkUpdate);
});
logger.info("仓鼠核心启动完成,总计耗时 " + time + " ms");
}
@@ -165,4 +145,23 @@ public class HamsterCorePlugin extends JavaPlugin {
long time = System.currentTimeMillis() - start;
logger.info("仓鼠核心已关闭,总计耗时 " + time + " ms");
}
private void checkUpdate() {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
try (InputStream stream = plugin.getResource("plugin.yml")) {
if (stream == null) {
continue;
}
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
YamlConfig config = YamlConfig.load(reader);
ConfigSection section = config.getSection("UPDATE_CHECKER");
if (section == null) {
continue;
}
UpdateCheckUtils.checkUpdate(plugin.getName(), section);
}
} catch (Exception ignored) {
}
}
}
}