mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: b6cf80ee Preload important classes such as Logger and JLine ea1a909c Fix netty version to 50 and restore epoll native support 10502558 Workaround for some hacky environments that mess up things 8b2a437b Fix plugins calling getChunkAtAsync asynchronously c8055836 Update Netty to 4.1.51 64cfcf3e Optimize sending packets to nearby locations (sounds/effects)
285 lines
12 KiB
Diff
285 lines
12 KiB
Diff
From fad7117f1f0a960e444b059b3ef72357a008826e 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
|
|
|
|
---
|
|
pom.xml | 32 +++--
|
|
.../paper/console/PaperConsole.java | 2 +-
|
|
.../net/minecraft/server/MinecraftServer.java | 2 +-
|
|
.../net/pl3x/purpur/PurpurVersionFetcher.java | 115 ++++++++++++++++++
|
|
.../org/bukkit/craftbukkit/CraftServer.java | 2 +-
|
|
.../craftbukkit/util/CraftMagicNumbers.java | 2 +-
|
|
.../bukkit/craftbukkit/util/Versioning.java | 2 +-
|
|
7 files changed, 143 insertions(+), 14 deletions(-)
|
|
create mode 100644 src/main/java/net/pl3x/purpur/PurpurVersionFetcher.java
|
|
|
|
diff --git a/pom.xml b/pom.xml
|
|
index e4c63bb76..d5709e670 100644
|
|
--- a/pom.xml
|
|
+++ b/pom.xml
|
|
@@ -1,11 +1,11 @@
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
<modelVersion>4.0.0</modelVersion>
|
|
- <artifactId>paper</artifactId>
|
|
+ <artifactId>purpur</artifactId>
|
|
<packaging>jar</packaging>
|
|
<version>1.15.2-R0.1-SNAPSHOT</version>
|
|
- <name>Paper</name>
|
|
- <url>https://papermc.io</url>
|
|
+ <name>Purpur</name>
|
|
+ <url>http://pl3x.net</url>
|
|
|
|
<properties>
|
|
<!-- <skipTests>true</skipTests> Paper - This [was] not going to end well -->
|
|
@@ -18,16 +18,16 @@
|
|
</properties>
|
|
|
|
<parent>
|
|
- <groupId>com.destroystokyo.paper</groupId>
|
|
- <artifactId>paper-parent</artifactId>
|
|
+ <groupId>net.pl3x.purpur</groupId>
|
|
+ <artifactId>purpur-parent</artifactId>
|
|
<version>dev-SNAPSHOT</version>
|
|
<relativePath>../pom.xml</relativePath>
|
|
</parent>
|
|
|
|
<dependencies>
|
|
<dependency>
|
|
- <groupId>com.destroystokyo.paper</groupId>
|
|
- <artifactId>paper-api</artifactId>
|
|
+ <groupId>net.pl3x.purpur</groupId>
|
|
+ <artifactId>purpur-api</artifactId>
|
|
<version>${project.version}</version>
|
|
<scope>compile</scope>
|
|
</dependency>
|
|
@@ -43,6 +43,20 @@
|
|
<version>${minecraft.version}-SNAPSHOT</version>
|
|
<scope>compile</scope>
|
|
</dependency>
|
|
+ <!-- Purpur start -->
|
|
+ <dependency>
|
|
+ <groupId>org.mozilla</groupId>
|
|
+ <artifactId>rhino</artifactId>
|
|
+ <version>1.7.7.1</version>
|
|
+ <scope>compile</scope>
|
|
+ </dependency>
|
|
+ <dependency>
|
|
+ <groupId>cat.inspiracio</groupId>
|
|
+ <artifactId>rhino-js-engine</artifactId>
|
|
+ <version>1.7.7.1</version>
|
|
+ <scope>compile</scope>
|
|
+ </dependency>
|
|
+ <!-- Purpur end -->
|
|
<dependency>
|
|
<groupId>net.minecrell</groupId>
|
|
<artifactId>terminalconsoleappender</artifactId>
|
|
@@ -164,7 +178,7 @@
|
|
|
|
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
|
|
<build>
|
|
- <finalName>paper-${minecraft.version}</finalName>
|
|
+ <finalName>purpur-${minecraft.version}</finalName>
|
|
<defaultGoal>clean install</defaultGoal> <!-- Paper -->
|
|
<plugins>
|
|
<plugin>
|
|
@@ -172,7 +186,7 @@
|
|
<artifactId>gitdescribe-maven-plugin</artifactId>
|
|
<version>1.3</version>
|
|
<configuration>
|
|
- <outputPrefix>git-Paper-</outputPrefix>
|
|
+ <outputPrefix>git-Purpur-</outputPrefix>
|
|
<scmDirectory>..</scmDirectory>
|
|
</configuration>
|
|
<executions>
|
|
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
index cd6e25923..bb227bc0f 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
|
|
.completer(new ConsoleCommandCompleter(this.server))
|
|
);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 5b24de6d6..5cd342eda 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1559,7 +1559,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
}
|
|
|
|
public String getServerModName() {
|
|
- return "Paper"; //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
|
+ return "Purpur"; // Purpur - Purpur > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
|
}
|
|
|
|
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 000000000..d8b408f06
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurVersionFetcher.java
|
|
@@ -0,0 +1,115 @@
|
|
+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 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 String 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();
|
|
+
|
|
+ return history != null ? history + "\n" + updateMessage : updateMessage;
|
|
+ }
|
|
+
|
|
+ private static String 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 "Error obtaining version information";
|
|
+ case 0:
|
|
+ return "You are running the latest version";
|
|
+ case -2:
|
|
+ return "Unknown version";
|
|
+ default:
|
|
+ return "You are " + distance + " version(s) behind";
|
|
+ }
|
|
+ }
|
|
+
|
|
+ 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 String getHistory() {
|
|
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
|
+ if (data == null) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ final String oldVersion = data.getOldVersion();
|
|
+ if (oldVersion == null) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ return "Previous version: " + oldVersion;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 894917c88..648dde01a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -205,7 +205,7 @@ import javax.annotation.Nullable; // Paper
|
|
import javax.annotation.Nonnull; // Paper
|
|
|
|
public final class CraftServer implements Server {
|
|
- private final String serverName = "Paper"; // Paper
|
|
+ private final String serverName = "Purpur"; // Purpur // Paper
|
|
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 b58f2ef5c..fefa718df 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -306,7 +306,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 674096cab..e9aee2d8a 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/com.destroystokyo.paper/paper-api/pom.properties");
|
|
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/net.pl3x.purpur/purpur-api/pom.properties"); // Purpur
|
|
Properties properties = new Properties();
|
|
|
|
if (stream != null) {
|
|
--
|
|
2.24.0
|
|
|