diff --git a/patches/api/0003-Disable-reload-command-by-default.patch b/patches/api/0003-Disable-reload-command-by-default.patch index 2d112f3..7b6048f 100644 --- a/patches/api/0003-Disable-reload-command-by-default.patch +++ b/patches/api/0003-Disable-reload-command-by-default.patch @@ -3,29 +3,24 @@ From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Mon, 12 Jun 2023 00:23:38 +0300 Subject: [PATCH] Disable reload command by default -This is fully rewritten reload command. Reloading in Bukkit VERY, VERY UNSTABLE and I removed it +This is fully rewritten reload command, you can enable or disable it with -DDivineMC.EnableReloadCommand flag Read this article why reload is VERY UNSAFE in Bukkit: https://madelinemiller.dev/blog/problem-with-reload/ diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java -index bdfe68b386b5ca2878475e548d3c9a3808fce848..ce4aa866eacd5c07f915986cee740edf007e6978 100644 +index bdfe68b386b5ca2878475e548d3c9a3808fce848..0a21f2138969f75425b720487e626aac796821d1 100644 --- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java +++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java -@@ -1,13 +1,10 @@ +@@ -1,8 +1,7 @@ package org.bukkit.command.defaults; -import java.util.Arrays; -import java.util.Collections; import java.util.List; --import org.bukkit.Bukkit; --import org.bukkit.ChatColor; ++ + import org.bukkit.Bukkit; + import org.bukkit.ChatColor; import org.bukkit.command.Command; - import org.bukkit.command.CommandSender; - import org.jetbrains.annotations.NotNull; -+import net.kyori.adventure.text.format.NamedTextColor; // DivineMC - - public class ReloadCommand extends BukkitCommand { - public ReloadCommand(@NotNull String name) { -@@ -15,7 +12,7 @@ public class ReloadCommand extends BukkitCommand { +@@ -15,7 +14,7 @@ public class ReloadCommand extends BukkitCommand { this.description = "Reloads the server configuration and plugins"; this.usageMessage = "/reload [permissions|commands|confirm]"; // Paper this.setPermission("bukkit.command.reload"); @@ -34,7 +29,7 @@ index bdfe68b386b5ca2878475e548d3c9a3808fce848..ce4aa866eacd5c07f915986cee740edf } @org.jetbrains.annotations.ApiStatus.Internal // Paper -@@ -25,48 +22,12 @@ public class ReloadCommand extends BukkitCommand { +@@ -25,48 +24,53 @@ public class ReloadCommand extends BukkitCommand { public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { // Paper if (!testPermission(sender)) return true; @@ -48,23 +43,47 @@ index bdfe68b386b5ca2878475e548d3c9a3808fce848..ce4aa866eacd5c07f915986cee740edf - } else if ("commands".equalsIgnoreCase(args[0])) { - if (Bukkit.getServer().reloadCommandAliases()) { - Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Command aliases successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN)); -- } else { ++ // DivineMC start - disable reload command by default & add startup flag ++ if (System.getProperty("DivineMC.EnableReloadCommand") == null || false) { ++ sender.sendMessage(net.kyori.adventure.text.Component.text("Operation denied, command disabled.", net.kyori.adventure.text.format.NamedTextColor.RED )); ++ sender.sendMessage(net.kyori.adventure.text.Component.text("Reload command SHOULD NEVER be used in whatever circumstances.", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); ++ sender.sendMessage(net.kyori.adventure.text.Component.text("DivineMC has intentionally disabled it in order to stop you using it, instead of restarting your server.", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); ++ sender.sendMessage(net.kyori.adventure.text.Component.text("If you still want to enable reload command, add -DDivineMC.EnableReloadCommand=true flag to your startup arguments.", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); ++ sender.sendMessage(net.kyori.adventure.text.Component.text("---------------------------------------------", net.kyori.adventure.text.format.NamedTextColor.GREEN)); ++ sender.sendMessage(net.kyori.adventure.text.Component.text("RESTART YOUR SERVER AND NEVER USE /reload", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); ++ sender.sendMessage(net.kyori.adventure.text.Component.text("To learn more, read this article: https://madelinemiller.dev/blog/problem-with-reload", net.kyori.adventure.text.format.NamedTextColor.GREEN)); ++ } else { ++ if (args.length == 1) { ++ if (args[0].equalsIgnoreCase("permissions")) { ++ Bukkit.getServer().reloadPermissions(); ++ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Permissions successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN)); ++ return true; ++ } else if ("commands".equalsIgnoreCase(args[0])) { ++ if (Bukkit.getServer().reloadCommandAliases()) { ++ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Command aliases successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN)); ++ } else { ++ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("An error occurred while trying to reload command aliases.", net.kyori.adventure.text.format.NamedTextColor.RED)); ++ } ++ return true; + } else { - Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("An error occurred while trying to reload command aliases.", net.kyori.adventure.text.format.NamedTextColor.RED)); -- } ++ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Usage: " + usageMessage, net.kyori.adventure.text.format.NamedTextColor.RED)); ++ return true; + } - return true; - } else if ("confirm".equalsIgnoreCase(args[0])) { - confirmed = true; - } else { - Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Usage: " + usageMessage, net.kyori.adventure.text.format.NamedTextColor.RED)); - return true; -- } + } - } - if (!confirmed) { - Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Are you sure you wish to reload your server? Doing so may cause bugs and memory leaks. It is recommended to restart instead of using /reload. To confirm, please type ", net.kyori.adventure.text.format.NamedTextColor.RED).append(net.kyori.adventure.text.Component.text("/reload confirm", net.kyori.adventure.text.format.NamedTextColor.YELLOW))); - return true; - } - // Paper end -- + - Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins."); - Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server."); - // Paper start - lifecycle events @@ -74,15 +93,25 @@ index bdfe68b386b5ca2878475e548d3c9a3808fce848..ce4aa866eacd5c07f915986cee740edf - if (ex.getMessage().equals(RELOADING_DISABLED_MESSAGE)) { - Command.broadcastCommandMessage(sender, ChatColor.RED + RELOADING_DISABLED_MESSAGE); - return true; -- } -- } ++ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins."); ++ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server."); ++ // Paper start - lifecycle events ++ try { ++ Bukkit.reload(); ++ } catch (final IllegalStateException ex) { ++ if (ex.getMessage().equals(RELOADING_DISABLED_MESSAGE)) { ++ Command.broadcastCommandMessage(sender, ChatColor.RED + RELOADING_DISABLED_MESSAGE); ++ return true; ++ } + } ++ // Paper end - lifecycle events ++ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete."); ++ ++ return true; + } - // Paper end - lifecycle events - Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete."); -- -+ // DivineMC start - Disable reload command by default -+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Reloading disabled by default in DivineMC.", NamedTextColor.RED)); -+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("This is a permanent change!", NamedTextColor.RED)); -+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Read here why it is unsafe: https://madelinemiller.dev/blog/problem-with-reload", NamedTextColor.GREEN)); + return true; + // DivineMC end } diff --git a/patches/api/0007-Hide-unnecessary-compilation-warnings.patch b/patches/api/0007-Hide-unnecessary-compilation-warnings.patch new file mode 100644 index 0000000..2104f82 --- /dev/null +++ b/patches/api/0007-Hide-unnecessary-compilation-warnings.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Mon, 20 May 2024 07:14:21 +0300 +Subject: [PATCH] Hide unnecessary compilation warnings + + +diff --git a/build.gradle.kts b/build.gradle.kts +index 78cae5a080f65646494e7d1d8a52df969db6d3b1..e33a4bd94cbaf07ed10f0b160ca0e65ec2383b66 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -130,6 +130,15 @@ val generateApiVersioningFile by tasks.registering { + } + } + ++// DivineMC start - Hide unnecessary compilation warnings ++tasks.withType { ++ val compilerArgs = options.compilerArgs ++ compilerArgs.add("-Xlint:-module") ++ compilerArgs.add("-Xlint:-removal") ++ compilerArgs.add("-Xlint:-dep-ann") ++} ++// DivineMC end ++ + tasks.jar { + from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { + into("META-INF/maven/${project.group}/${project.name}") +@@ -189,6 +198,8 @@ tasks.withType { + into("build/docs/javadoc") + } + } ++ ++ options.addStringOption("Xdoclint:none", "-quiet") // DivineMC - Hide unnecessary compilation warnings + } + + tasks.test { diff --git a/patches/server/0001-Divine-Branding.patch b/patches/server/0001-Divine-Branding.patch index cc2b1ea..fc7f72f 100644 --- a/patches/server/0001-Divine-Branding.patch +++ b/patches/server/0001-Divine-Branding.patch @@ -159,7 +159,7 @@ index 3cb56595822799926a8141e60a42f5d1edfc6de5..05478a1ea04ec0396bc8c97090edef4a .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 a6e5950b5875cafd734300cdfbf58f5d3736f3c8..3c2102bd861f65474968a51d379993efc639bdc3 100644 +index a6e5950b5875cafd734300cdfbf58f5d3736f3c8..7256e02150a2ddc2afd821299d36b1c71b7930b6 100644 --- a/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java +++ b/src/main/java/io/papermc/paper/ServerBuildInfoImpl.java @@ -32,6 +32,7 @@ public record ServerBuildInfoImpl( @@ -178,10 +178,36 @@ index a6e5950b5875cafd734300cdfbf58f5d3736f3c8..3c2102bd861f65474968a51d379993ef + .orElse(BRAND_DIVINEMC_ID), // DivineMC getManifestAttribute(manifest, ATTRIBUTE_BRAND_NAME) - .orElse(BRAND_PURPUR_NAME), // Purpur -+ .orElse(BRAND_DIVINEMC_NAME), // Purpur ++ .orElse(BRAND_DIVINEMC_NAME), // DivineMC SharedConstants.getCurrentVersion().getId(), SharedConstants.getCurrentVersion().getName(), getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER) +diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java +index c366d84518979e842a6f10f969a5951539ecac93..b44daf19e76e9729980a4c871edd31dc293143fd 100644 +--- a/src/main/java/net/minecraft/CrashReport.java ++++ b/src/main/java/net/minecraft/CrashReport.java +@@ -127,7 +127,7 @@ public class CrashReport { + stringbuilder.append("---- Minecraft Crash Report ----\n"); + // Purpur start + stringbuilder.append("// "); +- stringbuilder.append("// DO NOT REPORT THIS TO PAPER! REPORT TO PURPUR INSTEAD!"); ++ stringbuilder.append("// DO NOT REPORT THIS TO PAPER! REPORT TO DIVINEMC INSTEAD!"); // DivineMC + // Purpur end + stringbuilder.append("// "); + stringbuilder.append(CrashReport.getErrorComment()); +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 71705ccbc0cce88382b1fb536271773a332ad3a2..acb0e7d4cb383a37b18d5981ee55e78e08a66922 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -962,7 +962,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop hiddenConfigEntries = List.of( - "database", -@@ -328,9 +330,9 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -328,9 +328,9 @@ public class GlobalConfiguration extends ConfigurationPart { public boolean fixEntityPositionDesync = true; public boolean loadPermissionsYmlBeforePlugins = true; @Constraints.Min(4) @@ -205,7 +190,7 @@ index efc91ff91827872c62b8bd060282549ccdcf67dd..2b3075505f09c15cee350b7a7f5e7571 public float maxLeashDistance = 10f; public boolean disableSprintInterruptionOnAttack = false; diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java -index bcdd2bc6ffc91349ac75833bd3928e8ca7de7a0f..a5dec9d6858fc19d6877a8ae93e51dcbccabd635 100644 +index b5092184076946b7169b67086b9542a9685c15f3..3d37b1413187004df679ee7744d8be2aaaeec670 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java @@ -241,7 +241,7 @@ public class PurpurConfig { diff --git a/patches/server/0035-Delete-Timings.patch b/patches/server/0035-Delete-Timings.patch index df46756..9a8f58d 100644 --- a/patches/server/0035-Delete-Timings.patch +++ b/patches/server/0035-Delete-Timings.patch @@ -767,7 +767,7 @@ index 02597f890ac7f2dc12c94c283356b8309638dd17..7b00e6bd50cafd87e63863c186418973 String content = context.getRange().get(context.getInput()); String[] args = org.apache.commons.lang3.StringUtils.split(content, ' '); // fix adjacent spaces (from console/plugins) causing empty array elements diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index d02d22b09430b93349d48bcb50d456d23f9b49c7..07fce8459d75920a4c5089506cf233d9194d9f29 100644 +index 17961dd8fbe306dfcb721db2830f0156db453a62..5dfb0c95642ab2e16501b9f95d96e02354643f34 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -1,6 +1,5 @@ @@ -777,15 +777,36 @@ index d02d22b09430b93349d48bcb50d456d23f9b49c7..07fce8459d75920a4c5089506cf233d9 import com.mojang.logging.LogUtils; import io.papermc.paper.configuration.constraint.Constraints; import io.papermc.paper.configuration.type.number.IntOr; -@@ -112,7 +111,7 @@ public class GlobalConfiguration extends ConfigurationPart { - - @PostProcess - private void postProcess() { -- MinecraftTimings.processConfig(this); -+ - } +@@ -91,28 +90,7 @@ public class GlobalConfiguration extends ConfigurationPart { + public boolean useDisplayNameInQuitMessage = false; } +- @Deprecated(forRemoval = true) +- public Timings timings; +- +- @Deprecated(forRemoval = true) +- public class Timings extends ConfigurationPart { +- public boolean enabled = true; +- public boolean verbose = true; +- public String url = "https://timings.aikar.co/"; +- public boolean serverNamePrivacy = false; +- public List hiddenConfigEntries = List.of( +- "database", +- "proxies.velocity.secret" +- ); +- public int historyInterval = 300; +- public int historyLength = 3600; +- public String serverName = "Unknown Server"; +- +- @PostProcess +- private void postProcess() { +- MinecraftTimings.processConfig(this); +- } +- } ++ // DivineMC - Remove timings configuration section + + public Proxies proxies; + diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java index 0e3bed7a75f8f4611f9f44a1f78fd70cc06eaa54..126ed4bd24d993b598c112c2dbfcb9d662038925 100644 --- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java @@ -842,7 +863,7 @@ index 8c134a642ccaf3530022f2e675a858d726e1dda4..d6daa27a8d7aca00b181e90d789f4249 } catch (Exception exception) { if (exception instanceof ReportedException) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 71705ccbc0cce88382b1fb536271773a332ad3a2..eca0c8afe003e0c3155aded8b5a9855ad0952e60 100644 +index acb0e7d4cb383a37b18d5981ee55e78e08a66922..08ec1a1c9b4a044c2ae6da145f09645d89da96cb 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -3,7 +3,6 @@ package net.minecraft.server; @@ -1094,7 +1115,7 @@ index 8120f39a9689dae1233b243b74825e9ff110eac3..4203dae9628b0576cc0b9a9160dca985 return this != EntityType.PLAYER && this != EntityType.LLAMA_SPIT && this != EntityType.WITHER && this != EntityType.BAT && this != EntityType.ITEM_FRAME && this != EntityType.GLOW_ITEM_FRAME && this != EntityType.LEASH_KNOT && this != EntityType.PAINTING && this != EntityType.END_CRYSTAL && this != EntityType.EVOKER_FANGS; } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index cb9429ea4c7c8521e17fcb46a8457d95bfb76cf7..4a224af1a9063e1617bc6753e063e8e395271ec7 100644 +index 18f03478a4f2c5b71d243aada4173abf9f33cc20..0f60b2fb44ecaf037c8235ed0d3da017e65310e3 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -150,8 +150,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; @@ -1240,7 +1261,7 @@ index d62bb6611ec37ec9c35712810cc65a60cb88ed6e..93cf19c3bb09f4b639c60d1093181256 tryPreloadClass("org.slf4j.helpers.FormattingTuple"); tryPreloadClass("org.slf4j.helpers.BasicMarker"); diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index ca8ae8e1c51b937dac916e0b0dc94b5e2e61efeb..2ed64f924170afe61829db270445cc16b4e61cdf 100644 +index e68e13ac375a6418ad0785bc1c0f20af72bf6cf5..e51a9ec41054750c38f95b06881980842c2c57f3 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -1,6 +1,5 @@ @@ -1334,7 +1355,7 @@ index d3ec817e95628f1fc8be4a29c9a0f13c7d5fd552..e9798517b9211c50a20ea5c69603aab3 } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 3daf674f1e0de3fdd89db5536cc1e34140a5abb8..066ad76b6545016d79009f46678106802e36d1f9 100644 +index 3daf674f1e0de3fdd89db5536cc1e34140a5abb8..110c5879d54c8251913ea9af571af27a1a7f5dc9 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -219,7 +219,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -1346,6 +1367,15 @@ index 3daf674f1e0de3fdd89db5536cc1e34140a5abb8..066ad76b6545016d79009f4667810680 } // Paper end +@@ -506,7 +506,7 @@ public final class CraftMagicNumbers implements UnsafeValues { + // Paper start + @Override + public String getTimingsServerName() { +- return io.papermc.paper.configuration.GlobalConfiguration.get().timings.serverName; ++ return "Unknown Server"; // DivineMC - strict assignment of the server name to an unknown + } + + @Override diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java index de2b469f06f6679aed1d20156052bfbef5e7c30b..d429b2ad38db053f8906f38a2d7fdee0099f4d3a 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java