From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Wed, 8 Jul 2026 18:15:19 +0800 Subject: [PATCH] Rebrand to Shiroha diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java index 08745a35b1ce8cc56d970472088de3cd17b9e43a..02bf179039196aeeb94c7392c28c214c9a19e641 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("Folia", serverUUID, logFailedRequests, Bukkit.getLogger()); // Folia - we have our own bstats page + Metrics metrics = new Metrics("Shiroha", serverUUID, logFailedRequests, Bukkit.getLogger()); // Folia - we have our own bstats page // Shiroha - Rebrand to Shiroha metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> { String minecraftVersion = Bukkit.getVersion(); @@ -607,11 +607,11 @@ public class Metrics { final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion(); if (implVersion != null) { final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1); - paperVersion = "git-Folia-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Folia - we have our own bstats page + paperVersion = "git-Shiroha-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Folia - we have our own bstats page // Shiroha - Rebrand to Shiroha } else { paperVersion = "unknown"; } - metrics.addCustomChart(new Metrics.SimplePie("folia_version", () -> paperVersion)); // Folia - we have our own bstats page + metrics.addCustomChart(new Metrics.SimplePie("shiroha_version", () -> paperVersion)); // Folia - we have our own bstats page // Shiroha - Rebrand to Shiroha 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 30815c8970b1f1c88a3c7bb5fd36efd915f1687d..9eb39592791ef9790e24f622bb78157492dcb47b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -40,8 +40,8 @@ public class PaperVersionFetcher implements VersionFetcher { private static final ComponentLogger COMPONENT_LOGGER = ComponentLogger.logger(LogManager.getRootLogger().getName()); private static final int DISTANCE_ERROR = -1; private static final int DISTANCE_UNKNOWN = -2; - private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/folia"; // Folia - private static final String REPOSITORY = "PaperMC/Folia"; // Folia + private static final String DOWNLOAD_PAGE = "https://codeberg.org/NanaChiyo0721/Shiroha"; // Folia // Shiroha - Rebrand to Shiroha + private static final String REPOSITORY = "Nanachiyo0721/Shiroha"; // Folia // Shiroha - Rebrand to Shiroha private static final ServerBuildInfo BUILD_INFO = ServerBuildInfo.buildInfo(); private static final String USER_AGENT = BUILD_INFO.brandName() + "/" + BUILD_INFO.asString(VERSION_SIMPLE) + " (https://papermc.io)"; private static final Gson GSON = new Gson(); @@ -72,7 +72,7 @@ public class PaperVersionFetcher implements VersionFetcher { COMPONENT_LOGGER.warn(text("*** You are running a development version without access to version information ***")); } else { final Optional apiResult = fetchMinecraftVersionList(); - if (buildNumber.isPresent()) { + if (buildNumber.isPresent() && false) { // Shiroha - Rebrand to Shiroha - we do not have a version manager api currently, disable it distance = fetchDistanceFromSiteApi(buildNumber.getAsInt()); } else { final Optional gitBranch = BUILD_INFO.gitBranch(); @@ -111,7 +111,7 @@ public class PaperVersionFetcher implements VersionFetcher { int distance = DISTANCE_ERROR; final OptionalInt buildNumber = PaperVersionFetcher.BUILD_INFO.buildNumber(); - if (buildNumber.isPresent()) { + if (buildNumber.isPresent() && false) { // Shiroha - Rebrand to Shiroha - we do not have a version manager api currently, disable it distance = fetchDistanceFromSiteApi(buildNumber.getAsInt()); } else { final Optional gitBranch = PaperVersionFetcher.BUILD_INFO.gitBranch(); @@ -226,7 +226,7 @@ public class PaperVersionFetcher implements VersionFetcher { // Contributed by Techcable in GH-65 private static int fetchDistanceFromGitHub(final String branch, final String hash) { try { - final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(PaperVersionFetcher.REPOSITORY, branch, hash)).toURL().openConnection(); + final HttpURLConnection connection = (HttpURLConnection) URI.create("https://codeberg.org/api/v1/repos/%s/compare/%s...%s".formatted(PaperVersionFetcher.REPOSITORY, hash, branch)).toURL().openConnection(); // Shiroha - Rebrand to Shiroha connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.setRequestProperty("User-Agent", PaperVersionFetcher.USER_AGENT); @@ -234,14 +234,16 @@ public class PaperVersionFetcher implements VersionFetcher { if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return DISTANCE_UNKNOWN; // Unknown commit try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { final JsonObject obj = GSON.fromJson(reader, JsonObject.class); - final String status = obj.get("status").getAsString(); - return switch (status) { - case "identical" -> 0; - case "behind" -> obj.get("behind_by").getAsInt(); - default -> DISTANCE_ERROR; - }; + // Shiroha start - Rebrand to Shiroha + if (obj == null || !obj.has("commits") || !obj.get("commits").isJsonArray()) { + LOGGER.error("Unexpected response shape from Codeberg's compare API"); + return DISTANCE_ERROR; + } + + return obj.getAsJsonArray("commits").size(); + // Shiroha end } catch (final JsonSyntaxException | NumberFormatException e) { - LOGGER.error("Error parsing json from GitHub's API", e); + LOGGER.error("Error parsing json from Codeberg's API", e); // Shiroha - Rebrand to Shiroha return DISTANCE_ERROR; } } catch (final IOException e) { diff --git a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java index 10a0be7a4db1a51579d113d279af7a9effe7f438..3d53b8f7a49c80d37b02fe72d11779b851700705 100644 --- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java +++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java @@ -31,6 +31,7 @@ public record ServerBuildInfoImpl( private static final String ATTRIBUTE_GIT_COMMIT = "Git-Commit"; private static final String BRAND_PAPER_NAME = "Paper"; + private static final String BRAND_SHIROHA_NAME = "Shiroha"; // Shiroha - Rebrand to Shiroha private static final String BUILD_DEV = "DEV"; @@ -42,9 +43,9 @@ public record ServerBuildInfoImpl( this( getManifestAttribute(manifest, ATTRIBUTE_BRAND_ID) .map(Key::key) - .orElse(Key.key("papermc", "folia")), // Folia + .orElse(BRAND_SHIROHA_ID), // Folia // Shiroha - Rebrand to Shiroha getManifestAttribute(manifest, ATTRIBUTE_BRAND_NAME) - .orElse("Folia"), // Folia + .orElse(BRAND_SHIROHA_NAME), // Folia // Shiroha - Rebrand to Shiroha SharedConstants.getCurrentVersion().id(), SharedConstants.getCurrentVersion().name(), getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER) @@ -61,7 +62,7 @@ public record ServerBuildInfoImpl( @Override public boolean isBrandCompatible(final @NotNull Key brandId) { - return brandId.equals(this.brandId); + return brandId.equals(this.brandId) || brandId.equals(BRAND_PAPER_ID) || brandId.equals(BRAND_FOLIA_ID); // Shiroha - Rebrand to Shiroha } @Override diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java index 5607f4cc8ca2f620461eb5e97d01d9db0d6b2303..6f0a2d3bc3d966079978db8dfb19236eeb89d579 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -80,9 +80,9 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre 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 Paper bug, please report this to https://github.com/PaperMC/Paper/issues"); + logger.log(Level.SEVERE, "If you are unsure or still think this is a Shiroha bug, please report this to https://github.com/Nanachiyo0721/Shiroha/issues"); // Shiroha - Rebrand to Shiroha logger.log(Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports"); - logger.log(Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion()); + logger.log(Level.SEVERE, "Shiroha version: " + Bukkit.getServer().getVersion()); // Shiroha - Rebrand to Shiroha if (net.minecraft.world.level.Level.lastPhysicsProblem != null) { logger.log(Level.SEVERE, "------------------------------");