2022-03-27 03:00:15 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 26 Mar 2022 21:51:07 -0500
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
2022-06-23 04:37:38 +00:00
index bf42969859545a8a520923ef1836ffa4a5cc24a0..2ee707e109f146c83cdea162c119ea96c0ff4f8f 100644
2022-03-27 03:00:15 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
2022-03-27 04:25:45 +00:00
@@ -4,6 +4,8 @@ import com.destroystokyo.paper.util.VersionFetcher;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.google.gson.*;
+import io.papermc.paper.util.JarManifests;
+import java.util.Map;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
2022-04-18 22:23:52 +00:00
@@ -19,8 +21,8 @@ import java.util.stream.StreamSupport;
2022-03-27 03:00:15 +00:00
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
- private static final String GITHUB_BRANCH_NAME = "master";
2022-04-18 22:23:52 +00:00
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
+ private static final String GITHUB_BRANCH_NAME = getBranch();
2022-06-23 04:37:38 +00:00
+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME;
2022-03-27 03:00:15 +00:00
private static @Nullable String mcVer;
2022-04-18 22:23:52 +00:00
@Override
2022-03-27 04:25:45 +00:00
@@ -31,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher {
2022-03-27 03:00:15 +00:00
@Nonnull
@Override
public Component getVersionMessage(@Nonnull String serverVersion) {
- String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
+ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]");
+ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]);
final Component history = getHistory();
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
2022-04-18 22:23:52 +00:00
@@ -54,15 +56,24 @@ public class PaperVersionFetcher implements VersionFetcher {
2022-03-27 04:25:45 +00:00
return mcVer;
}
2022-03-27 03:57:15 +00:00
2022-04-18 22:23:52 +00:00
+ // Scissors start - Allow getting git information
2022-03-27 04:25:45 +00:00
+ public static String getCommit() {
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
+ return attributes.get("Git-Commit");
+ }
2022-04-18 22:23:52 +00:00
+
+ public static String getBranch() {
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
+ return attributes.get("Git-Branch");
+ }
2022-03-27 04:25:45 +00:00
+ // Scissors end
+
2022-03-27 03:13:07 +00:00
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
int distance;
2022-03-27 03:57:15 +00:00
- try {
2022-03-27 03:13:07 +00:00
- int jenkinsBuild = Integer.parseInt(versionInfo);
2022-03-27 03:57:15 +00:00
- distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
- } catch (NumberFormatException ignored) {
- versionInfo = versionInfo.replace("\"", "");
- distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
- }
+ // Scissors start - always use Git for version checking
2022-03-27 04:25:45 +00:00
+ versionInfo = getCommit();
2022-03-27 03:57:15 +00:00
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
+ // Scissors end
switch (distance) {
case -1:
2022-06-23 04:37:38 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index fbe68bd4739d9a0e7d9bc4c3d5ba8ecfd2d13954..40313b014b4ed5f7e9505bde2827383c19d4377a 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -265,7 +265,7 @@ public class Main {
if (buildDate.before(deadline.getTime())) {
// Paper start - This is some stupid bullshit
System.err.println("*** Warning, you've not updated in a while! ***");
- System.err.println("*** Please download a new build as per instructions from https://papermc.io/downloads ***"); // Paper
+ System.err.println("*** Please download a new build from https://ci.scissors.gg/job/Scissors ***"); // Scissors > // Paper
//System.err.println("*** Server will start in 20 seconds ***");
//Thread.sleep(TimeUnit.SECONDS.toMillis(20));
// Paper End