- Removed roguelike perk system (double jump, magnet, shield, second chance) - Updated bStats dependency to 3.2.1 with proper relocation - Changed bStats plugin ID to 29754 - Added new game modes: Speedrun, Gravity Shift, Hardcore - Implemented .lpschem format with GZIP + JSON compression - Added JumpValidator for physics-based jump validation - Added JumpType system (neo-jump, head-hitter, fence, trapdoor, ladder) - Implemented Ghost system for recording/playback top players - Added loparkour-vilib as local dependency - Updated config with new mode settings and removed roguelike section - Cleaned up TODO.md roadmap
56 lines
2 KiB
Java
56 lines
2 KiB
Java
package dev.efnilite.vilib.util;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import java.net.URI;
|
|
import java.net.http.HttpClient;
|
|
import java.net.http.HttpRequest;
|
|
import java.net.http.HttpResponse;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
public class UpdateChecker {
|
|
|
|
public static void check(Plugin plugin, int resourceId) {
|
|
Task.create(plugin)
|
|
.async()
|
|
.execute(() -> {
|
|
HttpClient client = HttpClient.newHttpClient();
|
|
HttpRequest request = HttpRequest.newBuilder()
|
|
.uri(URI.create("https://api.spiget.org/v2/resources/%s/versions/latest".formatted(resourceId)))
|
|
.build();
|
|
|
|
plugin.getLogger().info("Checking for updates");
|
|
|
|
var tag = client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
|
|
.thenApply(HttpResponse::body)
|
|
.thenApply(UpdateChecker::parseLatestTag)
|
|
.join();
|
|
|
|
if (tag.isEmpty()) {
|
|
plugin.getLogger().info("Failed to check for updates");
|
|
return;
|
|
}
|
|
|
|
var version = plugin.getDescription().getVersion();
|
|
if (!version.equals(tag)) {
|
|
plugin.getLogger().info("A new version is available: %s -> %s".formatted(version, tag));
|
|
plugin.getLogger().info("Download at https://spigotmc.org/resources/%s".formatted(resourceId));
|
|
} else {
|
|
plugin.getLogger().info("No new version found");
|
|
}
|
|
})
|
|
.run();
|
|
}
|
|
|
|
private static String parseLatestTag(String responseBody) {
|
|
Pattern pattern = Pattern.compile("\"name\": ?\"(.*?)\"");
|
|
Matcher matcher = pattern.matcher(responseBody);
|
|
|
|
if (matcher.find()) {
|
|
return matcher.group(1);
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
}
|