Yatopia/patches/Purpur/patches/server/0002-Rebrand.patch
Simon Gardling 76a75f866b
upstream (#455)
* Updated Upstream and Sidestream(s) (Paper)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
d15161114 [Auto] Updated Upstream (Spigot)
e8889e96a [Auto] Updated Upstream (CraftBukkit)
3bc888ba6 [Auto] Updated Upstream (CraftBukkit)

* Updated Upstream and Sidestream(s) (Paper)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
3fea87edb [Auto] Updated Upstream (CraftBukkit)
a111b1365 Send post ChatEvent messages as MessageType.CHAT

* Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
3db3aaf39 [Auto] Updated Upstream (CraftBukkit)
c953e51dd [Auto] Updated Upstream (CraftBukkit/Spigot)
dc529c7a9 Fix PlayerEditBookEvent (#5463)

Tuinity Changes:
a0aa5ab Do not load 1 radius neighbours for lighting
5ccfa52 Fix terrible patch times
af53d70 Stop large move vectors in player packet handling from killing the server
6e56ee7 Fix OBFHELPER for flushHeader in RegionFile
995d05c Do not update TE's in generating chunks

Purpur Changes:
2e66f83 [ci-skip] Fix typo
6cbe4fc Change Logo Tuinity to Purpur
5e89d23 Updated Upstream (Paper & Airplane)

* Updated Upstream and Sidestream(s) (Paper)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
304a216ba [CI-SKIP] Ignore gitignore when adding files in automation
d8e384a16 [CI-SKIP] Drop `Allow PlayerEditBookEvent to fire for off hand` (#5471)

* fix kotlin-stdlib dependency

* update dependencies

* how did that happen...

* Updated Upstream and Sidestream(s) (Paper)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
de138fac4 [Auto] Updated Upstream (Bukkit)

* Updated Upstream and Sidestream(s) (Paper/Tuinity/Airplane)

Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Paper Changes:
4492bc4cc remove l4j class no longer in existence from preload list
be1370517 Updated Upstream (CraftBukkit) (#5484)
d560151ec Bump mysql-connector-java to 8.0.23 (Fixes #5473) (#5474)
61f400f11 Update log4j to 2.11.2 for JDK 9+ compat (#5400)
a98196585 Updated Upstream (Bukkit/CraftBukkit)

Tuinity Changes:
d5261ad Do not load chunks for getCubes by default
da9cf98 Don't read neighbour chunk data off disk when converting chunks

Airplane Changes:
8de8e82 Updated Upstream (Tuinity)
2021-04-12 13:27:14 -04:00

271 lines
13 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 4 May 2019 01:02:11 -0500
Subject: [PATCH] Rebrand
diff --git a/pom.xml b/pom.xml
index 8a73569a4927e046940e5c12ad75ab071ea8aa91..cea712b94bb32ccda2895670859839d660bd0748 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,8 +39,10 @@
<dependencies>
<dependency>
- <groupId>gg.airplane</groupId>
- <artifactId>airplane-api</artifactId>
+ <!-- Purpur start - our "upstream" is Paper (not Tuinity), so this is necessary for DependencyLoading.kt to work properly -->
+ <groupId>net.pl3x.purpur</groupId>
+ <artifactId>purpur-api</artifactId>
+ <!-- Purpur end -->
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
@@ -190,6 +192,14 @@
</repository>
</repositories>
+ <repositories>
+ <!-- Purpur - Snapshots -->
+ <repository>
+ <id>purpur-snapshots</id>
+ <url>https://repo.pl3x.net/</url>
+ </repository>
+ </repositories>
+
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
<build>
<finalName>tuinity-${minecraft.version}</finalName>
@@ -369,8 +379,15 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
- <version>3.24.0</version>
+ <!-- Purpur start -->
+ <version>3.25.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib</artifactId>
+ <version>1.4.33-SNAPSHOT</version>
</dependency>
+ <!-- Purpur end -->
</dependencies>
</plugin>
<plugin>
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
index 89eeb9d202405747409e65fcf226d95379987e29..4d9e685c691a37078ff7452e50ab8c13999dbe10 100644
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
@@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
@Override
protected LineReader buildReader(LineReaderBuilder builder) {
return super.buildReader(builder
- .appName("Paper")
+ .appName("Purpur") // Purpur
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
.completer(new ConsoleCommandCompleter(this.server))
);
diff --git a/src/main/java/gg/airplane/compat/ServerConfigurations.java b/src/main/java/gg/airplane/compat/ServerConfigurations.java
index f4976428bc721319d2926e97cbe0f64c6e9e503c..044ad28bd1fd1c1e25061f9f811fc10baf7f5f72 100644
--- a/src/main/java/gg/airplane/compat/ServerConfigurations.java
+++ b/src/main/java/gg/airplane/compat/ServerConfigurations.java
@@ -23,6 +23,7 @@ public class ServerConfigurations {
"spigot.yml",
"paper.yml",
"tuinity.yml",
+ "purpur.yml", // Purpur
"airplane.air"
};
diff --git a/src/main/java/net/minecraft/server/EULA.java b/src/main/java/net/minecraft/server/EULA.java
index 3bc5cd1e53dd7c94b948e7f57f0dc8e073e349b0..87891161f5b06bb8be0e2016b490484e6daca9d7 100644
--- a/src/main/java/net/minecraft/server/EULA.java
+++ b/src/main/java/net/minecraft/server/EULA.java
@@ -72,7 +72,7 @@ public class EULA {
Properties properties = new Properties();
properties.setProperty("eula", "false");
- properties.store(outputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula)."); // Paper - fix lag; // Tuinity - Tacos are disgusting
+ properties.store(outputstream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\nYou also agree that tacos are tasty, and the best food in the world."); // Paper - fix lag; // Tuinity - Tacos are disgusting // Purpur - no they're not
} catch (Throwable throwable1) {
throwable = throwable1;
throw throwable1;
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ca10d901ebd56bdee54f3c8cf607a5a34cd79f32..4f602f0448585b95b8b2b05006f0fa9f9c57ba43 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1636,7 +1636,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
public String getServerModName() {
- return "Airplane"; // Airplane // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
+ return "Purpur"; // Purpur // Airplane // Tuinity // Paper // Spigot // CraftBukkit
}
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..cabfcebf9f944f7a2a2a1cffc7401435803a8741
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/PurpurVersionFetcher.java
@@ -0,0 +1,119 @@
+package net.pl3x.purpur;
+
+import com.destroystokyo.paper.VersionHistoryManager;
+import com.destroystokyo.paper.util.VersionFetcher;
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+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;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class PurpurVersionFetcher implements VersionFetcher {
+ private static final String JENKINS_URL = "https://ci.pl3x.net/job/Purpur/lastSuccessfulBuild/buildNumber";
+ private static final String GITHUB_BRANCH_NAME = "master";
+
+ @Override
+ public long getCacheTime() {
+ return 720000;
+ }
+
+ @Nonnull
+ @Override
+ public Component getVersionMessage(@Nonnull String serverVersion) {
+ String[] parts = serverVersion.substring("git-Purpur-".length()).split("[-\\s]");
+ final Component updateMessage = getUpdateStatusMessage("pl3xgaming/Purpur", GITHUB_BRANCH_NAME, parts[0]);
+ final Component history = getHistory();
+
+ return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
+ }
+
+ private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
+ int distance;
+ try {
+ int jenkinsBuild = Integer.parseInt(versionInfo);
+ distance = fetchDistanceFromJenkins(jenkinsBuild);
+ } catch (NumberFormatException ignored) {
+ versionInfo = versionInfo.replace("\"", "");
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
+ }
+
+ switch (distance) {
+ case -1:
+ return Component.text("Error obtaining version information", NamedTextColor.YELLOW);
+ case 0:
+ return Component.text("You are running the latest version", NamedTextColor.GREEN);
+ case -2:
+ return Component.text("Unknown version", NamedTextColor.YELLOW);
+ default:
+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW);
+ }
+ }
+
+ private static int fetchDistanceFromJenkins(int jenkinsBuild) {
+ try {
+ try (BufferedReader reader = Resources.asCharSource(new URL(JENKINS_URL), Charsets.UTF_8).openBufferedStream()) {
+ return Integer.decode(reader.readLine()) - jenkinsBuild;
+ } catch (NumberFormatException ex) {
+ ex.printStackTrace();
+ return -2;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return -1;
+ }
+ }
+
+ // Contributed by Techcable <Techcable@outlook.com> in GH-65
+ private static int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash) {
+ try {
+ HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
+ connection.connect();
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return -2; // Unknown commit
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) {
+ JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
+ String status = obj.get("status").getAsString();
+ switch (status) {
+ case "identical":
+ return 0;
+ case "behind":
+ return obj.get("behind_by").getAsInt();
+ default:
+ return -1;
+ }
+ } catch (JsonSyntaxException | NumberFormatException e) {
+ e.printStackTrace();
+ return -1;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return -1;
+ }
+ }
+
+ @Nullable
+ private Component getHistory() {
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
+ if (data == null) {
+ return null;
+ }
+
+ final String oldVersion = data.getOldVersion();
+ if (oldVersion == null) {
+ return null;
+ }
+
+ 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
index aec6c036ed42078a6cc3540f1f6e46a551e87a2f..f9913d7bd66935f975b756f31e26153ec160b3b1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -232,7 +232,7 @@ import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
public final class CraftServer implements Server {
- private final String serverName = "Airplane"; // Paper // Tuinity // Airplane
+ private final String serverName = "Purpur"; // Paper // Tuinity // Airplane // Purpur
private final String serverVersion;
private final String bukkitVersion = Versioning.getBukkitVersion();
private final Logger logger = Logger.getLogger("Minecraft");
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 712a32c0b64dace1f3e3d6f8acb8cbef1736b1f9..eba28b9c5cb87dea09bf8430d253725f585f87b9 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -377,7 +377,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
@Override
public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
- return new com.destroystokyo.paper.PaperVersionFetcher();
+ return new net.pl3x.purpur.PurpurVersionFetcher();
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
index 1788d79ea489e446d3d9f541693d4ba3dfc26015..191f5331f0c7871f80f0da9cc38345ce33353577 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
@@ -11,7 +11,7 @@ public final class Versioning {
public static String getBukkitVersion() {
String result = "Unknown-Version";
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/gg.airplane/airplane-api/pom.properties"); // Tuinity // Airplane
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/net.pl3x.purpur/purpur-api/pom.properties"); // Tuinity // Airplane // Purpur
Properties properties = new Properties();
if (stream != null) {