mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
92 lines
5.1 KiB
Diff
92 lines
5.1 KiB
Diff
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
|
|
index e2f704c115fd6e00960bb56bb0779f1100c89c17..0a821ba42f850b95412c89eba8f66dbf0d6b5c66 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
|
@@ -4,11 +4,13 @@ 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; // Scissors
|
|
import net.kyori.adventure.text.Component;
|
|
import net.kyori.adventure.text.event.ClickEvent;
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
|
import net.kyori.adventure.text.format.TextDecoration;
|
|
import net.kyori.adventure.text.TextComponent;
|
|
+import org.bukkit.Bukkit; // Scissors
|
|
|
|
import javax.annotation.Nonnull;
|
|
import javax.annotation.Nullable;
|
|
@@ -19,8 +21,8 @@ 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
|
|
- private static final String GITHUB_BRANCH_NAME = "master";
|
|
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/paper";
|
|
+ private static final String GITHUB_BRANCH_NAME = getBranch(); // Scissors
|
|
+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME; // Scissors
|
|
private static @Nullable String mcVer;
|
|
|
|
@Override
|
|
@@ -31,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
@Nonnull
|
|
@Override
|
|
public Component getVersionMessage(@Nonnull String serverVersion) {
|
|
- String[] parts = serverVersion.substring("git-Folia-".length()).split("[-\\s]"); // Folia
|
|
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Folia", GITHUB_BRANCH_NAME, parts[0]); // Folia
|
|
+ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]"); // Scissors // Folia
|
|
+ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]); // Scissors // Folia
|
|
final Component history = getHistory();
|
|
|
|
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
|
@@ -54,15 +56,24 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
return mcVer;
|
|
}
|
|
|
|
+ // Scissors start - Allow getting git information
|
|
+ public static String getCommit() {
|
|
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
|
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Commit");
|
|
+ }
|
|
+
|
|
+ public static String getBranch() {
|
|
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
|
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Branch");
|
|
+ }
|
|
+ // Scissors end
|
|
+
|
|
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
|
int distance;
|
|
- try {
|
|
- int jenkinsBuild = Integer.parseInt(versionInfo);
|
|
- distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
|
- } catch (NumberFormatException ignored) {
|
|
- versionInfo = versionInfo.replace("\"", "");
|
|
- distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
|
- }
|
|
+ // Scissors start - always use Git for version checking
|
|
+ versionInfo = getCommit();
|
|
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
|
+ // Scissors end
|
|
|
|
switch (distance) {
|
|
case -1:
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
index 776b7fc26fe96b69be260bbd36efae147d988640..344bef62aa1551a6a09c10492cbc26acb63fa105 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
@@ -292,7 +292,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 ***"); // 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
|