aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorProf-Bloodstone <[email protected]>2021-05-27 15:25:24 +0200
committerGitHub <[email protected]>2021-05-27 14:25:24 +0100
commitcd4defec04661535af78c27a4b7ed6cc619ecfe8 (patch)
tree03bef238a670527fe37c8ce4516cad0e731a4963
parentb9f2a673d3f71e9005c39edde01cf87436fe60e1 (diff)
downloadPaper-cd4defec04661535af78c27a4b7ed6cc619ecfe8.tar.gz
Paper-cd4defec04661535af78c27a4b7ed6cc619ecfe8.zip
[CI-SKIP] Update version checker to use V2 downloads API (#5728)
-rw-r--r--Spigot-Server-Patches/0019-Implement-Paper-VersionChecker.patch13
-rw-r--r--Spigot-Server-Patches/0020-Add-version-history-to-version-command.patch6
2 files changed, 12 insertions, 7 deletions
diff --git a/Spigot-Server-Patches/0019-Implement-Paper-VersionChecker.patch b/Spigot-Server-Patches/0019-Implement-Paper-VersionChecker.patch
index 8be3bf335e..34f3da9b88 100644
--- a/Spigot-Server-Patches/0019-Implement-Paper-VersionChecker.patch
+++ b/Spigot-Server-Patches/0019-Implement-Paper-VersionChecker.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] Implement Paper VersionChecker
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
new file mode 100644
-index 0000000000000000000000000000000000000000..c8b911e5d013525ffc5d2911ee0e421dd916cb00
+index 0000000000000000000000000000000000000000..1a1b50e475b9ede544b2f6d0d36632b24b68898c
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
-@@ -0,0 +1,117 @@
+@@ -0,0 +1,122 @@
+package com.destroystokyo.paper;
+
+import com.destroystokyo.paper.util.VersionFetcher;
@@ -24,6 +24,7 @@ index 0000000000000000000000000000000000000000..c8b911e5d013525ffc5d2911ee0e421d
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
++import java.util.stream.StreamSupport;
+
+public class PaperVersionFetcher implements VersionFetcher {
+ private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
@@ -84,11 +85,15 @@ index 0000000000000000000000000000000000000000..c8b911e5d013525ffc5d2911ee0e421d
+ if (siteApiVersion == null) { return -1; }
+ try {
+ try (BufferedReader reader = Resources.asCharSource(
-+ new URL("https://papermc.io/api/v1/paper/" + siteApiVersion + "/latest"),
++ new URL("https://papermc.io/api/v2/projects/paper/versions/" + siteApiVersion),
+ Charsets.UTF_8
+ ).openBufferedStream()) {
+ JsonObject json = new Gson().fromJson(reader, JsonObject.class);
-+ int latest = json.get("build").getAsInt();
++ JsonArray builds = json.getAsJsonArray("builds");
++ int latest = StreamSupport.stream(builds.spliterator(), false)
++ .mapToInt(e -> e.getAsInt())
++ .max()
++ .getAsInt();
+ return latest - jenkinsBuild;
+ } catch (JsonSyntaxException ex) {
+ ex.printStackTrace();
diff --git a/Spigot-Server-Patches/0020-Add-version-history-to-version-command.patch b/Spigot-Server-Patches/0020-Add-version-history-to-version-command.patch
index 8ce6b7fea5..a115cf4943 100644
--- a/Spigot-Server-Patches/0020-Add-version-history-to-version-command.patch
+++ b/Spigot-Server-Patches/0020-Add-version-history-to-version-command.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] Add version history to version command
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
-index c8b911e5d013525ffc5d2911ee0e421dd916cb00..dc0ea65ab87255fad0d54dfb509300098a0b4864 100644
+index 1a1b50e475b9ede544b2f6d0d36632b24b68898c..580bae0d414d371a07a6bfeefc41fdd989dc0083 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -5,7 +5,9 @@ import com.google.common.base.Charsets;
@@ -18,7 +18,7 @@ index c8b911e5d013525ffc5d2911ee0e421dd916cb00..dc0ea65ab87255fad0d54dfb50930009
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-@@ -27,7 +29,10 @@ public class PaperVersionFetcher implements VersionFetcher {
+@@ -28,7 +30,10 @@ public class PaperVersionFetcher implements VersionFetcher {
@Override
public Component getVersionMessage(@Nonnull String serverVersion) {
String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
@@ -30,7 +30,7 @@ index c8b911e5d013525ffc5d2911ee0e421dd916cb00..dc0ea65ab87255fad0d54dfb50930009
}
private static @Nullable String getMinecraftVersion() {
-@@ -114,4 +119,19 @@ public class PaperVersionFetcher implements VersionFetcher {
+@@ -119,4 +124,19 @@ public class PaperVersionFetcher implements VersionFetcher {
return -1;
}
}