mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
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:
1 parent
88fe8c8bcd
commit
f7aaed79a6
33 files changed
+230
-102
No files matched your search
+1
-1
@@ -52,7 +52,7 @@ public class CommandStructure implements DirectorExecutor {
|
||||
int imported = jigsaws.imported() + templates.imported() + groups.imported() + captured.imported();
|
||||
int failed = jigsaws.failed() + templates.failed() + groups.failed() + captured.failed();
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_IMPORT_COMPLETE_STRUCTURES_OBJECTS_WRITTEN_FAILED, MessageArgument.untrusted("imported", imported), MessageArgument.untrusted("failed", failed)));
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_REFERENCE_THEM_FROM_BIOME_REGION_DIMENSION_STRUCTURES_LIST_RUN_IRIS, MessageArgument.untrusted("value", dimension.getLoadKey())));
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STRUCTURE_REFERENCE_THEM_FROM_BIOME_REGION_DIMENSION_STRUCTURES_LIST_RUN_IRIS));
|
||||
}
|
||||
|
||||
@Director(name = "capture", description = "Capture live registered structures into editable Iris objects by generating each one in a throwaway scratch world and reading back its blocks. This standalone command overwrites its owned outputs; structures wider/taller than the capture cap and anything that will not generate in a flat overworld are skipped. Each captured structure becomes a single-piece Iris structure you can place from a biome/region/dimension 'structures' list. /iris structure import runs a restricted final capture pass only for non-jigsaw structures that have no loadable NBT template.", descriptionKey = "iris.director.commandstructure.director.capture_code_generated_structures_that_have_no_nbt_template_swamp_huts_igloos", aliases = {"cap"}, origin = DirectorOrigin.BOTH)
|
||||
|
||||
@@ -59,6 +59,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -183,7 +184,7 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
}
|
||||
|
||||
private void denyUnlessOpenToEveryone(CommandSender sender, ToolingSender toolingSender, String[] args) {
|
||||
if (tooling.executeIfOpenToEveryone(toolingSender, Arrays.asList(args))) {
|
||||
if (isModuleBranch(args) && tooling.executeIfOpenToEveryone(toolingSender, wordsAfterBranch(args))) {
|
||||
return;
|
||||
}
|
||||
ComponentMessenger.sendSection(sender, IrisLanguage.text(
|
||||
@@ -192,19 +193,33 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
));
|
||||
}
|
||||
|
||||
private static boolean isModuleBranch(String[] args) {
|
||||
return args.length > 0 && ToolingCommands.isBranchWord(args[0]);
|
||||
}
|
||||
|
||||
private static List<String> wordsAfterBranch(String[] args) {
|
||||
return Arrays.asList(args).subList(1, args.length);
|
||||
}
|
||||
|
||||
public List<String> tabCompleteRoot(CommandSender sender, String alias, String[] args) {
|
||||
List<String> suggestions = new ArrayList<>(runDirectorTab(sender, alias, args));
|
||||
for (String toolingSuggestion : tooling.complete(new BukkitToolingSender(sender), Arrays.asList(args))) {
|
||||
if (!suggestions.contains(toolingSuggestion)) {
|
||||
suggestions.add(toolingSuggestion);
|
||||
}
|
||||
}
|
||||
List<String> suggestions = isModuleBranch(args) && args.length > 1
|
||||
? tooling.complete(new BukkitToolingSender(sender), wordsAfterBranch(args))
|
||||
: directorSuggestionsWithModuleBranch(sender, alias, args);
|
||||
if (sender instanceof Player player && IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 0.25f, RNG.r.f(0.125f, 1.95f));
|
||||
}
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
private List<String> directorSuggestionsWithModuleBranch(CommandSender sender, String alias, String[] args) {
|
||||
List<String> suggestions = new ArrayList<>(runDirectorTab(sender, alias, args));
|
||||
boolean typingFirstWord = args.length == 1;
|
||||
if (typingFirstWord && ToolingCommands.BRANCH.startsWith(args[0].toLowerCase(Locale.ROOT))) {
|
||||
suggestions.add(ToolingCommands.BRANCH);
|
||||
}
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
private PluginCommand findBukkitCommand() {
|
||||
try {
|
||||
return Iris.instance.getCommand(ROOT_COMMAND);
|
||||
@@ -233,6 +248,12 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
}
|
||||
|
||||
private void executeCommand(CommandSender sender, ToolingSender toolingSender, String label, String[] args) {
|
||||
if (isModuleBranch(args)) {
|
||||
tooling.execute(toolingSender, wordsAfterBranch(args));
|
||||
playSuccessSound(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sendHelpIfRequested(sender, args)) {
|
||||
playSuccessSound(sender);
|
||||
return;
|
||||
@@ -245,11 +266,6 @@ public class CommandSVC implements IrisService, CommandExecutor, TabCompleter, D
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.isHandled() && tooling.execute(toolingSender, Arrays.asList(args))) {
|
||||
playSuccessSound(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
playFailureSound(sender);
|
||||
if (result.getMessage() == null || result.getMessage().trim().isEmpty()) {
|
||||
new VolmitSender(sender).sendMessage(C.RED + IrisLanguage.text(IrisMessages.COMMAND_UNKNOWN));
|
||||
|
||||
Reference in new issue
Block a user