Files
Purpur/patches/server/0001-Rebrand.patch
William Blake Galbreath 860c86191a Updated Upstream (Paper)
Upstream has released updates that appears to apply and compile correctly

Paper Changes:
c8028d1c Fix data version check for ItemStack serialization (#3394)
9254a80a Fix race condition reintroduced in Prioritize class loader patch
6f196fe7 Add Raw Byte ItemStack Serialization
df43f828 Allow server startup for those poor people running <1G Xmx
3c9b65ef Fix cases where no-tick < tick view distance
72f89a07 Workaround for Client Lag Spikes (MC-162253)
3f941c0c Add option for console having all permissions
d2ae4658 Add permission for command blocks
9f8ae5cb Prioritise own classes where possible
74466412 Check portal restrictions when entering end gateways
fc9cf84d Fix NPE when temp ip bans expire (#3373)
16bd420d Add missing mob goals for API (#3367)
b5c4e2f6 Ensure no-tick view is not smaller than ticking VD
52564b1f Expand Pathfinding API with more options
dde65481 Fix usage of vanilla goals
7797aebe Drop Leads from nether portals - Fixes #3226
511b6bc2 Reduce MutableInt and Vec3d allocations, use ArrayDeque
84673141 Optimize NibbleArray to use pooled buffers
897dd2c8 Foundational work for Future Memory usage improvements
bb4002d8 Handle CraftPlayer#setSpectatorTarget better
4ae08959 Fix collision checks on spawning hanging entities and null on async chunk loads
c2f8d1ef Protect Bedrock and End Portal/Frames from being destroyed
827cc632 Updated Upstream (Bukkit/CraftBukkit/Spigot)
92f680ed Fix Pathfinding and obscure glitchy buggy 0 tick farms
7a7c4292 Optimize Pathfinder - Remove Streams / Optimized collections
fc917d16 Optimize Hoppers - Major performance improvement
14ad77c6 Fix PotionEffect API Ignoring Icon bug
eb3ce8a2 Fix EntityRaider picking up items when they shouldn't be able
1ea9ada0 Add a TELEPORT ticket when changing dimensions
8e9459ea Fix missing flag pass for isUrgent
7befec44 Potential bed api (#3339)
27945a6b Optimize WorldBorder collision checks and air
55e17a85 Wait for Async Tasks during shutdown
b5905256 Ensure Entity AABB's are never invalid
a054aa6f Properly remove Entities from current chunk
c894ddfd Fix teleporting onto a chunk line
57d6cc01 Send LOGIN protocol packets immediately - Fix disconnect during async prelogin
cd93e54d Don't use our modified chunk checks for collision in world gen
b4003ef1 Allow loading entities current chunk if needed to fix collision checks
e5f64896 Add Urgent API for Async Chunks API and use it for Async Teleport
ad8e59dc Ensure chunks loaded on respawn for suffocation check
2020-05-18 15:22:23 -05:00

285 lines
12 KiB
Diff

From 11137688efbe226b4c00fd1e9e2a2a0796b0c025 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 1ae57e8ab..7f251e739 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>
@@ -159,7 +173,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>
@@ -167,7 +181,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 3ec164785..92677b38b 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 549ba4d80..3c7cb4e3f 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