diff --git a/patches/server/0009-Paper-command.patch b/patches/server/0009-Paper-command.patch index 82aa9db917e0..591619f62f2b 100644 --- a/patches/server/0009-Paper-command.patch +++ b/patches/server/0009-Paper-command.patch @@ -3,6 +3,7 @@ From: Zach Brown Date: Mon, 29 Feb 2016 21:02:09 -0600 Subject: [PATCH] Paper command +Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> diff --git a/src/main/java/io/papermc/paper/command/CommandUtil.java b/src/main/java/io/papermc/paper/command/CommandUtil.java new file mode 100644 @@ -81,17 +82,27 @@ index 0000000000000000000000000000000000000000..953c30500892e5f0c55b8597bc708ea8 +} diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..b3a58bf4b654e336826dc04da9e2f80ff8b9a9a7 +index 0000000000000000000000000000000000000000..84f3cfbee470f2e219f59b38b378a8f05c66b845 --- /dev/null +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -0,0 +1,145 @@ +@@ -0,0 +1,243 @@ +package io.papermc.paper.command; + ++import com.mojang.brigadier.builder.ArgumentBuilder; ++import com.mojang.brigadier.builder.LiteralArgumentBuilder; ++import com.mojang.brigadier.builder.RequiredArgumentBuilder; ++import com.mojang.brigadier.context.CommandContext; ++import com.mojang.brigadier.suggestion.SuggestionProvider; ++import com.mojang.brigadier.suggestion.Suggestions; ++import com.mojang.brigadier.suggestion.SuggestionsBuilder; ++import com.mojang.brigadier.tree.ArgumentCommandNode; ++import com.mojang.brigadier.tree.CommandNode; +import io.papermc.paper.command.subcommands.EntityCommand; +import io.papermc.paper.command.subcommands.HeapDumpCommand; +import io.papermc.paper.command.subcommands.ReloadCommand; +import io.papermc.paper.command.subcommands.VersionCommand; +import it.unimi.dsi.fastutil.Pair; ++import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; @@ -100,12 +111,15 @@ index 0000000000000000000000000000000000000000..b3a58bf4b654e336826dc04da9e2f80f +import java.util.Locale; +import java.util.Map; +import java.util.Set; ++import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; +import net.minecraft.Util; ++import net.minecraft.commands.CommandSourceStack; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; ++import org.bukkit.craftbukkit.command.BukkitCommandWrapper; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; @@ -115,6 +129,7 @@ index 0000000000000000000000000000000000000000..b3a58bf4b654e336826dc04da9e2f80f + +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.NamedTextColor.RED; ++import static net.minecraft.commands.Commands.literal; + +@DefaultQualifier(NonNull.class) +public final class PaperCommand extends Command { @@ -229,6 +244,90 @@ index 0000000000000000000000000000000000000000..b3a58bf4b654e336826dc04da9e2f80f + + return null; + } ++ ++ public LiteralArgumentBuilder brigadierNode(final String label, final BukkitCommandWrapper bukkitCommandWrapper) { ++ return new BrigadierMapper(bukkitCommandWrapper).brigadierNode(label); ++ } ++ ++ private record BrigadierMapper(BukkitCommandWrapper bukkitCommandWrapper) { ++ LiteralArgumentBuilder brigadierNode(final String label) { ++ final LiteralArgumentBuilder paperNode = literal(label); ++ SUBCOMMANDS.forEach((subLabel, cmd) -> paperNode.then(subcommandNode(subLabel, subLabel, cmd))); ++ ALIASES.forEach((alias, cmdName) -> paperNode.then(subcommandNode(alias, cmdName, SUBCOMMANDS.get(cmdName)))); ++ this.decorate(paperNode); ++ return paperNode; ++ } ++ ++ void decorate(final ArgumentBuilder node) { ++ this.decorate((Object) node); ++ } ++ ++ void decorate(final Object node) { ++ if (node instanceof ArgumentBuilder argumentBuilder) { ++ this.decorateBuilder(argumentBuilder); ++ } else if (node instanceof CommandNode commandNode) { ++ this.decorateNode(commandNode); ++ } else { ++ throw new IllegalArgumentException(); ++ } ++ } ++ ++ @SuppressWarnings("rawtypes") ++ void decorateNode(final CommandNode commandNode) { ++ // yes this is ugly, but it seemed like the easiest solution ++ try { ++ if (commandNode instanceof ArgumentCommandNode argumentCommandNode && argumentCommandNode.getCustomSuggestions() == null) { ++ final Field commandField = ArgumentCommandNode.class.getDeclaredField("customSuggestions"); ++ commandField.setAccessible(true); ++ commandField.set(argumentCommandNode, (SuggestionProvider) BrigadierMapper::bukkitSuggestions); ++ } ++ final Field commandField = CommandNode.class.getDeclaredField("command"); ++ commandField.setAccessible(true); ++ commandField.set(commandNode, this.bukkitCommandWrapper); ++ } catch (final ReflectiveOperationException e) { ++ throw new RuntimeException(e); ++ } ++ commandNode.getChildren().forEach(this::decorate); ++ } ++ ++ @SuppressWarnings({"rawtypes", "unchecked"}) ++ void decorateBuilder(final ArgumentBuilder argumentBuilder) { ++ if (argumentBuilder instanceof RequiredArgumentBuilder requiredArgumentBuilder && requiredArgumentBuilder.getSuggestionsProvider() == null) { ++ requiredArgumentBuilder.suggests(BrigadierMapper::bukkitSuggestions); ++ } ++ argumentBuilder.executes((com.mojang.brigadier.Command) this.bukkitCommandWrapper); ++ argumentBuilder.getArguments().forEach(this::decorate); ++ } ++ ++ static LiteralArgumentBuilder subcommandNode( ++ final String alias, ++ final String cmdName, ++ final PaperSubcommand cmd ++ ) { ++ final LiteralArgumentBuilder subCommandNode = literal(alias); ++ subCommandNode.requires(stack -> testPermission(stack.getBukkitSender(), cmdName)); ++ for (final ArgumentBuilder arg : cmd.nodes(cmdName)) { ++ subCommandNode.then(arg); ++ } ++ return subCommandNode; ++ } ++ ++ static CompletableFuture bukkitSuggestions( ++ final CommandContext ctx, ++ final SuggestionsBuilder builder ++ ) { ++ final CommandSourceStack stack = (CommandSourceStack) ctx.getSource(); ++ final List completions = stack.getServer().server.tabComplete( ++ stack.getBukkitSender(), ++ builder.getInput(), ++ stack.getLevel(), ++ stack.getPosition(), ++ true ++ ); ++ completions.forEach(builder::suggest); ++ return builder.buildFuture(); ++ } ++ } +} 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 @@ -265,14 +364,16 @@ index 0000000000000000000000000000000000000000..6a00f3d38da8107825ab1d405f337fd0 +} diff --git a/src/main/java/io/papermc/paper/command/PaperSubcommand.java b/src/main/java/io/papermc/paper/command/PaperSubcommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..6ff5d42a866d2752c73a766815aa190b2b0dc36f +index 0000000000000000000000000000000000000000..38e9c11f99464f86c4569af175adaff526a4692e --- /dev/null +++ b/src/main/java/io/papermc/paper/command/PaperSubcommand.java -@@ -0,0 +1,16 @@ +@@ -0,0 +1,22 @@ +package io.papermc.paper.command; + ++import com.mojang.brigadier.builder.ArgumentBuilder; +import java.util.Collections; +import java.util.List; ++import net.minecraft.commands.CommandSourceStack; +import org.bukkit.command.CommandSender; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; @@ -284,16 +385,21 @@ index 0000000000000000000000000000000000000000..6ff5d42a866d2752c73a766815aa190b + default List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { + return Collections.emptyList(); + } ++ ++ default List> nodes(final String subCommand) { ++ return Collections.emptyList(); ++ } +} diff --git a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..68f99e93ed3e843b4001a7a27620f88a48b85e67 +index 0000000000000000000000000000000000000000..ec0b9917a5085365ce5655614324310118748594 --- /dev/null +++ b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java -@@ -0,0 +1,145 @@ +@@ -0,0 +1,158 @@ +package io.papermc.paper.command.subcommands; + +import com.google.common.collect.Maps; ++import com.mojang.brigadier.builder.ArgumentBuilder; +import io.papermc.paper.command.CommandUtil; +import io.papermc.paper.command.PaperSubcommand; +import java.util.Collections; @@ -302,6 +408,7 @@ index 0000000000000000000000000000000000000000..68f99e93ed3e843b4001a7a27620f88a +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; ++import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerChunkCache; @@ -319,12 +426,23 @@ index 0000000000000000000000000000000000000000..68f99e93ed3e843b4001a7a27620f88a +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; + ++import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.NamedTextColor.RED; ++import static net.minecraft.commands.Commands.argument; ++import static net.minecraft.commands.Commands.literal; + +@DefaultQualifier(NonNull.class) +public final class EntityCommand implements PaperSubcommand { + @Override ++ public List> nodes(final String subCommand) { ++ return List.of( ++ literal("help"), ++ literal("list").then(argument("args", greedyString())) ++ ); ++ } ++ ++ @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + this.listEntities(sender, args); + return true; @@ -605,3 +723,19 @@ index 837fb51698e6650c6df720f798b7196322b6e7bb..80333fe069e417ef692cb7b80292ed42 private Iterable adventure$audiences; @Override public Iterable audiences() { +diff --git a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java +index 21971d52fa8ed92c946c519ba93a39aceae10f5f..815c4ee79a11bd4b3064ba42ba8678f13278d9bf 100644 +--- a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java ++++ b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java +@@ -28,6 +28,11 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command register(CommandDispatcher dispatcher, String label) { ++ // Paper start - brig meta for Paper command ++ if (this.command instanceof io.papermc.paper.command.PaperCommand paperCommand) { ++ return dispatcher.register(paperCommand.brigadierNode(label, this).requires(this)); ++ } ++ // Paper end + return dispatcher.register( + LiteralArgumentBuilder.literal(label).requires(this).executes(this) + .then(RequiredArgumentBuilder.argument("args", StringArgumentType.greedyString()).suggests(this).executes(this)) diff --git a/patches/server/0285-Make-the-default-permission-message-configurable.patch b/patches/server/0285-Make-the-default-permission-message-configurable.patch index 0b9434505396..59d50bd22565 100644 --- a/patches/server/0285-Make-the-default-permission-message-configurable.patch +++ b/patches/server/0285-Make-the-default-permission-message-configurable.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Make the default permission message configurable diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java -index b3a58bf4b654e336826dc04da9e2f80ff8b9a9a7..cd4936ef114b504df8649fba8f1823d94a4bb2a2 100644 +index e73c116f4361f455c37e99c838c68d7375d5513d..bb4e6f78bb5514356d22a66a1d56f7e3ea04994e 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -74,7 +74,7 @@ public final class PaperCommand extends Command { +@@ -88,7 +88,7 @@ public final class PaperCommand extends Command { if (sender.hasPermission(BASE_PERM + permission) || sender.hasPermission("bukkit.command.paper")) { return true; } diff --git a/patches/server/0298-Implement-Brigadier-Mojang-API.patch b/patches/server/0298-Implement-Brigadier-Mojang-API.patch index 3578f0784021..becc1a5946f1 100644 --- a/patches/server/0298-Implement-Brigadier-Mojang-API.patch +++ b/patches/server/0298-Implement-Brigadier-Mojang-API.patch @@ -82,7 +82,7 @@ index 685e04b1f17938d49cd126bcfe2f488f21afbea2..54bf5558c9048c215aee518874f3d96a event.getPlayer().getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2205849e8aaa161c5772b39d9368765a552a5a94..4ce4cba4f105c9abcad29173be38bb36feb1d061 100644 +index 67399b8881ff24b3465ae23aa6008639abcb4d8e..ed272499b40a96efd83f1a09a063e4d65dbe48e8 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -832,8 +832,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -114,7 +114,7 @@ index 2205849e8aaa161c5772b39d9368765a552a5a94..4ce4cba4f105c9abcad29173be38bb36 // Paper end - async tab completion } diff --git a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java -index 21971d52fa8ed92c946c519ba93a39aceae10f5f..0bba36d18d56a4dc2d6c6fb7969e5e6f0e1da404 100644 +index 815c4ee79a11bd4b3064ba42ba8678f13278d9bf..f166ababa53d33bef3811ce22d9e5cb78bc8d310 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java @@ -17,7 +17,7 @@ import net.minecraft.commands.CommandSourceStack; @@ -126,10 +126,10 @@ index 21971d52fa8ed92c946c519ba93a39aceae10f5f..0bba36d18d56a4dc2d6c6fb7969e5e6f private final CraftServer server; private final Command command; -@@ -28,10 +28,19 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command register(CommandDispatcher dispatcher, String label) { +@@ -33,10 +33,19 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Commandliteral(label).requires(this).executes(this) - .then(RequiredArgumentBuilder.argument("args", StringArgumentType.greedyString()).suggests(this).executes(this)) diff --git a/patches/server/0322-Chunk-debug-command.patch b/patches/server/0322-Chunk-debug-command.patch index 79c5f0f12863..a0722e42ad53 100644 --- a/patches/server/0322-Chunk-debug-command.patch +++ b/patches/server/0322-Chunk-debug-command.patch @@ -32,17 +32,18 @@ https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528273&page=com.atlass https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528577&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-528577 diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java -index cd4936ef114b504df8649fba8f1823d94a4bb2a2..395c43f6440c1e0e47919eef096ea8a8d552ccec 100644 +index bb4e6f78bb5514356d22a66a1d56f7e3ea04994e..548d2f29a4d18ebff379dca2e078d8b5a1358169 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -1,5 +1,6 @@ - package io.papermc.paper.command; - +@@ -9,6 +9,7 @@ import com.mojang.brigadier.suggestion.Suggestions; + import com.mojang.brigadier.suggestion.SuggestionsBuilder; + import com.mojang.brigadier.tree.ArgumentCommandNode; + import com.mojang.brigadier.tree.CommandNode; +import io.papermc.paper.command.subcommands.ChunkDebugCommand; import io.papermc.paper.command.subcommands.EntityCommand; import io.papermc.paper.command.subcommands.HeapDumpCommand; import io.papermc.paper.command.subcommands.ReloadCommand; -@@ -40,6 +41,7 @@ public final class PaperCommand extends Command { +@@ -54,6 +55,7 @@ public final class PaperCommand extends Command { commands.put(Set.of("entity"), new EntityCommand()); commands.put(Set.of("reload"), new ReloadCommand()); commands.put(Set.of("version"), new VersionCommand()); @@ -52,12 +53,13 @@ index cd4936ef114b504df8649fba8f1823d94a4bb2a2..395c43f6440c1e0e47919eef096ea8a8 .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) diff --git a/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..029ad37df71e74d9feb57e4b31b3602e55d49113 +index 0000000000000000000000000000000000000000..651afdf380e28f93f8277d913d698f214c7eca89 --- /dev/null +++ b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java -@@ -0,0 +1,166 @@ +@@ -0,0 +1,185 @@ +package io.papermc.paper.command.subcommands; + ++import com.mojang.brigadier.builder.ArgumentBuilder; +import io.papermc.paper.command.CommandUtil; +import io.papermc.paper.command.PaperSubcommand; +import java.io.File; @@ -67,6 +69,7 @@ index 0000000000000000000000000000000000000000..029ad37df71e74d9feb57e4b31b3602e +import java.util.Collections; +import java.util.List; +import java.util.Locale; ++import net.minecraft.commands.CommandSourceStack; +import net.minecraft.server.MCUtil; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ChunkHolder; @@ -78,15 +81,31 @@ index 0000000000000000000000000000000000000000..029ad37df71e74d9feb57e4b31b3602e +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; + ++import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.NamedTextColor.BLUE; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_AQUA; +import static net.kyori.adventure.text.format.NamedTextColor.GREEN; +import static net.kyori.adventure.text.format.NamedTextColor.RED; ++import static net.minecraft.commands.Commands.argument; ++import static net.minecraft.commands.Commands.literal; + +@DefaultQualifier(NonNull.class) +public final class ChunkDebugCommand implements PaperSubcommand { + @Override ++ public List> nodes(final String subCommand) { ++ switch (subCommand) { ++ case "debug" -> { ++ return List.of(literal("help"), literal("chunks")); ++ } ++ case "chunkinfo" -> { ++ return List.of(argument("worlds", greedyString())); ++ } ++ } ++ throw new IllegalArgumentException(); ++ } ++ ++ @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + switch (subCommand) { + case "debug" -> this.doDebug(sender, args); @@ -217,7 +236,8 @@ index 0000000000000000000000000000000000000000..029ad37df71e74d9feb57e4b31b3602e + } + } + // "help" & default -+ default -> sender.sendMessage(text("Use /paper debug [chunks] help for more information on a specific command", RED)); ++ default -> ++ sender.sendMessage(text("Use /paper debug [chunks] help for more information on a specific command", RED)); + } + } + diff --git a/patches/server/0352-Fix-Light-Command.patch b/patches/server/0352-Fix-Light-Command.patch index 9ddd1af8d219..630b9497a494 100644 --- a/patches/server/0352-Fix-Light-Command.patch +++ b/patches/server/0352-Fix-Light-Command.patch @@ -7,18 +7,18 @@ This lets you run /paper fixlight (max 5) to automatically fix all light data in the chunks. diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java -index 395c43f6440c1e0e47919eef096ea8a8d552ccec..f44ab1d71210e84328661c0feb662989a5635b6d 100644 +index 548d2f29a4d18ebff379dca2e078d8b5a1358169..3d8d8b02b4271c1e7cd13c8c1b6cfe31b794c153 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -2,6 +2,7 @@ package io.papermc.paper.command; - +@@ -11,6 +11,7 @@ import com.mojang.brigadier.tree.ArgumentCommandNode; + import com.mojang.brigadier.tree.CommandNode; import io.papermc.paper.command.subcommands.ChunkDebugCommand; import io.papermc.paper.command.subcommands.EntityCommand; +import io.papermc.paper.command.subcommands.FixLightCommand; import io.papermc.paper.command.subcommands.HeapDumpCommand; import io.papermc.paper.command.subcommands.ReloadCommand; import io.papermc.paper.command.subcommands.VersionCommand; -@@ -42,6 +43,7 @@ public final class PaperCommand extends Command { +@@ -56,6 +57,7 @@ public final class PaperCommand extends Command { commands.put(Set.of("reload"), new ReloadCommand()); commands.put(Set.of("version"), new VersionCommand()); commands.put(Set.of("debug", "chunkinfo"), new ChunkDebugCommand()); @@ -28,15 +28,18 @@ index 395c43f6440c1e0e47919eef096ea8a8d552ccec..f44ab1d71210e84328661c0feb662989 .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) diff --git a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..190df802cb24aa360f6cf4d291e38b4b3fe4a2ac +index 0000000000000000000000000000000000000000..d9d4bda504bf28b9a3b33c1b3e47235c31e6e06c --- /dev/null +++ b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java -@@ -0,0 +1,121 @@ +@@ -0,0 +1,132 @@ +package io.papermc.paper.command.subcommands; + ++import com.mojang.brigadier.builder.ArgumentBuilder; +import io.papermc.paper.command.PaperSubcommand; +import java.util.ArrayDeque; +import java.util.Deque; ++import java.util.List; ++import net.minecraft.commands.CommandSourceStack; +import net.minecraft.server.MCUtil; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ChunkHolder; @@ -52,12 +55,21 @@ index 0000000000000000000000000000000000000000..190df802cb24aa360f6cf4d291e38b4b +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; + ++import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.NamedTextColor.GREEN; +import static net.kyori.adventure.text.format.NamedTextColor.RED; ++import static net.minecraft.commands.Commands.argument; + +@DefaultQualifier(NonNull.class) +public final class FixLightCommand implements PaperSubcommand { ++ private static final int MAX_RADIUS = 2; ++ ++ @Override ++ public List> nodes(final String subCommand) { ++ return List.of(argument("radius", integer(0, MAX_RADIUS))); ++ } ++ + @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + this.doFixLight(sender, args); @@ -78,10 +90,9 @@ index 0000000000000000000000000000000000000000..190df802cb24aa360f6cf4d291e38b4b + sender.sendMessage(text("Radius cannot be negative!", RED)); + return; + } -+ final int maxRadius = 5; -+ radius = Math.min(maxRadius, parsed); ++ radius = Math.min(MAX_RADIUS, parsed); + if (radius != parsed) { -+ post = () -> sender.sendMessage(text("Radius '" + parsed + "' was not in the required range [0, " + maxRadius + "], it was lowered to the maximum (" + maxRadius + " chunks).", RED)); ++ post = () -> sender.sendMessage(text("Radius '" + parsed + "' was not in the required range [0, " + MAX_RADIUS + "], it was lowered to the maximum (" + MAX_RADIUS + " chunks).", RED)); + } + } catch (final Exception e) { + sender.sendMessage(text("'" + args[0] + "' is not a valid number.", RED)); diff --git a/patches/server/0361-Add-debug-for-sync-chunk-loads.patch b/patches/server/0361-Add-debug-for-sync-chunk-loads.patch index 1ea33e7ff086..ec56d9e6fbc5 100644 --- a/patches/server/0361-Add-debug-for-sync-chunk-loads.patch +++ b/patches/server/0361-Add-debug-for-sync-chunk-loads.patch @@ -194,18 +194,18 @@ index 0000000000000000000000000000000000000000..0bb4aaa546939b67a5d22865190f3047 + } +} diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java -index f44ab1d71210e84328661c0feb662989a5635b6d..25f6d1c15cdfb4abdf1edd2ad9bbdc0e37b546f3 100644 +index 3d8d8b02b4271c1e7cd13c8c1b6cfe31b794c153..7c2b6c2134207cbeae64534c1ebf7b25b2321e6f 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -5,6 +5,7 @@ import io.papermc.paper.command.subcommands.EntityCommand; +@@ -14,6 +14,7 @@ import io.papermc.paper.command.subcommands.EntityCommand; import io.papermc.paper.command.subcommands.FixLightCommand; import io.papermc.paper.command.subcommands.HeapDumpCommand; import io.papermc.paper.command.subcommands.ReloadCommand; +import io.papermc.paper.command.subcommands.SyncLoadInfoCommand; import io.papermc.paper.command.subcommands.VersionCommand; import it.unimi.dsi.fastutil.Pair; - import java.util.ArrayList; -@@ -44,6 +45,7 @@ public final class PaperCommand extends Command { + import java.lang.reflect.Field; +@@ -58,6 +59,7 @@ public final class PaperCommand extends Command { commands.put(Set.of("version"), new VersionCommand()); commands.put(Set.of("debug", "chunkinfo"), new ChunkDebugCommand()); commands.put(Set.of("fixlight"), new FixLightCommand()); @@ -215,16 +215,17 @@ index f44ab1d71210e84328661c0feb662989a5635b6d..25f6d1c15cdfb4abdf1edd2ad9bbdc0e .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) diff --git a/src/main/java/io/papermc/paper/command/subcommands/SyncLoadInfoCommand.java b/src/main/java/io/papermc/paper/command/subcommands/SyncLoadInfoCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..1120aef5b0dd983c467167f77245884e1198552a +index 0000000000000000000000000000000000000000..4b8e9a7421907611986e926bbdfd11e8638a37a2 --- /dev/null +++ b/src/main/java/io/papermc/paper/command/subcommands/SyncLoadInfoCommand.java -@@ -0,0 +1,78 @@ +@@ -0,0 +1,86 @@ +package io.papermc.paper.command.subcommands; + +import com.destroystokyo.paper.io.SyncLoadFinder; +import com.google.gson.JsonObject; +import com.google.gson.internal.Streams; +import com.google.gson.stream.JsonWriter; ++import com.mojang.brigadier.builder.ArgumentBuilder; +import io.papermc.paper.command.CommandUtil; +import io.papermc.paper.command.PaperSubcommand; +import java.io.File; @@ -234,6 +235,7 @@ index 0000000000000000000000000000000000000000..1120aef5b0dd983c467167f77245884e +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; ++import net.minecraft.commands.CommandSourceStack; +import org.bukkit.command.CommandSender; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; @@ -242,10 +244,16 @@ index 0000000000000000000000000000000000000000..1120aef5b0dd983c467167f77245884e +import static net.kyori.adventure.text.format.NamedTextColor.GRAY; +import static net.kyori.adventure.text.format.NamedTextColor.GREEN; +import static net.kyori.adventure.text.format.NamedTextColor.RED; ++import static net.minecraft.commands.Commands.literal; + +@DefaultQualifier(NonNull.class) +public final class SyncLoadInfoCommand implements PaperSubcommand { + @Override ++ public List> nodes(final String subCommand) { ++ return List.of(literal("clear")); ++ } ++ ++ @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + this.doSyncLoadInfo(sender, args); + return true; diff --git a/patches/server/0443-Paper-dumpitem-command.patch b/patches/server/0443-Paper-dumpitem-command.patch index 930a212a00e5..26300d77a92f 100644 --- a/patches/server/0443-Paper-dumpitem-command.patch +++ b/patches/server/0443-Paper-dumpitem-command.patch @@ -6,18 +6,18 @@ Subject: [PATCH] Paper dumpitem command Let's you quickly view the item in your hands NBT data diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java -index 25f6d1c15cdfb4abdf1edd2ad9bbdc0e37b546f3..d2536f4ffae721f4df714b5345fa3329c3b8e3f5 100644 +index 7c2b6c2134207cbeae64534c1ebf7b25b2321e6f..84c5a4f4202b39c641c4f20cdb09ba114a71c8e0 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -1,6 +1,7 @@ - package io.papermc.paper.command; - +@@ -10,6 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; + import com.mojang.brigadier.tree.ArgumentCommandNode; + import com.mojang.brigadier.tree.CommandNode; import io.papermc.paper.command.subcommands.ChunkDebugCommand; +import io.papermc.paper.command.subcommands.DumpItemCommand; import io.papermc.paper.command.subcommands.EntityCommand; import io.papermc.paper.command.subcommands.FixLightCommand; import io.papermc.paper.command.subcommands.HeapDumpCommand; -@@ -46,6 +47,7 @@ public final class PaperCommand extends Command { +@@ -60,6 +61,7 @@ public final class PaperCommand extends Command { commands.put(Set.of("debug", "chunkinfo"), new ChunkDebugCommand()); commands.put(Set.of("fixlight"), new FixLightCommand()); commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand()); diff --git a/patches/server/0676-Fix-commands-from-signs-not-firing-command-events.patch b/patches/server/0676-Fix-commands-from-signs-not-firing-command-events.patch index 01d4a6921df0..263236774648 100644 --- a/patches/server/0676-Fix-commands-from-signs-not-firing-command-events.patch +++ b/patches/server/0676-Fix-commands-from-signs-not-firing-command-events.patch @@ -112,10 +112,10 @@ index 831db5ee21938d71e99bf9d17b92a6ca15531740..def4fdd2c7e4f925fa128692a744e5d1 public DyeColor getColor() { diff --git a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java -index 0bba36d18d56a4dc2d6c6fb7969e5e6f0e1da404..a246a0bd9e57fb0703ba756e8aa1109f1674c0e8 100644 +index f166ababa53d33bef3811ce22d9e5cb78bc8d310..83423ffaf1e178c0cc89be86575601e949d05a54 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java -@@ -50,7 +50,7 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command context) throws CommandSyntaxException { diff --git a/patches/server/0729-Add-paper-mobcaps-and-paper-playermobcaps.patch b/patches/server/0729-Add-paper-mobcaps-and-paper-playermobcaps.patch index b5dc131bb0a6..ef28585c73b2 100644 --- a/patches/server/0729-Add-paper-mobcaps-and-paper-playermobcaps.patch +++ b/patches/server/0729-Add-paper-mobcaps-and-paper-playermobcaps.patch @@ -10,10 +10,10 @@ Also has a hover text on each mob category listing what entity types are in said category diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java -index d2536f4ffae721f4df714b5345fa3329c3b8e3f5..60b0ce4557390ee7030efe4c90933402c57bab59 100644 +index 84c5a4f4202b39c641c4f20cdb09ba114a71c8e0..e949474a6f070cb23c63091a87eb46e01554850f 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -5,6 +5,7 @@ import io.papermc.paper.command.subcommands.DumpItemCommand; +@@ -14,6 +14,7 @@ import io.papermc.paper.command.subcommands.DumpItemCommand; import io.papermc.paper.command.subcommands.EntityCommand; import io.papermc.paper.command.subcommands.FixLightCommand; import io.papermc.paper.command.subcommands.HeapDumpCommand; @@ -21,7 +21,7 @@ index d2536f4ffae721f4df714b5345fa3329c3b8e3f5..60b0ce4557390ee7030efe4c90933402 import io.papermc.paper.command.subcommands.ReloadCommand; import io.papermc.paper.command.subcommands.SyncLoadInfoCommand; import io.papermc.paper.command.subcommands.VersionCommand; -@@ -48,6 +49,7 @@ public final class PaperCommand extends Command { +@@ -62,6 +63,7 @@ public final class PaperCommand extends Command { commands.put(Set.of("fixlight"), new FixLightCommand()); commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand()); commands.put(Set.of("dumpitem"), new DumpItemCommand()); @@ -31,13 +31,14 @@ index d2536f4ffae721f4df714b5345fa3329c3b8e3f5..60b0ce4557390ee7030efe4c90933402 .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) diff --git a/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..2e02d94e2903c48f6d08e743c1cf8bad9f9662df +index 0000000000000000000000000000000000000000..f4c76aa2c647fc39504bb33a6761ee4d815e7442 --- /dev/null +++ b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java -@@ -0,0 +1,229 @@ +@@ -0,0 +1,248 @@ +package io.papermc.paper.command.subcommands; + +import com.google.common.collect.ImmutableMap; ++import com.mojang.brigadier.builder.ArgumentBuilder; +import io.papermc.paper.command.CommandUtil; +import io.papermc.paper.command.PaperSubcommand; +import java.util.ArrayList; @@ -51,6 +52,7 @@ index 0000000000000000000000000000000000000000..2e02d94e2903c48f6d08e743c1cf8bad +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; ++import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.Registry; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; @@ -66,6 +68,9 @@ index 0000000000000000000000000000000000000000..2e02d94e2903c48f6d08e743c1cf8bad +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; + ++import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; ++import static net.minecraft.commands.Commands.argument; ++ +@DefaultQualifier(NonNull.class) +public final class MobcapsCommand implements PaperSubcommand { + static final Map MOB_CATEGORY_COLORS = ImmutableMap.builder() @@ -80,6 +85,19 @@ index 0000000000000000000000000000000000000000..2e02d94e2903c48f6d08e743c1cf8bad + .build(); + + @Override ++ public List> nodes(final String subCommand) { ++ switch (subCommand) { ++ case "mobcaps" -> { ++ return List.of(argument("worlds", greedyString())); ++ } ++ case "playermobcaps" -> { ++ return List.of(argument("player", greedyString())); ++ } ++ } ++ throw new IllegalArgumentException(); ++ } ++ ++ @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + switch (subCommand) { + case "mobcaps" -> this.printMobcaps(sender, args); @@ -92,7 +110,8 @@ index 0000000000000000000000000000000000000000..2e02d94e2903c48f6d08e743c1cf8bad + public List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { + return switch (subCommand) { + case "mobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestMobcaps(args)); -+ case "playermobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestPlayerMobcaps(sender, args)); ++ case "playermobcaps" -> ++ CommandUtil.getListMatchingLast(sender, args, this.suggestPlayerMobcaps(sender, args)); + default -> throw new IllegalArgumentException(); + }; + } diff --git a/patches/server/0738-Do-not-copy-visible-chunks.patch b/patches/server/0738-Do-not-copy-visible-chunks.patch index 1b2f6fcee846..7374dfa3b70c 100644 --- a/patches/server/0738-Do-not-copy-visible-chunks.patch +++ b/patches/server/0738-Do-not-copy-visible-chunks.patch @@ -9,10 +9,10 @@ the function. I saw approximately 1/3rd of the function on the copy. diff --git a/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java -index 029ad37df71e74d9feb57e4b31b3602e55d49113..4b367982fae4662c326aa247824e9c4185896de1 100644 +index 651afdf380e28f93f8277d913d698f214c7eca89..dcef27d267a477b4e809aeef8eddca2b9b144145 100644 --- a/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java +++ b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java -@@ -90,7 +90,7 @@ public final class ChunkDebugCommand implements PaperSubcommand { +@@ -108,7 +108,7 @@ public final class ChunkDebugCommand implements PaperSubcommand { int ticking = 0; int entityTicking = 0; diff --git a/patches/server/0791-Rewrite-the-light-engine.patch b/patches/server/0791-Rewrite-the-light-engine.patch index cb60f1cacb58..35d2c6593e95 100644 --- a/patches/server/0791-Rewrite-the-light-engine.patch +++ b/patches/server/0791-Rewrite-the-light-engine.patch @@ -4358,10 +4358,10 @@ index 0000000000000000000000000000000000000000..dd995e25ae620ae36cd5eecb2fe10ad0 + +} diff --git a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java -index 190df802cb24aa360f6cf4d291e38b4b3fe4a2ac..68645bbbab9b4225048b647252d8f462028a9c84 100644 +index d9d4bda504bf28b9a3b33c1b3e47235c31e6e06c..9a900f5931734f18453a81b07bd43000a00e1cc3 100644 --- a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java +++ b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java -@@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerLevel; +@@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ThreadedLevelLightEngine; import net.minecraft.world.level.ChunkPos; @@ -4369,25 +4369,24 @@ index 190df802cb24aa360f6cf4d291e38b4b3fe4a2ac..68645bbbab9b4225048b647252d8f462 import net.minecraft.world.level.chunk.LevelChunk; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.entity.CraftPlayer; -@@ -19,6 +20,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; - import org.checkerframework.framework.qual.DefaultQualifier; +@@ -23,13 +24,15 @@ import org.checkerframework.framework.qual.DefaultQualifier; + import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.format.NamedTextColor.BLUE; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_AQUA; import static net.kyori.adventure.text.format.NamedTextColor.GREEN; import static net.kyori.adventure.text.format.NamedTextColor.RED; + import static net.minecraft.commands.Commands.argument; -@@ -44,7 +47,7 @@ public final class FixLightCommand implements PaperSubcommand { - sender.sendMessage(text("Radius cannot be negative!", RED)); - return; - } -- final int maxRadius = 5; -+ final int maxRadius = 32; // Paper - MOOOOOORE - radius = Math.min(maxRadius, parsed); - if (radius != parsed) { - post = () -> sender.sendMessage(text("Radius '" + parsed + "' was not in the required range [0, " + maxRadius + "], it was lowered to the maximum (" + maxRadius + " chunks).", RED)); -@@ -59,12 +62,67 @@ public final class FixLightCommand implements PaperSubcommand { + @DefaultQualifier(NonNull.class) + public final class FixLightCommand implements PaperSubcommand { +- private static final int MAX_RADIUS = 2; ++ private static final int MAX_RADIUS = 32; // Paper - MOOOOOORE + + @Override + public List> nodes(final String subCommand) { +@@ -70,12 +73,67 @@ public final class FixLightCommand implements PaperSubcommand { ServerPlayer handle = player.getHandle(); ServerLevel world = (ServerLevel) handle.level; ThreadedLevelLightEngine lightengine = world.getChunkSource().getLightEngine(); @@ -5039,7 +5038,7 @@ index c85380c3bf3bf4448a28a91af78f41c235a583e4..d870cefbe5b7485f423817f4f639e3e2 while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -index 1326dc1239e00e7001c9ea98713b955b37e759b9..09201b51d6b9fadcef7e38d6a108bfafc5235fbe 100644 +index 5ebde3a4f99b8d017d9a10a30fefc0b7dd011319..7908360dd47937b2cb702e381802b7b278a5198e 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java @@ -203,7 +203,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer diff --git a/patches/server/0894-Don-t-tick-markers.patch b/patches/server/0894-Don-t-tick-markers.patch index 848b3dc5fbcb..26993c72fa8a 100644 --- a/patches/server/0894-Don-t-tick-markers.patch +++ b/patches/server/0894-Don-t-tick-markers.patch @@ -9,10 +9,10 @@ list is only used in the tick and tickPassenger methods, so we can safely not ad markers to it. diff --git a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java -index 68f99e93ed3e843b4001a7a27620f88a48b85e67..0dc96c39151ec4dbeec3947cb17606f53a6392d4 100644 +index ec0b9917a5085365ce5655614324310118748594..c3ee1da2f4106a78c0ffe03201d938bcff38a90a 100644 --- a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java +++ b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java -@@ -103,7 +103,7 @@ public final class EntityCommand implements PaperSubcommand { +@@ -116,7 +116,7 @@ public final class EntityCommand implements PaperSubcommand { ChunkPos chunk = e.chunkPosition(); info.left++; info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1);