mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
It's muffin time!
This commit is contained in:
@@ -62,10 +62,10 @@ index 7ac34a8959a797bf2af96f3f402fa65cffe3d666..80b7ef7c02c8f99b81a6c33d6d969690
|
||||
public CrashReport b(CrashReport crashreport) {
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurVersionFetcher.java b/src/main/java/net/pl3x/purpur/PurpurVersionFetcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d8b408f061d96e2fa8e2e587462e2221aaee80ce
|
||||
index 0000000000000000000000000000000000000000..cabfcebf9f944f7a2a2a1cffc7401435803a8741
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurVersionFetcher.java
|
||||
@@ -0,0 +1,115 @@
|
||||
@@ -0,0 +1,119 @@
|
||||
+package net.pl3x.purpur;
|
||||
+
|
||||
+import com.destroystokyo.paper.VersionHistoryManager;
|
||||
@@ -75,6 +75,10 @@ index 0000000000000000000000000000000000000000..d8b408f061d96e2fa8e2e587462e2221
|
||||
+import com.google.gson.Gson;
|
||||
+import com.google.gson.JsonObject;
|
||||
+import com.google.gson.JsonSyntaxException;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextDecoration;
|
||||
+
|
||||
+import javax.annotation.Nonnull;
|
||||
+import javax.annotation.Nullable;
|
||||
@@ -95,15 +99,15 @@ index 0000000000000000000000000000000000000000..d8b408f061d96e2fa8e2e587462e2221
|
||||
+
|
||||
+ @Nonnull
|
||||
+ @Override
|
||||
+ public String getVersionMessage(@Nonnull String serverVersion) {
|
||||
+ public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
+ String[] parts = serverVersion.substring("git-Purpur-".length()).split("[-\\s]");
|
||||
+ String updateMessage = getUpdateStatusMessage("pl3xgaming/Purpur", GITHUB_BRANCH_NAME, parts[0]);
|
||||
+ String history = getHistory();
|
||||
+ final Component updateMessage = getUpdateStatusMessage("pl3xgaming/Purpur", GITHUB_BRANCH_NAME, parts[0]);
|
||||
+ final Component history = getHistory();
|
||||
+
|
||||
+ return history != null ? history + "\n" + updateMessage : updateMessage;
|
||||
+ return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||
+ }
|
||||
+
|
||||
+ private static String getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||
+ private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||
+ int distance;
|
||||
+ try {
|
||||
+ int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||
@@ -115,13 +119,13 @@ index 0000000000000000000000000000000000000000..d8b408f061d96e2fa8e2e587462e2221
|
||||
+
|
||||
+ switch (distance) {
|
||||
+ case -1:
|
||||
+ return "Error obtaining version information";
|
||||
+ return Component.text("Error obtaining version information", NamedTextColor.YELLOW);
|
||||
+ case 0:
|
||||
+ return "You are running the latest version";
|
||||
+ return Component.text("You are running the latest version", NamedTextColor.GREEN);
|
||||
+ case -2:
|
||||
+ return "Unknown version";
|
||||
+ return Component.text("Unknown version", NamedTextColor.YELLOW);
|
||||
+ default:
|
||||
+ return "You are " + distance + " version(s) behind";
|
||||
+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -167,7 +171,7 @@ index 0000000000000000000000000000000000000000..d8b408f061d96e2fa8e2e587462e2221
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ private String getHistory() {
|
||||
+ private Component getHistory() {
|
||||
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ if (data == null) {
|
||||
+ return null;
|
||||
@@ -178,7 +182,7 @@ index 0000000000000000000000000000000000000000..d8b408f061d96e2fa8e2e587462e2221
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ return "Previous version: " + oldVersion;
|
||||
+ return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
|
||||
Reference in New Issue
Block a user