13
0
geforkt von Mirrors/Paper

Add download link to the /version command (#6482)

* Add download link to /version command

* Change colors
Dieser Commit ist enthalten in:
HexedHero 2021-10-06 16:14:03 +01:00
Ursprung 8596d6dad5
Commit 16088745e1
2 geänderte Dateien mit 11 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -8,13 +8,12 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/sr
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -0,0 +0,0 @@ import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.google.gson.*;
@@ -0,0 +0,0 @@ import com.google.gson.*;
import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TextComponent;
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 javax.annotation.Nonnull;
import javax.annotation.Nullable;

Datei anzeigen

@ -17,6 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import com.google.common.io.Resources;
+import com.google.gson.*;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.event.ClickEvent;
+import net.kyori.adventure.text.format.NamedTextColor;
+
+import javax.annotation.Nonnull;
@ -29,6 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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";
+ private static @Nullable String mcVer;
+
+ @Override
@ -77,7 +79,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ case -2:
+ return Component.text("Unknown version", NamedTextColor.YELLOW);
+ default:
+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW);
+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW)
+ .append(Component.newline())
+ .append(Component.text("Download the new version at: ")
+ .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.GOLD)
+ .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE))
+ .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE))));
+ }
+ }
+