From 2a68f41bef2c595d8c2d54a0437b094176fe2426 Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 6 Nov 2026 10:51:15 +0100 Subject: [PATCH] Mount the tooling commands on the modded /iris root A greedy-string tail with a suggestion provider sits next to the literals of the /iris root and inside the structure literals, so literal commands keep winning. The modded list, info and verify trees and ModdedLocateCommands.verifyStructures are deleted; the import and capture notices stay. --- .../modded/command/IrisModdedCommands.java | 11 -- .../modded/command/ModdedCommandTree.java | 3 +- .../modded/command/ModdedLocateCommands.java | 60 -------- .../command/ModdedStructureCommands.java | 133 ++---------------- .../modded/command/ModdedToolingSender.java | 91 ++++++++++++ .../modded/command/ModdedToolingTail.java | 73 ++++++++++ .../IrisModdedStructureCommandTest.java | 26 +--- 7 files changed, 187 insertions(+), 210 deletions(-) create mode 100644 adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingSender.java create mode 100644 adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingTail.java diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/IrisModdedCommands.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/IrisModdedCommands.java index 5d8a9ba68..3230a76ca 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/IrisModdedCommands.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/IrisModdedCommands.java @@ -40,10 +40,7 @@ import art.arcane.iris.modded.ModdedWorldgenIds; import art.arcane.iris.spi.IrisLogging; import art.arcane.volmlib.util.collection.KMap; import com.mojang.brigadier.CommandDispatcher; -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.LiteralCommandNode; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -508,14 +505,6 @@ public final class IrisModdedCommands { return 1; } - static int verifyStructures(CommandSourceStack source, String keyRaw) { - return ModdedLocateCommands.verifyStructures(source, keyRaw); - } - - static CompletableFuture suggestStructureKeys(CommandContext context, SuggestionsBuilder builder) { - return ModdedCommandSuggestions.suggestStructureKeys(context, builder); - } - static void warnTabFailure(String suggestion, CommandSourceStack source, Throwable error) { ModdedCommandSuggestions.warnTabFailure(suggestion, source, error); } diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedCommandTree.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedCommandTree.java index b42598754..5c23ac1df 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedCommandTree.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedCommandTree.java @@ -43,7 +43,7 @@ final class ModdedCommandTree { List.of("pack=overworld", "pack=underworld", "link="), builder ); - private static final Predicate GATE = Commands.hasPermission(Commands.LEVEL_GAMEMASTERS); + static final Predicate GATE = Commands.hasPermission(Commands.LEVEL_GAMEMASTERS); /** * SP-4: read-only inspection must work for an unopped player in a no-cheats singleplayer world, where the * what/height overlays are the only way to see what Iris generated. Everything that mutates a world, @@ -151,6 +151,7 @@ final class ModdedCommandTree { root.then(ModdedStructureCommands.tree("str")); root.then(ModdedDeveloperCommands.tree("developer")); root.then(ModdedDeveloperCommands.tree("dev")); + root.then(ModdedToolingTail.after()); return root; } diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedLocateCommands.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedLocateCommands.java index 7e9e0ecad..a36a8e056 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedLocateCommands.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedLocateCommands.java @@ -324,66 +324,6 @@ final class ModdedLocateCommands { IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_TELEPORTED_AT, MessageArgument.untrusted("label", label), MessageArgument.untrusted("targetX", targetX), MessageArgument.untrusted("clampedY", clampedY), MessageArgument.untrusted("targetZ", targetZ))); } - static int verifyStructures(CommandSourceStack source, String keyRaw) { - ServerLevel level = source.getLevel(); - Engine engine = IrisModdedCommands.engineFor(level); - if (engine == null) { - IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_THIS_DIMENSION_IS_NOT_GENERATED_BY_IRIS_12)); - return 0; - } - String key = keyRaw == null ? "" : keyRaw.trim(); - if (!key.isEmpty()) { - return verifyStructure(source, level, engine, key); - } - Registry registry = source.getServer().registryAccess().lookupOrThrow(Registries.STRUCTURE); - int available = 0; - int disabled = 0; - int suppressed = 0; - int unreachableBiomes = 0; - int unsupported = 0; - for (Identifier identifier : registry.keySet()) { - Optional> holder = registry.get(identifier); - if (holder.isEmpty()) { - continue; - } - NativeStructureAvailability availability = nativeAvailability(source, level, engine, - identifier.toString(), holder.get()); - switch (availability) { - case AVAILABLE -> available++; - case WORLD_DISABLED, FILTERED -> disabled++; - case IRIS_SUPPRESSED -> suppressed++; - case EMPTY_BIOME_FILTER, BIOME_UNREACHABLE -> unreachableBiomes++; - case NO_PLACEMENT -> unsupported++; - } - } - int irisPlaced = ModuleServices.placedStructures(engine).size(); - IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_STRUCTURE_REACHABILITY_NATIVE_GENERATION_ELIGIBLE_IRIS_PLACED_NATIVE_DISABLED_NATIVE, MessageArgument.untrusted("available", available), MessageArgument.untrusted("irisPlaced", irisPlaced), MessageArgument.untrusted("disabled", disabled), MessageArgument.untrusted("suppressed", suppressed), MessageArgument.untrusted("unreachableBiomes", unreachableBiomes), MessageArgument.untrusted("unsupported", unsupported))); - return 1; - } - - private static int verifyStructure(CommandSourceStack source, ServerLevel level, Engine engine, String key) { - Optional target = resolveNativeStructure(source, level, engine, key); - if (target.isEmpty()) { - if (ModuleServices.placesStructure(engine, key)) { - IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_STRUCTURE_IS_IRIS_PLACED_LOCATABLE_WITH_IRIS_GOTO_STRUCTURE, MessageArgument.untrusted("key", key), MessageArgument.untrusted("key2", key))); - return 1; - } - IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_UNKNOWN_STRUCTURE_IT_IS_NEITHER_IRIS_PLACED_NOR_REGISTERED_BY, MessageArgument.untrusted("key", key))); - return 0; - } - NativeStructureTarget resolved = target.get(); - if (resolved.availability() == NativeStructureAvailability.IRIS_SUPPRESSED) { - IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_STRUCTURE_IS_EXPLICITLY_REPLACED_BY_IRIS_PLACEMENT_LOCATABLE_WITH_IRIS, MessageArgument.untrusted("value", resolved.key()), MessageArgument.untrusted("value2", resolved.key()))); - return 1; - } - if (resolved.availability() != NativeStructureAvailability.AVAILABLE) { - IrisModdedCommands.fail(source, nativeUnavailableMessage(resolved.key(), resolved.availability())); - return 0; - } - IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_NATIVE_STRUCTURE_IS_ENABLED_SUPPORTED_BY_THIS_DIMENSION_S_GENERATOR, MessageArgument.untrusted("value", resolved.key()), MessageArgument.untrusted("value2", resolved.key()))); - return 1; - } - private static Optional resolveNativeStructure(CommandSourceStack source, ServerLevel level, Engine engine, diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java index 15dbc7959..e5a25fb26 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStructureCommands.java @@ -18,79 +18,40 @@ package art.arcane.iris.modded.command; -import art.arcane.iris.core.modules.StructureAssemblies; -import art.arcane.iris.engine.framework.structure.StructureResources; -import art.arcane.iris.core.loader.IrisData; -import art.arcane.iris.core.structure.StructureIndexService; -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.PlacedStructurePiece; -import art.arcane.iris.engine.framework.StructureAssembler; -import art.arcane.iris.engine.framework.structure.StructureAssemblyResult; -import art.arcane.iris.engine.object.value.IrisPosition; -import art.arcane.iris.engine.object.structure.IrisStructure; -import art.arcane.volmlib.util.math.RNG; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; 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 net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.commands.SharedSuggestionProvider; -import java.io.File; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; - -import art.arcane.iris.core.localization.IrisLanguage; -import art.arcane.iris.core.localization.ModdedCommandMessages; -import art.arcane.volmlib.util.localization.MessageArgument; +/** + * The {@code /iris structure} literals that only explain the Bukkit-only import and capture. The structure module's own + * commands ({@code list}, {@code info}, {@code verify}) reach the sender through the tooling tail of this node. + */ public final class ModdedStructureCommands { - private static final Predicate GATE = Commands.hasPermission(Commands.LEVEL_GAMEMASTERS); - - private static final SuggestionProvider IRIS_STRUCTURE_KEYS = (CommandContext context, SuggestionsBuilder builder) -> suggestIrisStructureKeys(context, builder); - private static final SuggestionProvider ALL_STRUCTURE_KEYS = (CommandContext context, SuggestionsBuilder builder) -> IrisModdedCommands.suggestStructureKeys(context, builder); + private static final String IMPORT_EXPLANATION = "Structure import rebuilds vanilla & datapack structures as editable Iris resources through Bukkit/NMS template managers; run /iris structure import on a Bukkit server against this pack, then copy the pack folder over."; + private static final String CAPTURE_EXPLANATION = "Structure capture generates each structure in a throwaway Bukkit scratch world to read its blocks; it requires the Bukkit plugin (v26 NMS binding)."; private ModdedStructureCommands() { } public static LiteralArgumentBuilder tree(String name) { - LiteralArgumentBuilder root = Commands.literal(name).requires(GATE); + LiteralArgumentBuilder root = Commands.literal(name).requires(ModdedCommandTree.GATE); root.executes((CommandContext context) -> ModdedCommandHelp.send(context.getSource(), name)); - root.then(Commands.literal("list") - .executes((CommandContext context) -> list(context.getSource()))); - root.then(Commands.literal("ls") - .executes((CommandContext context) -> list(context.getSource()))); - - root.then(Commands.literal("info") - .then(Commands.argument("key", StringArgumentType.greedyString()).suggests(IRIS_STRUCTURE_KEYS) - .executes((CommandContext context) -> info(context.getSource(), StringArgumentType.getString(context, "key"))))); - - root.then(message("import", "Structure import rebuilds vanilla & datapack structures as editable Iris resources through Bukkit/NMS template managers; run /iris structure import on a Bukkit server against this pack, then copy the pack folder over.")); - root.then(message("import-all", "Structure import rebuilds vanilla & datapack structures as editable Iris resources through Bukkit/NMS template managers; run /iris structure import on a Bukkit server against this pack, then copy the pack folder over.")); - root.then(message("reimport", "Structure import rebuilds vanilla & datapack structures as editable Iris resources through Bukkit/NMS template managers; run /iris structure import on a Bukkit server against this pack, then copy the pack folder over.")); - root.then(message("imp", "Structure import rebuilds vanilla & datapack structures as editable Iris resources through Bukkit/NMS template managers; run /iris structure import on a Bukkit server against this pack, then copy the pack folder over.")); - root.then(message("all", "Structure import rebuilds vanilla & datapack structures as editable Iris resources through Bukkit/NMS template managers; run /iris structure import on a Bukkit server against this pack, then copy the pack folder over.")); - root.then(message("capture", "Structure capture generates each structure in a throwaway Bukkit scratch world to read its blocks; it requires the Bukkit plugin (v26 NMS binding).")); - root.then(message("cap", "Structure capture generates each structure in a throwaway Bukkit scratch world to read its blocks; it requires the Bukkit plugin (v26 NMS binding).")); - root.then(verifyTree("verify")); - root.then(verifyTree("locateall")); + root.then(message("import", IMPORT_EXPLANATION)); + root.then(message("import-all", IMPORT_EXPLANATION)); + root.then(message("reimport", IMPORT_EXPLANATION)); + root.then(message("imp", IMPORT_EXPLANATION)); + root.then(message("all", IMPORT_EXPLANATION)); + root.then(message("capture", CAPTURE_EXPLANATION)); + root.then(message("cap", CAPTURE_EXPLANATION)); + root.then(ModdedToolingTail.after(name)); return root; } - private static LiteralArgumentBuilder verifyTree(String name) { - return Commands.literal(name) - .executes((CommandContext context) -> IrisModdedCommands.verifyStructures(context.getSource(), null)) - .then(Commands.argument("key", StringArgumentType.greedyString()).suggests(ALL_STRUCTURE_KEYS) - .executes((CommandContext context) -> IrisModdedCommands.verifyStructures( - context.getSource(), StringArgumentType.getString(context, "key")))); - } - private static LiteralArgumentBuilder message(String name, String text) { return Commands.literal(name) .executes((CommandContext context) -> { @@ -103,68 +64,4 @@ public final class ModdedStructureCommands { return 0; })); } - - private static IrisData dataFor(CommandSourceStack source) { - Engine engine = IrisModdedCommands.engineFor(source.getLevel()); - if (engine == null) { - IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_THIS_DIMENSION_IS_NOT_GENERATED_BY_IRIS_RUN_THIS_FROM)); - return null; - } - return engine.getData(); - } - - private static int list(CommandSourceStack source) { - IrisData data = dataFor(source); - if (data == null) { - return 0; - } - File file = StructureIndexService.write(data); - IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_WROTE_STRUCTURE_INDEX, MessageArgument.untrusted("value", file.getPath()))); - return 1; - } - - private static int info(CommandSourceStack source, String keyRaw) { - IrisData data = dataFor(source); - if (data == null) { - return 0; - } - String key = keyRaw.trim(); - IrisStructure structure = StructureResources.structure(data.getPackResources(), key); - if (structure == null) { - IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_NO_IRIS_STRUCTURE_THIS_PACK, MessageArgument.untrusted("key", key))); - return 0; - } - StructureAssembler assembler = StructureAssemblies.forData( - data, structure, new IrisPosition(0, 64, 0)); - StructureAssemblyResult assembly = assembler.assemble(new RNG(1234)); - List pieces = assembly.pieces(); - if (!assembly.hasOutput()) { - IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_STRUCTURE_ASSEMBLED_0_PIECES_CHECK_STARTPOOL, MessageArgument.untrusted("key", key), MessageArgument.untrusted("value", structure.getStartPool()))); - return 0; - } - int minX = Integer.MAX_VALUE; - int minZ = Integer.MAX_VALUE; - int maxX = Integer.MIN_VALUE; - int maxZ = Integer.MIN_VALUE; - for (PlacedStructurePiece piece : pieces) { - minX = Math.min(minX, piece.getMinX()); - minZ = Math.min(minZ, piece.getMinZ()); - maxX = Math.max(maxX, piece.getMaxX()); - maxZ = Math.max(maxZ, piece.getMaxZ()); - } - IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STRUCTURE_COMMANDS_STRUCTURE_PIECES_FOOTPRINT_X_BLOCKS_SAMPLE_SEED_1234, MessageArgument.untrusted("key", key), MessageArgument.untrusted("value", pieces.size()), MessageArgument.untrusted("value2", (maxX - minX + 1)), MessageArgument.untrusted("value3", (maxZ - minZ + 1)))); - return 1; - } - - private static CompletableFuture suggestIrisStructureKeys(CommandContext context, SuggestionsBuilder builder) { - ModdedCommandFeedback.tab(context.getSource()); - try { - Engine engine = IrisModdedCommands.engineFor(context.getSource().getLevel()); - if (engine != null) { - return SharedSuggestionProvider.suggest(StructureResources.structureKeys(engine.getData().getPackResources()), builder); - } - } catch (Throwable ignored) { - } - return builder.buildFuture(); - } } diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingSender.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingSender.java new file mode 100644 index 000000000..b7ee7ca70 --- /dev/null +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingSender.java @@ -0,0 +1,91 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.modded.command; + +import art.arcane.iris.core.tooling.SenderWorld; +import art.arcane.iris.core.tooling.ServedPack; +import art.arcane.iris.core.tooling.ToolingSender; +import art.arcane.iris.engine.framework.Engine; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.network.chat.Component; + +import java.util.Optional; + +/** + * A modded source of a tooling command. It reads the world of the source when it is built, on the server thread that + * received the command, and delivers messages on the server thread. A modded platform has no studio. + */ +final class ModdedToolingSender implements ToolingSender { + private final CommandSourceStack source; + private final Optional world; + + ModdedToolingSender(CommandSourceStack source) { + this.source = source; + this.world = Optional.ofNullable(IrisModdedCommands.engineFor(source.getLevel())) + .filter(engine -> !engine.isClosed()) + .map(SenderWorld::of); + } + + @Override + public String name() { + return source.getTextName(); + } + + @Override + public void info(String message) { + onServerThread(() -> source.sendSuccess(() -> Component.literal(message), false)); + } + + @Override + public void success(String message) { + onServerThread(() -> ModdedCommandFeedback.ok(source, message)); + } + + @Override + public void error(String message) { + onServerThread(() -> ModdedCommandFeedback.fail(source, message)); + } + + @Override + public Optional extension(Class type) { + if (type.isInstance(source)) { + return Optional.of(type.cast(source)); + } + return Optional.ofNullable(source.getEntity()).filter(type::isInstance).map(type::cast); + } + + @Override + public boolean isOperator() { + return ModdedCommandTree.GATE.test(source); + } + + @Override + public Optional world() { + return world; + } + + @Override + public Optional openStudioPack() { + return Optional.empty(); + } + + private void onServerThread(Runnable delivery) { + source.getServer().execute(delivery); + } +} diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingTail.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingTail.java new file mode 100644 index 000000000..4c7f7c5b8 --- /dev/null +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedToolingTail.java @@ -0,0 +1,73 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.modded.command; + +import art.arcane.iris.core.tooling.ToolingCommands; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.RequiredArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +/** + * The tail of a command node that hands the rest of the line to the commands modules register + * ({@link ToolingCommands}). It is a greedy string next to the node's literals, and Brigadier takes a literal that matches + * before any argument, so a literal command always wins over a module's. + */ +final class ModdedToolingTail { + private static final String ARGUMENT_NAME = "tooling"; + private static final int COMMAND_ACCEPTED = 1; + private static final ToolingCommands TOOLING = ToolingCommands.forBoundPlatform(); + + private ModdedToolingTail() { + } + + /** A tail for the node reached after {@code leadingWords}, which the dispatcher puts before the words the sender types. */ + static RequiredArgumentBuilder after(String... leadingWords) { + List leading = List.of(leadingWords); + return Commands.argument(ARGUMENT_NAME, StringArgumentType.greedyString()) + .suggests((CommandContext context, SuggestionsBuilder builder) -> suggest(context.getSource(), leading, builder)) + .executes((CommandContext context) -> run( + context.getSource(), leading, StringArgumentType.getString(context, ARGUMENT_NAME))); + } + + private static int run(CommandSourceStack source, List leading, String typed) { + List words = new ArrayList<>(leading); + words.addAll(Arrays.stream(typed.trim().split("\\s+")).filter(word -> !word.isEmpty()).toList()); + TOOLING.executeOffThread(new ModdedToolingSender(source), words); + return COMMAND_ACCEPTED; + } + + private static CompletableFuture suggest(CommandSourceStack source, List leading, SuggestionsBuilder builder) { + ModdedCommandFeedback.tab(source); + String typed = builder.getRemaining(); + List words = new ArrayList<>(leading); + words.addAll(Arrays.asList(typed.split(" ", -1))); + SuggestionsBuilder lastWord = builder.createOffset(builder.getStart() + typed.lastIndexOf(' ') + 1); + TOOLING.complete(new ModdedToolingSender(source), words).forEach(lastWord::suggest); + return lastWord.buildFuture(); + } +} diff --git a/adapters/modded-common/src/test/java/art/arcane/iris/modded/command/IrisModdedStructureCommandTest.java b/adapters/modded-common/src/test/java/art/arcane/iris/modded/command/IrisModdedStructureCommandTest.java index c9311a519..9aa3f054e 100644 --- a/adapters/modded-common/src/test/java/art/arcane/iris/modded/command/IrisModdedStructureCommandTest.java +++ b/adapters/modded-common/src/test/java/art/arcane/iris/modded/command/IrisModdedStructureCommandTest.java @@ -280,28 +280,14 @@ public class IrisModdedStructureCommandTest { } @Test - public void verifyResolvesRegisteredNativeBeforeGenericIrisAliases() throws IOException { - String source = source("ModdedLocateCommands.java"); - int methodStart = source.indexOf("private static int verifyStructure("); - int methodEnd = source.indexOf("private static Optional resolveNativeStructure(", - methodStart); - String method = source.substring(methodStart, methodEnd); - int nativeResolution = method.indexOf("resolveNativeStructure(source, level, engine, key)"); - int genericIrisLookup = method.indexOf("ModuleServices.placesStructure(engine, key)", nativeResolution); - - assertTrue(nativeResolution >= 0); - assertTrue(genericIrisLookup > nativeResolution); - assertTrue(method.contains("NativeStructureAvailability.IRIS_SUPPRESSED")); - } - - @Test - public void structureVerificationNoLongerClaimsNativeGenerationIsMissing() throws IOException { + public void structureListInfoAndVerifyBelongToTheStructureModule() throws IOException { String source = source("ModdedStructureCommands.java"); + String tree = source("ModdedCommandTree.java"); - assertTrue(source.contains("verifyTree(\"verify\")")); - assertTrue(source.contains("verifyTree(\"locateall\")")); - assertTrue(source.contains("IrisModdedCommands.verifyStructures(")); - assertFalse(source.contains("Vanilla structure locate is meaningless here")); + 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 {