From 4d7c2c787c7bebbc1479fb50d134708207351d5c Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 9 Jun 2022 14:43:27 -0700 Subject: [PATCH] move commands out of configuration --- ...dd-Early-Warning-Feature-to-WatchDog.patch | 4 +- .../Add-debug-for-sync-chunk-loads.patch | 7 +-- ...aper-mobcaps-and-paper-playermobcaps.patch | 9 +-- .../Add-tick-times-API-and-mspt-command.patch | 16 +++--- ...d-version-history-to-version-command.patch | 4 +- patches/server/Anti-Xray.patch | 5 +- patches/server/Chunk-debug-command.patch | 9 +-- ...tab-completions-for-brigadier-comman.patch | 4 +- patches/server/Fix-Light-Command.patch | 2 +- ...s-to-convert-between-Component-and-B.patch | 4 +- patches/server/Paper-Metrics.patch | 39 ++++--------- patches/server/Paper-command.patch | 55 ++++++++++++++----- patches/server/Paper-config-files.patch | 11 ---- patches/server/Paper-dumpitem-command.patch | 8 --- 14 files changed, 78 insertions(+), 99 deletions(-) diff --git a/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch b/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch index 3cffc77b89..9484ae6134 100644 --- a/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch +++ b/patches/server/Add-Early-Warning-Feature-to-WatchDog.patch @@ -29,9 +29,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 paperConfigurations.initializeGlobalConfiguration(); paperConfigurations.initializeWorldDefaultsConfiguration(); + org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); - io.papermc.paper.configuration.PaperConfigurations.registerCommands(this); + io.papermc.paper.command.PaperCommands.registerCommands(this); + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now - // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/patches/server/Add-debug-for-sync-chunk-loads.patch b/patches/server/Add-debug-for-sync-chunk-loads.patch index fd952601fd..96f7d28392 100644 --- a/patches/server/Add-debug-for-sync-chunk-loads.patch +++ b/patches/server/Add-debug-for-sync-chunk-loads.patch @@ -23,14 +23,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.google.common.base.Functions; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSet; - import com.google.common.collect.Iterables; - import com.google.common.collect.Lists; +@@ -0,0 +0,0 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; + import net.minecraft.core.Registry; + import net.minecraft.resources.ResourceLocation; +import com.google.gson.JsonObject; +import com.google.gson.internal.Streams; +import com.google.gson.stream.JsonWriter; -+import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.MCUtil; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerChunkCache; diff --git a/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch b/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch index a8418c10a5..a46419aafb 100644 --- a/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch +++ b/patches/server/Add-paper-mobcaps-and-paper-playermobcaps.patch @@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -@@ -0,0 +0,0 @@ import com.google.common.collect.Maps; +@@ -0,0 +0,0 @@ import net.minecraft.resources.ResourceLocation; import com.google.gson.JsonObject; import com.google.gson.internal.Streams; import com.google.gson.stream.JsonWriter; @@ -31,18 +31,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; -+import net.minecraft.core.Registry; - import net.minecraft.resources.ResourceLocation; - import net.minecraft.server.MCUtil; import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ChunkHolder; + import net.minecraft.server.level.ServerChunkCache; @@ -0,0 +0,0 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ThreadedLevelLightEngine; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.ChunkPos; - import net.minecraft.network.protocol.game.ClientboundLightUpdatePacket; - import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MCUtil; +import net.minecraft.world.level.NaturalSpawner; import org.apache.commons.lang3.tuple.MutablePair; diff --git a/patches/server/Add-tick-times-API-and-mspt-command.patch b/patches/server/Add-tick-times-API-and-mspt-command.patch index 96c7b88d6f..e7327183e5 100644 --- a/patches/server/Add-tick-times-API-and-mspt-command.patch +++ b/patches/server/Add-tick-times-API-and-mspt-command.patch @@ -109,19 +109,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return text(DF.format(avg), avg >= 50 ? RED : avg >= 40 ? YELLOW : GREEN); + } +} -diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +--- a/src/main/java/io/papermc/paper/command/PaperCommands.java ++++ b/src/main/java/io/papermc/paper/command/PaperCommands.java @@ -0,0 +0,0 @@ - package io.papermc.paper.configuration; + package io.papermc.paper.command; +import com.destroystokyo.paper.MSPTCommand; - import com.destroystokyo.paper.Metrics; import com.destroystokyo.paper.PaperCommand; - import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray; -@@ -0,0 +0,0 @@ public class PaperConfigurations extends Configurations COMMANDS = new HashMap<>(); static { COMMANDS.put("paper", new PaperCommand("paper")); + COMMANDS.put("mspt", new MSPTCommand("mspt")); diff --git a/patches/server/Add-version-history-to-version-command.patch b/patches/server/Add-version-history-to-version-command.patch index f15d40b984..297be168cb 100644 --- a/patches/server/Add-version-history-to-version-command.patch +++ b/patches/server/Add-version-history-to-version-command.patch @@ -205,9 +205,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - paperConfigurations.initializeGlobalConfiguration(); paperConfigurations.initializeWorldDefaultsConfiguration(); - io.papermc.paper.configuration.PaperConfigurations.registerCommands(this); + io.papermc.paper.command.PaperCommands.registerCommands(this); + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now // Paper end diff --git a/patches/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch index f9718e80fc..821894c7d6 100644 --- a/patches/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -1020,10 +1020,9 @@ diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -0,0 +0,0 @@ package io.papermc.paper.configuration; +@@ -0,0 +0,0 @@ + package io.papermc.paper.configuration; - import com.destroystokyo.paper.Metrics; - import com.destroystokyo.paper.PaperCommand; +import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray; import com.google.common.base.Suppliers; import com.google.common.collect.Table; diff --git a/patches/server/Chunk-debug-command.patch b/patches/server/Chunk-debug-command.patch index fb2866807c..3869da4f80 100644 --- a/patches/server/Chunk-debug-command.patch +++ b/patches/server/Chunk-debug-command.patch @@ -35,11 +35,9 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java -@@ -0,0 +0,0 @@ import com.google.common.collect.ImmutableSet; - import com.google.common.collect.Iterables; - import com.google.common.collect.Lists; - import com.google.common.collect.Maps; --import net.minecraft.resources.ResourceLocation; +@@ -0,0 +0,0 @@ import com.google.common.collect.Maps; + import net.minecraft.core.Registry; + import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerChunkCache; @@ -47,7 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.ChunkPos; -+import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MCUtil; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; diff --git a/patches/server/Enhance-console-tab-completions-for-brigadier-comman.patch b/patches/server/Enhance-console-tab-completions-for-brigadier-comman.patch index 7f22e4b3a1..2b03a8a0bc 100644 --- a/patches/server/Enhance-console-tab-completions-for-brigadier-comman.patch +++ b/patches/server/Enhance-console-tab-completions-for-brigadier-comman.patch @@ -215,9 +215,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 paperConfigurations.initializeWorldDefaultsConfiguration(); org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); + thread.start(); // Paper - start console thread after MinecraftServer.console & PaperConfig are initialized - io.papermc.paper.configuration.PaperConfigurations.registerCommands(this); + io.papermc.paper.command.PaperCommands.registerCommands(this); + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now - // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java diff --git a/patches/server/Fix-Light-Command.patch b/patches/server/Fix-Light-Command.patch index 9052ed29c7..7d9aa60607 100644 --- a/patches/server/Fix-Light-Command.patch +++ b/patches/server/Fix-Light-Command.patch @@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.server.level.ThreadedLevelLightEngine; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.ChunkPos; - import net.minecraft.resources.ResourceLocation; + import net.minecraft.server.MCUtil; @@ -0,0 +0,0 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.CraftServer; diff --git a/patches/server/Implement-methods-to-convert-between-Component-and-B.patch b/patches/server/Implement-methods-to-convert-between-Component-and-B.patch index 89cca9543f..de9e37c386 100644 --- a/patches/server/Implement-methods-to-convert-between-Component-and-B.patch +++ b/patches/server/Implement-methods-to-convert-between-Component-and-B.patch @@ -46,8 +46,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - thread.start(); // Paper - start console thread after MinecraftServer.console & PaperConfig are initialized - io.papermc.paper.configuration.PaperConfigurations.registerCommands(this); + io.papermc.paper.command.PaperCommands.registerCommands(this); + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now + io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider // Paper end diff --git a/patches/server/Paper-Metrics.patch b/patches/server/Paper-Metrics.patch index 264da795f0..552d57fd5b 100644 --- a/patches/server/Paper-Metrics.patch +++ b/patches/server/Paper-Metrics.patch @@ -689,37 +689,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } +} -diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -0,0 +0,0 @@ - package io.papermc.paper.configuration; +--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + paperConfigurations.initializeGlobalConfiguration(); + paperConfigurations.initializeWorldDefaultsConfiguration(); + io.papermc.paper.command.PaperCommands.registerCommands(this); ++ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); + // Paper end -+import com.destroystokyo.paper.Metrics; - import com.destroystokyo.paper.PaperCommand; - import com.google.common.base.Suppliers; - import com.google.common.collect.Table; -@@ -0,0 +0,0 @@ public class PaperConfigurations extends Configurations COMMANDS = new HashMap<>(); -+ private static boolean metricsStarted = false; - static { - COMMANDS.put("paper", new PaperCommand("paper")); - } -@@ -0,0 +0,0 @@ public class PaperConfigurations extends Configurations { - server.server.getCommandMap().register(s, "Paper", command); - }); -+ -+ if (!metricsStarted) { -+ Metrics.PaperMetrics.startMetrics(); -+ metricsStarted = true; -+ } - } - - @Deprecated + this.setPvpAllowed(dedicatedserverproperties.pvp); diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java diff --git a/patches/server/Paper-command.patch b/patches/server/Paper-command.patch index 53c6121d75..2e8b00fdb6 100644 --- a/patches/server/Paper-command.patch +++ b/patches/server/Paper-command.patch @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; ++import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerChunkCache; @@ -296,25 +297,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Command.broadcastCommandMessage(sender, text("Paper config reload complete.", GREEN)); + } +} -diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/command/PaperCommands.java @@ -0,0 +0,0 @@ - package io.papermc.paper.configuration; - ++package io.papermc.paper.command; ++ +import com.destroystokyo.paper.PaperCommand; - import com.google.common.base.Suppliers; - import com.google.common.collect.Table; - import com.mojang.logging.LogUtils; -@@ -0,0 +0,0 @@ public class PaperConfigurations extends Configurations COMMANDS = new HashMap<>(); - static { ++import net.minecraft.server.MinecraftServer; ++import org.bukkit.command.Command; ++ ++import java.util.HashMap; ++import java.util.Map; ++ ++public final class PaperCommands { ++ ++ private PaperCommands() { ++ } ++ ++ private static final Map COMMANDS = new HashMap<>(); ++ static { + COMMANDS.put("paper", new PaperCommand("paper")); - } ++ } ++ ++ public static void registerCommands(final MinecraftServer server) { ++ COMMANDS.forEach((s, command) -> { ++ server.server.getCommandMap().register(s, "Paper", command); ++ }); ++ } ++} +diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + // Paper start + paperConfigurations.initializeGlobalConfiguration(); + paperConfigurations.initializeWorldDefaultsConfiguration(); ++ io.papermc.paper.command.PaperCommands.registerCommands(this); + // Paper end - public static void registerCommands(final MinecraftServer server) { + this.setPvpAllowed(dedicatedserverproperties.pvp); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 03deb5aed6..aa004adaba 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -1192,16 +1192,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return Files.exists(legacyConfig) && Files.isRegularFile(legacyConfig); + } + -+ private static final Map COMMANDS = new HashMap<>(); -+ static { -+ } -+ -+ public static void registerCommands(final MinecraftServer server) { -+ COMMANDS.forEach((s, command) -> { -+ server.server.getCommandMap().register(s, "Paper", command); -+ }); -+ } -+ + @Deprecated + public YamlConfiguration createLegacyObject(final MinecraftServer server) { + YamlConfiguration global = YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.globalConfigFileName).toFile()); @@ -4016,7 +4006,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + paperConfigurations.initializeGlobalConfiguration(); + paperConfigurations.initializeWorldDefaultsConfiguration(); -+ io.papermc.paper.configuration.PaperConfigurations.registerCommands(this); + // Paper end this.setPvpAllowed(dedicatedserverproperties.pvp); diff --git a/patches/server/Paper-dumpitem-command.patch b/patches/server/Paper-dumpitem-command.patch index d516f6a334..b89750e255 100644 --- a/patches/server/Paper-dumpitem-command.patch +++ b/patches/server/Paper-dumpitem-command.patch @@ -9,14 +9,6 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java -@@ -0,0 +0,0 @@ import net.minecraft.server.level.ServerPlayer; - import net.minecraft.server.level.ThreadedLevelLightEngine; - import net.minecraft.world.entity.EntityType; - import net.minecraft.world.level.ChunkPos; -+import net.minecraft.network.protocol.game.ClientboundLightUpdatePacket; - import net.minecraft.resources.ResourceLocation; - import net.minecraft.server.MCUtil; - import org.apache.commons.lang3.tuple.MutablePair; @@ -0,0 +0,0 @@ import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld;