Move module commands under /iris module <root> <command...>

Module commands get their own branch, with the alias /iris m. <root> is the
root a module registers through ToolingRegistry.registerCommand, so
/iris module structure list|info|verify replaces /iris structure list.

- Bukkit: the branch word is taken before the Director runs; the Director
  first, then dispatcher fallback and the merged completions are gone. The
  first word completes "module".
- Modded: the greedy-string tails at the /iris root and inside the
  structure literal are gone. The module and m literals take one greedy
  string, because the roots belong to the modules of the pack the sender
  resolves to when the line runs, so they cannot be Brigadier nodes when the
  tree is built.
- /iris module alone lists the mounted roots and their commands; an unknown
  root is an error that points to that list.
- Permissions are unchanged: iris.all, and commands opened to everyone.
- /iris structure import and capture stay Director commands.
This commit is contained in:
piexel committed 2026-11-06 14:29:05 +01:00
1 parent 88fe8c8bcd
commit f7aaed79a6
33 files changed
+230 -102

No files matched your search

@@ -5,7 +5,10 @@ import art.arcane.iris.core.localization.PackDownloadMessages;
import art.arcane.iris.core.lifecycle.LifecycleOperationCoordinator;
import art.arcane.iris.core.pack.PackDownloader;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import net.minecraft.SharedConstants;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.Bootstrap;
@@ -159,11 +162,39 @@ public class IrisModdedCommandParityTest {
assertNotNull("iris", iris.getCommand());
for (String category : new String[]{"help", "find", "goto", "pregen", "pregenerate", "object", "o",
"edit", "studio", "std", "s", "pack", "pk", "world", "w", "datapack", "datapacks", "dp",
"structure", "struct", "str", "developer", "dev"}) {
"structure", "struct", "str", "developer", "dev", "module", "m"}) {
assertNotNull(category, child(iris, category).getCommand());
}
}
@Test
public void moduleCommandsHaveTheirOwnBranchAndNoTailElsewhere() {
CommandNode<CommandSourceStack> iris = irisNode();
for (CommandNode<CommandSourceStack> node : iris.getChildren()) {
assertTrue(node.getName() + " must be a literal", node instanceof LiteralCommandNode);
}
for (CommandNode<CommandSourceStack> node : child(iris, "structure").getChildren()) {
assertTrue("structure " + node.getName() + " must be a literal", node instanceof LiteralCommandNode);
}
for (String branch : new String[]{"module", "m"}) {
CommandNode<CommandSourceStack> module = child(iris, branch);
assertNotNull(branch + " lists the mounted commands on its own", module.getCommand());
CommandNode<CommandSourceStack> rest = child(module, "command");
assertTrue(rest instanceof ArgumentCommandNode);
assertEquals(StringArgumentType.StringType.GREEDY_PHRASE, ((StringArgumentType) ((ArgumentCommandNode<?, ?>) rest).getType()).getType());
assertNotNull(rest.getCommand());
}
}
private static CommandNode<CommandSourceStack> irisNode() {
SharedConstants.tryDetectVersion();
Bootstrap.bootStrap();
CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher<>();
IrisModdedCommands.register(dispatcher);
return child(dispatcher.getRoot(), "iris");
}
@Test
public void consoleHelpListsEveryEntryWithInlineUsageAndDescription() {
List<String> root = ModdedCommandHelp.consoleLines("");
@@ -282,12 +282,9 @@ public class IrisModdedStructureCommandTest {
@Test
public void structureListInfoAndVerifyBelongToTheStructureModule() throws IOException {
String source = source("ModdedStructureCommands.java");
String tree = source("ModdedCommandTree.java");
assertTrue(source.contains("ModdedToolingTail.after(name)"));
assertFalse(source.contains("Commands.literal(\"list\")"));
assertFalse(source.contains("verifyTree("));
assertTrue(tree.contains("root.then(ModdedToolingTail.after())"));
}
private String source(String fileName) throws IOException {