diff --git a/patches/api/0001-Add-getCommit-method-to-Bukkit.patch b/patches/api/0001-Add-getCommit-method-to-Bukkit.patch new file mode 100644 index 0000000..b0eaf78 --- /dev/null +++ b/patches/api/0001-Add-getCommit-method-to-Bukkit.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Telesphoreo +Date: Sat, 26 Mar 2022 23:03:39 -0500 +Subject: [PATCH] Add getCommit() method to Bukkit + + +diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java +index c551010f84ac5d3ebc626c253a8f8282924152c4..80f19df4262958315d50df5104a8fea6d0b33094 100644 +--- a/src/main/java/org/bukkit/Bukkit.java ++++ b/src/main/java/org/bukkit/Bukkit.java +@@ -108,6 +108,13 @@ public final class Bukkit { + // Paper end + } + ++ // Scissors start - Allow getting git commit ++ public static String getCommit() { ++ Map attributes = JarManifests.MANIFEST_MAP; ++ return attributes.get("Git-Commit"); ++ } ++ // Scissors end ++ + /** + * Gets the name of this server implementation. + * diff --git a/patches/server/0017-Change-version-fetcher-to-AMG.patch b/patches/server/0017-Change-version-fetcher-to-AMG.patch index 33cce13..0724a89 100644 --- a/patches/server/0017-Change-version-fetcher-to-AMG.patch +++ b/patches/server/0017-Change-version-fetcher-to-AMG.patch @@ -5,10 +5,14 @@ Subject: [PATCH] Change version fetcher to AMG diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -index ece77f5ea4b14bbed7c070131b3251ea86764538..7437299baa0a8d720e7b374d92530169aed5aa1d 100644 +index ece77f5ea4b14bbed7c070131b3251ea86764538..eabe002dcd1aeacf04b694da2185770f20672d2b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -@@ -19,7 +19,7 @@ import java.util.stream.StreamSupport; +@@ -16,10 +16,11 @@ import java.io.*; + import java.net.HttpURLConnection; + import java.net.URL; + import java.util.stream.StreamSupport; ++import org.bukkit.Bukkit; 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 @@ -17,7 +21,7 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..7437299baa0a8d720e7b374d92530169 private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads"; private static @Nullable String mcVer; -@@ -31,8 +31,8 @@ public class PaperVersionFetcher implements VersionFetcher { +@@ -31,8 +32,8 @@ public class PaperVersionFetcher implements VersionFetcher { @Nonnull @Override public Component getVersionMessage(@Nonnull String serverVersion) { @@ -28,12 +32,21 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..7437299baa0a8d720e7b374d92530169 final Component history = getHistory(); return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; -@@ -57,7 +57,7 @@ public class PaperVersionFetcher implements VersionFetcher { +@@ -56,13 +57,10 @@ public class PaperVersionFetcher implements VersionFetcher { + private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) { int distance; - try { +- try { - int jenkinsBuild = Integer.parseInt(versionInfo); -+ int jenkinsBuild = Integer.parseInt("force-git"); - distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion()); - } catch (NumberFormatException ignored) { - versionInfo = versionInfo.replace("\"", ""); +- distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion()); +- } catch (NumberFormatException ignored) { +- versionInfo = versionInfo.replace("\"", ""); +- distance = fetchDistanceFromGitHub(repo, branch, versionInfo); +- } ++ // Scissors start - always use Git for version checking ++ versionInfo = Bukkit.getCommit(); ++ distance = fetchDistanceFromGitHub(repo, branch, versionInfo); ++ // Scissors end + + switch (distance) { + case -1: