Yatopia/patches/server/0003-Brandings.patch

251 lines
14 KiB
Diff
Raw Normal View History

2020-07-17 18:05:50 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-02-26 18:37:58 +01:00
From: tr7zw <tr7zw@live.de>
Date: Wed, 26 Feb 2020 18:37:34 +0100
Subject: [PATCH] Brandings
2020-09-13 20:50:36 +02:00
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
index de75e33a68a4fb980d3c9356a2e3c87e8f34384d..11d3f9000f6b23352a3b62eb994cbbf2779498eb 100644
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
@@ -581,7 +581,7 @@ public class Metrics {
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
// Only start Metrics, if it's enabled in the config
if (config.getBoolean("enabled", true)) {
- Metrics metrics = new Metrics("Purpur", serverUUID, logFailedRequests, Bukkit.getLogger()); // Purpur
+ Metrics metrics = new Metrics("Yatopia", serverUUID, logFailedRequests, Bukkit.getLogger()); // Purpur // Yatopia
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
String minecraftVersion = Bukkit.getVersion();
@@ -591,7 +591,7 @@ public class Metrics {
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : (PaperConfig.isProxyOnlineMode() ? "bungee" : "offline"))); // Purpur
- metrics.addCustomChart(new Metrics.SimplePie("purpur_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown")); // Purpur
+ metrics.addCustomChart(new Metrics.SimplePie("yatopia_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown")); // Purpur // Yatopia
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
Map<String, Map<String, Integer>> map = new HashMap<>();
2020-02-26 18:37:58 +01:00
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
2020-08-01 18:14:57 +02:00
index 74ed02fa9296583977bb721014b10ff8b708b43c..a13c7b2b5bc79ecaea404779149ed02c4600a61b 100644
2020-02-26 18:37:58 +01:00
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
2020-03-21 17:29:35 +01:00
@@ -18,6 +18,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
2020-02-26 18:37:58 +01:00
protected LineReader buildReader(LineReaderBuilder builder) {
return super.buildReader(builder
2020-03-21 17:29:35 +01:00
.appName("Paper")
2020-08-01 18:14:57 +02:00
+ .appName("Yatopia") // Yatopia
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
2020-02-26 18:37:58 +01:00
.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 4b85fb34051f286b08d23ff25cbd0c7a1c0a2a21..05305007e2118c618f1bd24985cc108d2efb0204 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1519,7 +1519,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
public String getServerModName() {
- return "Tuinity"; // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
+ return "Yatopia"; // Yatopia // Tuinity //Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
}
public CrashReport b(CrashReport crashreport) {
diff --git a/src/main/java/net/yatopia/server/YatopiaVersionFetcher.java b/src/main/java/net/yatopia/server/YatopiaVersionFetcher.java
2020-02-26 18:37:58 +01:00
new file mode 100644
2020-09-11 08:11:08 +02:00
index 0000000000000000000000000000000000000000..fdfd1af1309df4a400b47768708bec7abeed8b20
2020-02-26 18:37:58 +01:00
--- /dev/null
+++ b/src/main/java/net/yatopia/server/YatopiaVersionFetcher.java
@@ -0,0 +1,96 @@
+package net.yatopia.server;
2020-02-26 18:37:58 +01:00
+
+import com.destroystokyo.paper.VersionHistoryManager;
+import com.google.common.base.Charsets;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonSyntaxException;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
2020-02-26 18:37:58 +01:00
+import javax.annotation.Nonnull;
+
+import com.destroystokyo.paper.util.VersionFetcher;
+import javax.annotation.Nullable;
2020-02-26 18:37:58 +01:00
+
[WIP] Better Patch System (#18) * Update build.yml * Remove 3rd party patches * Add Upsteam Submodules * Fix patches * ? * Fix patches * Add Fast Init script * Lots of stuff also it's broke * more broken * fixes * mor stuff * gfhfgh hg * fix patch * fix up script * update submodule * add papercut * update tuinity * update gitmodules * fix var name * fix more var stuff * some how it's not deleting shit anymore * should now use the branch it just made why are we doing this again? * now it does thing thing * return previous so YAPFA can use it * ok now it really does the thing * for REAL it does the thing * don't do the thing because it causes too many problems * fix api * work * use better patching for YAPFA patches * fix better patching * more fixes * new patches stuff * remove old 3rd parry patches add removed akarin patches * make new branch for making patches * hopefully build patches correctly * fix gitignore and add config patches * remove papercut files * fix some weirdness * fix bug * time to do some fixin' :eyes: * New Patch System Rebased Patches * fix full build * exit 1 * fix * Remove patch * Hopefully fix compile errors * fixes * this might work * don't use rej for our patches * tmp disable cache * some times case sensitivity is dumb * my sanity is at an all time low :) * dfg * readd cahce * fix? * Update Upstream * fix perms * fix * fix api * Redo API * rm folders * fix villager brain patch * emc explosion pref * fixed aikar's shit * betterfix * fix lagggg * Origami * Origami Fixes * Update readme * test async path finding * WIP Async Path Finding * WIP fix async path finding * same as bellow * same * update to newer funcs * fix newer funcs * fix author * Updates, Fixes, and new patches * fixes * possibly async flying path finding * minor asnyc pathfinding fix * test remove non asnyc path finder * WIP make all path finding async * Rename everything * Exec flag * Rebuild hashes * remove dupe patch * fix? * Fix packages, redirect config * old nav class is now async and back * add getchatcolor.getbyid and handle patches with a . in them better Co-authored-by: tr7zw <tr7zw@live.de> Co-authored-by: Unknown <unknown@example.com> Co-authored-by: Ovydux <68059159+Ovydux@users.noreply.github.com>
2020-08-03 18:48:42 +02:00
+public class YatopiaVersionFetcher implements VersionFetcher {
2020-02-26 18:37:58 +01:00
+
2020-09-11 08:11:08 +02:00
+ private static final String GITHUB_BRANCH_NAME = "ver/1.16.3";
+
2020-02-26 18:37:58 +01:00
+ @Override
+ public long getCacheTime() {
2020-09-11 08:11:08 +02:00
+ return 3600000;
2020-02-26 18:37:58 +01:00
+ }
+
+ @Nonnull
+ @Override
+ public String getVersionMessage(@Nonnull String serverVersion) {
+ String[] parts = serverVersion.substring("git-Yatopia-".length()).split("[-\\s]");
+ String updateMessage = getUpdateStatusMessage("YatopiaMC/Yatopia", GITHUB_BRANCH_NAME, parts[0]);
+ String history = getHistory();
+ return history != null ? history + "\n" + updateMessage : updateMessage;
+ }
+
+ private String getUpdateStatusMessage(String repo, String branch, String versionInfo) {
+ versionInfo = versionInfo.replace("\"", "");
+ int 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 "\u00AF\\_(\u30C4)_/\u00AF";
+ default:
+ return "You are " + distance + " version(s) behind";
+ }
+ }
+
+ // Contributed by Techcable <Techcable@outlook.com> in GH-65
+ // from PaperVersionFetcher
+ 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;
+ }
+ }
+
+ // from PaperVersionFetcher
+ @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;
2020-02-26 18:37:58 +01:00
+ }
+
+}
2020-03-21 17:29:35 +01:00
\ No newline at end of file
2020-02-26 18:37:58 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b07659d2df48f3d131c8ddf94ff2a1e12afc3d08..42628d6dbf54977d34442f46c89b771af3af5b11 100644
2020-02-26 18:37:58 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -218,7 +218,7 @@ import javax.annotation.Nullable; // Paper
2020-02-26 18:37:58 +01:00
import javax.annotation.Nonnull; // Paper
public final class CraftServer implements Server {
2020-03-21 17:30:03 +01:00
- private final String serverName = "Tuinity"; // Paper // Tuinity
2020-08-01 18:14:57 +02:00
+ private final String serverName = "Yatopia"; // Paper // Tuinity // Yatopia
2020-02-26 18:37:58 +01:00
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 3ebaa9463e365831de37d8fa3cc191693f5b856f..56af3160015a5cf34586d2b8e7c073cea8ce52a5 100644
2020-02-26 18:37:58 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -347,7 +347,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
2020-02-26 18:37:58 +01:00
@Override
public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
- return new com.destroystokyo.paper.PaperVersionFetcher();
+ return new net.yatopia.server.YatopiaVersionFetcher(); // Yatopia
2020-02-26 18:37:58 +01:00
}
@Override
2020-03-08 15:59:59 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
2020-09-01 17:34:30 +02:00
index 001b1e5197eaa51bfff9031aa6c69876c9a47960..0525370b7e3bf24147b4948caf522ad785ce5d78 100644
2020-03-08 15:59:59 +01:00
--- 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";
2020-03-21 17:30:03 +01:00
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/com.tuinity/tuinity-api/pom.properties"); // Tuinity
2020-09-01 17:34:30 +02:00
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/net.yatopia/yatopia-api/pom.properties"); // Yatopia
2020-03-08 15:59:59 +01:00
Properties properties = new Properties();
if (stream != null) {
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index 4d310908489953d6d061b2358f614142edacb62e..fd3e1d363a8ed18af6132421e927e83680ff8e76 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -26,7 +26,7 @@ public class WatchdogThread extends Thread
private WatchdogThread(long timeoutTime, boolean restart)
{
- super( "Paper Watchdog Thread" );
+ super( "Yatopia Watchdog Thread" ); // Yatopia
this.timeoutTime = timeoutTime;
this.restart = restart;
earlyWarningEvery = Math.min(PaperConfig.watchdogPrintEarlyWarningEvery, timeoutTime); // Paper
@@ -158,14 +158,14 @@ public class WatchdogThread extends Thread
if (isLongTimeout) {
// Paper end
log.log( Level.SEVERE, "------------------------------" );
- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper
+ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Yatopia bug." ); // Paper // Yatopia
log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" );
log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring" );
log.log( Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once" );
log.log( Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes" );
- log.log( Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" );
+ log.log( Level.SEVERE, "If you are unsure or still think this is a Yatopia bug, please report this to https://github.com/tr7zw/Yatopia/issues" ); // Yatopia
log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
- log.log( Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion() );
+ log.log( Level.SEVERE, "Yatopia version: " + Bukkit.getServer().getVersion() ); // Yatopia
//
if ( net.minecraft.server.World.lastPhysicsProblem != null )
{
@@ -188,12 +188,12 @@ public class WatchdogThread extends Thread
// Paper end
} else
{
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---");
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO YATOPIA - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Yatopia
log.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump");
}
// Paper end - Different message for short timeout
log.log( Level.SEVERE, "------------------------------" );
- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Yatopia!):" ); // Paper // Yatopia
ChunkTaskManager.dumpAllChunkLoadInfo(); // Paper
this.dumpTickingInfo(); // Tuinity - log detailed tick information
dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( server.serverThread.getId(), Integer.MAX_VALUE ), log );
@@ -209,7 +209,7 @@ public class WatchdogThread extends Thread
dumpThread( thread, log );
}
} else {
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---");
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO YATOPIA - THIS IS NOT A BUG OR A CRASH ---"); // Yatopia
}