From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: nostalgic853 Date: Thu, 20 Oct 2022 10:07:45 +0800 Subject: [PATCH] Rebrand diff --git a/build.gradle.kts b/build.gradle.kts index 2ee34f92e8a89b90448bbf710fdc0d5d6350e919..299ac3fab7543cb7ae0371ae80ea4786e6d37d8b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } dependencies { - implementation(project(":purpur-api")) // Purpur + implementation(project(":keyi-api")) // Purpur // KeYi // Pufferfish start implementation("io.papermc.paper:paper-mojangapi:1.19.2-R0.1-SNAPSHOT") { exclude("io.papermc.paper", "paper-api") @@ -80,13 +80,13 @@ tasks.jar { manifest { val git = Git(rootProject.layout.projectDirectory.path) val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() - val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\"" + val implementationVersion = System.getenv("BUILD_NUMBER") ?: gitHash // KeYi val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", - "Implementation-Version" to "git-Purpur-$implementationVersion",// Purpur + "Implementation-Version" to "git-KeYi-$gitBranch-$implementationVersion",// Purpur // KeYi "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java index acd95cf1dc7f009b63e44e4404e1736283fd458e..3436a377f9c11d8f2a39af65c3370861fedb1b87 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -593,7 +593,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("KeYi", serverUUID, logFailedRequests, Bukkit.getLogger()); // Purpur // KeYi metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> { String minecraftVersion = Bukkit.getVersion(); @@ -603,7 +603,7 @@ public class Metrics { metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size())); metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.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("keyi_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown")); // Purpur // KeYi metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { Map> map = new HashMap<>(); diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java index fba5dbdb7bcbb55400ef18342c9b54612972a718..005983d56b283e54e2cf450f1e9f985aa22503a9 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -4,27 +4,31 @@ import com.destroystokyo.paper.util.VersionFetcher; import com.google.common.base.Charsets; import com.google.common.io.Resources; import com.google.gson.*; +import io.papermc.paper.util.JarManifests; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; -import net.kyori.adventure.text.TextComponent; +import org.bukkit.Bukkit; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.*; import java.net.HttpURLConnection; import java.net.URL; -import java.util.stream.StreamSupport; +import java.util.jar.Manifest; public class PaperVersionFetcher implements VersionFetcher { private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end // Purpur start - private static final String DOWNLOAD_PAGE = "https://purpurmc.org/downloads"; + private static final String DOWNLOAD_PAGE = "https://github.com/KeYiMC/KeYi/releases"; // KeYi private static int distance = -2; public int distance() { return distance; } // Purpur end private static @Nullable String mcVer; - + // KeYi start + private static final Manifest JAR_MANIFEST = JarManifests.manifest(Bukkit.getServer().getClass()); + private static final String GIT_BRANCH = JAR_MANIFEST == null ? null : JAR_MANIFEST.getMainAttributes().getValue("Git-Branch"); + private static final String GIT_COMMIT = JAR_MANIFEST == null ? null : JAR_MANIFEST.getMainAttributes().getValue("Git-Commit"); + // KeYi end @Override public long getCacheTime() { return 720000; @@ -33,8 +37,7 @@ public class PaperVersionFetcher implements VersionFetcher { @Nonnull @Override public Component getVersionMessage(@Nonnull String serverVersion) { - String[] parts = serverVersion.substring("git-Purpur-".length()).split("[-\\s]"); // Purpur - final Component updateMessage = getUpdateStatusMessage("PurpurMC/Purpur", "ver/" + getMinecraftVersion(), parts[0]); // Purpur + final Component updateMessage = getUpdateStatusMessage("KeYiMC/KeYi", GIT_BRANCH, GIT_COMMIT); // Purpur // KeYi final Component history = getHistory(); return history != null ? Component.join(net.kyori.adventure.text.JoinConfiguration.separator(Component.newline()), history, updateMessage) : updateMessage; // Purpur @@ -47,7 +50,7 @@ public class PaperVersionFetcher implements VersionFetcher { String result = matcher.group(); mcVer = result.substring(0, result.length() - 2); // strip 'R' anchor and trailing '-' } else { - org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to Purpur!"); // Purpur + org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to KeYi!"); // Purpur // KeYi org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString()); org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion()); } @@ -58,6 +61,8 @@ public class PaperVersionFetcher implements VersionFetcher { private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) { //int distance; // Purpur - use field + // KeYi start - we don't have jenkins + /* try { int jenkinsBuild = Integer.parseInt(versionInfo); distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion()); @@ -65,22 +70,25 @@ public class PaperVersionFetcher implements VersionFetcher { versionInfo = versionInfo.replace("\"", ""); distance = fetchDistanceFromGitHub(repo, branch, versionInfo); } + */ - switch (distance) { - case -1: - return Component.text("* Error obtaining version information", NamedTextColor.RED); // Purpur - case 0: - return Component.text("* You are running the latest version", NamedTextColor.GREEN); // Purpur - case -2: - return Component.text("* Unknown version", NamedTextColor.RED); // Purpur - default: - return Component.text("* You are " + distance + " version(s) behind", NamedTextColor.YELLOW) // Purpur - .append(Component.newline()) - .append(Component.text("Download the new version at: ") - .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.GOLD) - .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE)) - .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE)))); - } + versionInfo = versionInfo.replace("\"", ""); + distance = fetchDistanceFromGitHub(repo, branch, versionInfo); + // KeYi end + + // KeYi start + return switch (distance) { + case -1 -> Component.text("Failed to obtain version information.", NamedTextColor.RED); // Purpur // KeYi + case 0 -> Component.text("You are running the latest version.", NamedTextColor.GREEN); // Purpur // KeYi + case -2 -> Component.text("You are running an unknown version.", NamedTextColor.RED); // Purpur // KeYi + default -> Component.text("You are " + distance + " version(s) behind.", NamedTextColor.YELLOW) // Purpur // KeYi + .append(Component.newline()) + .append(Component.text("Download the new version at: ") + .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.GOLD) + .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE)) + .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE)))); + }; + // KeYi end } private static int fetchDistanceFromSiteApi(int jenkinsBuild, @Nullable String siteApiVersion) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index f9508a26b2e764e752da3d2c9f43a9d7de19dd27..4f029b96bf8deee597dbb56974e4519a1422f96d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -249,7 +249,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { - private final String serverName = "Purpur"; // Paper // Purpur + private final String serverName = "KeYi"; // Paper // Purpur // KeYi 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/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java index fb87620c742ff7912f5e8ccd2a7930dd605576d9..d779212cbb719a1d923a24823135c5d3543ae65c 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"); // Purpur + InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/cc.keyimc.keyi/keyi-api/pom.properties"); // Purpur // KeYi Properties properties = new Properties(); if (stream != null) { diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java index 5d71e3040df116a94df7efa83e61dc1766cc4a93..75f73042a72c6dde630ed106668fe2c60a8243f9 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java @@ -244,7 +244,7 @@ public class PurpurConfig { if (!TimingsManager.hiddenConfigs.contains("settings.seed")) TimingsManager.hiddenConfigs.add("settings.seed"); } - public static String serverModName = "Purpur"; + public static String serverModName = "KeYi"; // KeYi private static void serverModName() { serverModName = getString("settings.server-mod-name", serverModName); } diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java index a810bfd3b8d6bd4d8f2ef8797e4281ae4fe8a67f..e5a63fc8d7b82408b892230c972b8ea0c59fa8a7 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -155,14 +155,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa if (isLongTimeout) { // Paper end log.log( Level.SEVERE, "------------------------------" ); - log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Purpur bug." ); // Paper // Purpur + log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a KeYi bug." ); // Paper // Purpur // KeYi 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 Purpur bug, please report this to https://github.com/PurpurMC/Purpur/issues" ); // Purpur + log.log( Level.SEVERE, "If you are unsure or still think this is a KeYi bug, please report this to https://github.com/PurpurMC/Purpur/issues" ); // Purpur // KeYi log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" ); - log.log( Level.SEVERE, "Purpur version: " + Bukkit.getServer().getVersion() ); // Purpur + log.log( Level.SEVERE, "KeYi version: " + Bukkit.getServer().getVersion() ); // Purpur // KeYi // if ( net.minecraft.world.level.Level.lastPhysicsProblem != null ) { @@ -185,12 +185,12 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa // Paper end } else { - log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PURPUR - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Purpur + log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO KEYI - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Purpur // KeYi 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 Purpur!):" ); // Paper // Purpur + log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to KeYi!):" ); // Paper // Purpur // KeYi io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system this.dumpTickingInfo(); // Paper - log detailed tick information WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); @@ -206,7 +206,7 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa WatchdogThread.dumpThread( thread, log ); } } else { - log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PURPUR - THIS IS NOT A BUG OR A CRASH ---"); // Purpur + log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO KEYI - THIS IS NOT A BUG OR A CRASH ---"); // Purpur // KeYi } log.log( Level.SEVERE, "------------------------------" );