2022-03-26 23:00:15 -04: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-03-26 23:57:15 -04:00
index ece77f5ea4b14bbed7c070131b3251ea86764538..eabe002dcd1aeacf04b694da2185770f20672d2b 100644
2022-03-26 23:00:15 -04:00
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
2022-03-26 23:57:15 -04:00
@@ -16,10 +16,11 @@ import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.stream.StreamSupport;
+import org.bukkit.Bukkit;
2022-03-26 23:00:15 -04: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";
+ private static final String GITHUB_BRANCH_NAME = "main";
private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
private static @Nullable String mcVer;
2022-03-26 23:57:15 -04:00
@@ -31,8 +32,8 @@ public class PaperVersionFetcher implements VersionFetcher {
2022-03-26 23:00:15 -04: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-03-26 23:57:15 -04:00
@@ -56,13 +57,10 @@ public class PaperVersionFetcher implements VersionFetcher {
2022-03-26 23:13:07 -04:00
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
int distance;
2022-03-26 23:57:15 -04:00
- try {
2022-03-26 23:13:07 -04:00
- int jenkinsBuild = Integer.parseInt(versionInfo);
2022-03-26 23:57:15 -04:00
- 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: