9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2026-01-04 15:31:43 +00:00
Files
DivineMC/divinemc-server/paper-patches/features/0001-Rebrand.patch
2025-02-22 15:13:16 +03:00

209 lines
14 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Mon, 27 Jan 2025 01:35:41 +0300
Subject: [PATCH] Rebrand
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
index fe66e43c27e0798770e102d1385bacbaa90bda07..5aef1f7aa8c614e50b34747456e7d5a3f0045aff 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -36,7 +36,7 @@ public class PaperVersionFetcher implements VersionFetcher {
private static final int DISTANCE_ERROR = -1;
private static final int DISTANCE_UNKNOWN = -2;
// Purpur start - Rebrand
- private static final String DOWNLOAD_PAGE = "https://purpurmc.org/downloads";
+ private static final String DOWNLOAD_PAGE = "https://github.com/BX-Team/DivineMC/releases/latest"; // DivineMC - Rebrand
private static int distance = DISTANCE_UNKNOWN; public int distance() { return distance; }
// Purpur end - Rebrand
@@ -52,7 +52,7 @@ public class PaperVersionFetcher implements VersionFetcher {
if (build.buildNumber().isEmpty() && build.gitCommit().isEmpty()) {
updateMessage = text("You are running a development version without access to version information", color(0xFF5300));
} else {
- updateMessage = getUpdateStatusMessage("PurpurMC/Purpur", build); // Purpur - Rebrand
+ updateMessage = getUpdateStatusMessage("BX-Team/DivineMC", build); // DivineMC - Rebrand
}
final @Nullable Component history = this.getHistory();
@@ -60,18 +60,13 @@ public class PaperVersionFetcher implements VersionFetcher {
}
private static Component getUpdateStatusMessage(final String repo, final ServerBuildInfo build) {
- //int distance = DISTANCE_ERROR; // Purpur - use field - Rebrand
-
- final OptionalInt buildNumber = build.buildNumber();
- if (buildNumber.isPresent()) {
- distance = fetchDistanceFromSiteApi(build, buildNumber.getAsInt());
- } else {
- final Optional<String> gitBranch = build.gitBranch();
- final Optional<String> gitCommit = build.gitCommit();
- if (gitBranch.isPresent() && gitCommit.isPresent()) {
- distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get());
- }
+ // DivineMC start - Rebrand
+ final Optional<String> gitBranch = build.gitBranch();
+ final Optional<String> gitCommit = build.gitCommit();
+ if (gitBranch.isPresent() && gitCommit.isPresent()) {
+ distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get());
}
+ // DivineMC end - Rebrand
return switch (distance) {
case DISTANCE_ERROR -> text("* Error obtaining version information", NamedTextColor.RED); // Purpur - Rebrand
@@ -86,26 +81,6 @@ public class PaperVersionFetcher implements VersionFetcher {
};
}
- private static int fetchDistanceFromSiteApi(final ServerBuildInfo build, final int jenkinsBuild) {
- try {
- try (final BufferedReader reader = Resources.asCharSource(
- URI.create("https://api.purpurmc.org/v2/purpur/" + build.minecraftVersionId()).toURL(), // Purpur - Rebrand
- Charsets.UTF_8
- ).openBufferedStream()) {
- final JsonObject json = new Gson().fromJson(reader, JsonObject.class);
- //final JsonArray builds = json.getAsJsonArray("builds"); // Purpur - Rebrand
- final int latest = json.getAsJsonObject("builds").getAsJsonPrimitive("latest").getAsInt(); // Purpur - Rebrand
- return latest - jenkinsBuild;
- } catch (final JsonSyntaxException ex) {
- LOGGER.error("Error parsing json from Purpur's downloads API", ex); // Purpur - Rebrand
- return DISTANCE_ERROR;
- }
- } catch (final IOException e) {
- LOGGER.error("Error while parsing version", e);
- return DISTANCE_ERROR;
- }
- }
-
// Contributed by Techcable <Techcable@outlook.com> in GH-65
private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) {
try {
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
index bc7e4e5560708fea89c584b1d8b471f4966f311a..6567ff18cb1c21230565c2d92caf3a7f7f915c17 100644
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
@@ -20,7 +20,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
@Override
protected LineReader buildReader(LineReaderBuilder builder) {
builder
- .appName("Purpur") // Purpur - Rebrand
+ .appName("DivineMC") // DivineMC - Rebrand
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
.completer(new ConsoleCommandCompleter(this.server))
.option(LineReader.Option.COMPLETE_IN_WORD, true);
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
index b36e30fd4057a938e4d90cb42a2dca661f16478e..4e29f5f55b9a894099bef6f7c7f11e2a96b02fc8 100644
--- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
+++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java
@@ -23,15 +23,18 @@ public record ServerBuildInfoImpl(
Optional<String> gitBranch,
Optional<String> gitCommit
) implements ServerBuildInfo {
+ public static boolean IS_EXPERIMENTAL = false; // DivineMC - Rebrand
private static final String ATTRIBUTE_BRAND_ID = "Brand-Id";
private static final String ATTRIBUTE_BRAND_NAME = "Brand-Name";
private static final String ATTRIBUTE_BUILD_TIME = "Build-Time";
private static final String ATTRIBUTE_BUILD_NUMBER = "Build-Number";
private static final String ATTRIBUTE_GIT_BRANCH = "Git-Branch";
private static final String ATTRIBUTE_GIT_COMMIT = "Git-Commit";
+ private static final String ATTRIBUTE_EXPERIMENTAL = "Experimental"; // DivineMC - Rebrand
private static final String BRAND_PAPER_NAME = "Paper";
private static final String BRAND_PURPUR_NAME = "Purpur"; // Purpur - Rebrand
+ private static final String BRAND_DIVINEMC_NAME = "DivineMC"; // DivineMC - Rebrand
private static final String BUILD_DEV = "DEV";
@@ -43,9 +46,9 @@ public record ServerBuildInfoImpl(
this(
getManifestAttribute(manifest, ATTRIBUTE_BRAND_ID)
.map(Key::key)
- .orElse(BRAND_PURPUR_ID), // Purpur - Fix pufferfish issues // Purpur - Rebrand
+ .orElse(BRAND_DIVINEMC_ID), // DivineMC - Rebrand
getManifestAttribute(manifest, ATTRIBUTE_BRAND_NAME)
- .orElse(BRAND_PURPUR_NAME), // Purpur - Fix pufferfish issues // Purpur - Rebrand
+ .orElse(BRAND_DIVINEMC_NAME), // DivineMC - Rebrand
SharedConstants.getCurrentVersion().getId(),
SharedConstants.getCurrentVersion().getName(),
getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER)
@@ -58,6 +61,7 @@ public record ServerBuildInfoImpl(
getManifestAttribute(manifest, ATTRIBUTE_GIT_BRANCH),
getManifestAttribute(manifest, ATTRIBUTE_GIT_COMMIT)
);
+ IS_EXPERIMENTAL = Boolean.parseBoolean(getManifestAttribute(manifest, ATTRIBUTE_EXPERIMENTAL).orElse("false")); // DivineMC - Rebrand
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 2e7c3d4befeb6256ce81ecaa9ed4e8fbcb21651e..a839dbbb72f48b8f8736d9f4693c528686570732 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -491,7 +491,7 @@ public class CraftScheduler implements BukkitScheduler {
this.parsePending();
} else {
// this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(this.currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Purpur"); // Paper // Purpur - Rebrand
+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to DivineMC"); // DivineMC - Rebrand
// We don't need to parse pending
// (async tasks must live with race-conditions if they attempt to cancel between these few lines of code)
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
index 99eb04643fce44c37fd96c99756837ccafe7b559..4aef151bd162c4c99a3eaec1854b54639980a630 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/org.purpurmc.purpur/purpur-api/pom.properties"); // Pufferfish // Purpur - Rebrand
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.bxteam.divinemc/divinemc-api/pom.properties"); // DivineMC - Rebrand
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 776bc01784b53e3f1d9a35046109c3b9ee4f0882..3731ca80ed58cd385cd66ffbe67f2eeaae642d0f 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -77,14 +77,14 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
if (isLongTimeout) {
// Paper end
logger.log(Level.SEVERE, "------------------------------");
- logger.log(Level.SEVERE, "The server has stopped responding! This is (probably) not a Purpur bug."); // Paper // Purpur - Rebrand
+ logger.log(Level.SEVERE, "The server has stopped responding! This is (probably) not a DivineMC bug."); // DivineMC - Rebrand
logger.log(Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author");
logger.log(Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring");
logger.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");
logger.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");
- logger.log(Level.SEVERE, "If you are unsure or still think this is a Purpur bug, please report this to https://github.com/PurpurMC/Purpur/issues"); // Purpur - Rebrand
+ logger.log(Level.SEVERE, "If you are unsure or still think this is a DivineMC bug, please report this to https://github.com/BX-Team/DivineMC/issues"); // DivineMC - Rebrand
logger.log(Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports");
- logger.log(Level.SEVERE, "Purpur version: " + Bukkit.getServer().getVersion()); // Purpur - Rebrand
+ logger.log(Level.SEVERE, "DivineMC version: " + Bukkit.getServer().getVersion()); // DivineMC - Rebrand
if (net.minecraft.world.level.Level.lastPhysicsProblem != null) {
logger.log(Level.SEVERE, "------------------------------");
@@ -104,12 +104,12 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
}
// Paper end
} else {
- logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PURPUR - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Purpur - Rebrand
+ logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO DIVINEMC - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // DivineMC - Rebrand
logger.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump");
}
// Paper end - Different message for short timeout
logger.log(Level.SEVERE, "------------------------------");
- logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Purpur!):" ); // Paper // Purpur - Rebrand
+ logger.log(Level.SEVERE, "Server thread dump (Look for plugins here before reporting to DivineMC!):" ); // DivineMC - Rebrand
FeatureHooks.dumpAllChunkLoadInfo(MinecraftServer.getServer(), isLongTimeout); // Paper - log detailed tick information
WatchdogThread.dumpThread(ManagementFactory.getThreadMXBean().getThreadInfo(MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE), logger);
logger.log(Level.SEVERE, "------------------------------");
@@ -122,7 +122,7 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre
WatchdogThread.dumpThread(thread, logger);
}
} else {
- logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PURPUR - THIS IS NOT A BUG OR A CRASH ---"); // Purpur - Rebrand
+ logger.log(Level.SEVERE, "--- DO NOT REPORT THIS TO DIVINEMC - THIS IS NOT A BUG OR A CRASH ---"); // DivineMC - Rebrand
}
logger.log(Level.SEVERE, "------------------------------");