mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Autocomplete more command parameters
- Suggest pack folders for pack validate, cleanup, restore, status and compat - Suggest preview and apply for pack restore mode - Suggest versions and installed datapack ids for datapack export and remove - Suggest structure keys for structure info, place, jigsaw convert and adopt inspect - Suggest workcell ids for jigsaw save and goto - Suggest formats for jigsaw export - Suggest subterrain families, marker keys and world slots
This commit is contained in:
1 parent
cdb4e68708
commit
a1bf501c30
19 files changed
+239
-25
No files matched your search
@@ -18,6 +18,8 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.ExportVersionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.InstalledDatapackHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.command.handlers.DimensionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.ExportFormatHandler;
|
||||
@@ -94,7 +96,7 @@ public class CommandDatapack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Remove an installed datapack by id (also delete its URL from datapackImports to keep it gone)", descriptionKey = "iris.director.commanddatapack.director.remove_installed_datapack_by_id_also_delete_its_url_from_datapackimports_keep", aliases = {"rm"})
|
||||
public void remove(
|
||||
@Param(description = "The datapack id (folder name) shown by /iris datapack list", descriptionKey = "iris.director.commanddatapack.param.datapack_id_folder_name_shown_by_iris_datapack_list")
|
||||
@Param(description = "The datapack id (folder name) shown by /iris datapack list", descriptionKey = "iris.director.commanddatapack.param.datapack_id_folder_name_shown_by_iris_datapack_list", customHandler = InstalledDatapackHandler.class)
|
||||
String id
|
||||
) {
|
||||
DatapackIngestService.remove(sender(), id);
|
||||
@@ -104,7 +106,7 @@ public class CommandDatapack implements DirectorExecutor {
|
||||
public void export(
|
||||
@Param(name = "dimension", description = "The dimension to export", descriptionKey = "iris.director.commanddatapack.param.export_dimension", customHandler = DimensionHandler.class)
|
||||
IrisDimension dimension,
|
||||
@Param(name = "version", description = "Target Minecraft version, 26.3 or later (blank uses the latest)", descriptionKey = "iris.director.commanddatapack.param.export_version", defaultValue = "")
|
||||
@Param(name = "version", description = "Target Minecraft version, 26.3 or later (blank uses the latest)", descriptionKey = "iris.director.commanddatapack.param.export_version", defaultValue = "", customHandler = ExportVersionHandler.class)
|
||||
String version,
|
||||
@Param(name = "mode", description = "Output mode: preset, dimension, or overworld", descriptionKey = "iris.director.commanddatapack.param.export_mode", defaultValue = WorldgenExportRequest.DEFAULT_MODE, customHandler = ExportModeHandler.class)
|
||||
String mode,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.SubterrainFeatureHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
@@ -93,7 +94,7 @@ public class CommandFind implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Find an authored underground feature by id or geometry family", sync = true)
|
||||
public void subterrain(
|
||||
@Param(description = "Feature definition id or family: tectonic_fault, cenote, lava_tube, travertine_terraces")
|
||||
@Param(description = "Feature definition id or family: tectonic_fault, cenote, lava_tube, travertine_terraces", customHandler = SubterrainFeatureHandler.class)
|
||||
String feature,
|
||||
@Param(description = "Search radius in blocks", defaultValue = "8192")
|
||||
int radius,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.OpenSuggestionHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.IrisRuntime;
|
||||
import art.arcane.iris.world.BukkitWorldReconciler;
|
||||
@@ -61,6 +62,7 @@ import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -200,7 +202,8 @@ public class CommandIris implements DirectorExecutor {
|
||||
name = "target",
|
||||
aliases = "world-name",
|
||||
description = "The exact existing world slot to replace",
|
||||
descriptionKey = "iris.director.commandiris.param.replace_exact_existing_world_slot_next_restart"
|
||||
descriptionKey = "iris.director.commandiris.param.replace_exact_existing_world_slot_next_restart",
|
||||
customHandler = WorldSlotHandler.class
|
||||
)
|
||||
String target,
|
||||
@Param(
|
||||
@@ -721,6 +724,13 @@ public class CommandIris implements DirectorExecutor {
|
||||
).isPresent();
|
||||
}
|
||||
|
||||
public static final class WorldSlotHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return Bukkit.getWorlds().stream().map(world -> world.getKey().toString()).toList();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ManagedWorldNameHandler implements DirectorParameterHandler<String> {
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.OpenSuggestionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.RegisteredStructureKeyHandler;
|
||||
import art.arcane.iris.command.specialhandlers.ExportFormatHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.studio.object.StudioOpenCoordinator;
|
||||
@@ -52,7 +55,10 @@ import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -145,7 +151,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
aliases = {"import", "import-vanilla"}, sync = true, origin = DirectorOrigin.PLAYER)
|
||||
public void convert(
|
||||
@Param(description = "Pack dimension") IrisDimension dimension,
|
||||
@Param(description = "Registered structure key such as minecraft:village_plains") String source,
|
||||
@Param(description = "Registered structure key such as minecraft:village_plains", customHandler = RegisteredStructureKeyHandler.class) String source,
|
||||
@Param(description = "New Iris structure key, or auto", defaultValue = "auto") String target,
|
||||
@Param(description = "Studio world seed", defaultValue = "1337") long seed
|
||||
) {
|
||||
@@ -366,7 +372,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
@Director(description = "Flush the automatic save for a workcell now", sync = true,
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void save(
|
||||
@Param(description = "Workcell ID or selected", defaultValue = "selected") String bay
|
||||
@Param(description = "Workcell ID or selected", defaultValue = "selected", customHandler = JigsawWorkcellOrSelectedHandler.class) String bay
|
||||
) {
|
||||
ActiveContext context = requireActive();
|
||||
if (context == null) {
|
||||
@@ -387,7 +393,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
@Director(name = "goto", aliases = "teleport", description = "Select and teleport to a Studio workcell",
|
||||
sync = true, origin = DirectorOrigin.PLAYER)
|
||||
public void gotoBay(
|
||||
@Param(description = "Workcell ID") String bay
|
||||
@Param(description = "Workcell ID", customHandler = JigsawWorkcellHandler.class) String bay
|
||||
) {
|
||||
if (requireActive() != null) {
|
||||
JigsawStudioService.get().teleportTo(player(), bay);
|
||||
@@ -410,7 +416,7 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
@Param(description = "Datapack namespace", defaultValue = "iris") String namespace,
|
||||
@Param(description = "Output name under the Studio exports folder", defaultValue = "jigsaw-export")
|
||||
String output,
|
||||
@Param(description = "directory or zip", defaultValue = "zip") String format,
|
||||
@Param(description = "directory or zip", defaultValue = "zip", customHandler = ExportFormatHandler.class) String format,
|
||||
@Param(description = "Replace an existing export", defaultValue = "false") boolean replace
|
||||
) {
|
||||
ActiveContext context = requireActive();
|
||||
@@ -815,4 +821,27 @@ public class CommandJigsaw implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
public static class JigsawWorkcellHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
ActiveContext context = active(player());
|
||||
if (context == null) {
|
||||
return List.of();
|
||||
}
|
||||
return context.session().layout().bays().stream().map(JigsawStudioBay::stableId).toList();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class JigsawWorkcellOrSelectedHandler extends JigsawWorkcellHandler {
|
||||
private static final String SELECTED_WORKCELL = "selected";
|
||||
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
List<String> options = new ArrayList<>();
|
||||
options.add(SELECTED_WORKCELL);
|
||||
options.addAll(super.suggestions());
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.IrisStructureHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.authoring.StructureKey;
|
||||
@@ -45,7 +46,7 @@ public class CommandJigsawAdopt implements DirectorExecutor {
|
||||
origin = DirectorOrigin.PLAYER)
|
||||
public void inspect(
|
||||
@Param(description = "Pack dimension") IrisDimension dimension,
|
||||
@Param(description = "Existing Iris structure key") String source,
|
||||
@Param(description = "Existing Iris structure key", customHandler = IrisStructureHandler.class) String source,
|
||||
@Param(description = "New owned Iris key, or auto", defaultValue = "auto") String target,
|
||||
@Param(description = "auto, in-place, or clone", defaultValue = "auto",
|
||||
customHandler = JigsawAdoptionStrategyHandler.class) String strategy
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.PackFolderOrAllHandler;
|
||||
import art.arcane.iris.command.specialhandlers.PackFolderHandler;
|
||||
import art.arcane.iris.pack.PackFingerprints;
|
||||
|
||||
import art.arcane.iris.Iris;
|
||||
@@ -35,7 +37,7 @@ import art.arcane.iris.localization.C;
|
||||
import art.arcane.iris.localization.ChatReport;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.command.handlers.DimensionHandler;
|
||||
import art.arcane.iris.command.specialhandlers.CleanupModeHandler;
|
||||
import art.arcane.iris.command.specialhandlers.PreviewApplyModeHandler;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
@@ -108,7 +110,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Validate a pack (or all packs) and re-publish results", descriptionKey = "iris.director.commandpack.director.validate_pack_all_packs_re_publish_results", aliases = {"v"})
|
||||
public void validate(
|
||||
@Param(description = "The pack folder name to validate, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_validate_leave_empty_all", defaultValue = "*")
|
||||
@Param(description = "The pack folder name to validate, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_validate_leave_empty_all", defaultValue = "*", customHandler = PackFolderOrAllHandler.class)
|
||||
String pack
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -161,9 +163,9 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Preview or apply unused-resource cleanup", descriptionKey = "iris.director.commandpack.director.preview_apply_unused_resource_cleanup", aliases = {"c"})
|
||||
public void cleanup(
|
||||
@Param(description = "The pack folder name to clean", descriptionKey = "iris.director.commandpack.param.pack_folder_name_clean")
|
||||
@Param(description = "The pack folder name to clean", descriptionKey = "iris.director.commandpack.param.pack_folder_name_clean", customHandler = PackFolderHandler.class)
|
||||
String pack,
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply", defaultValue = "preview", customHandler = CleanupModeHandler.class)
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply", defaultValue = "preview", customHandler = PreviewApplyModeHandler.class)
|
||||
String mode
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -211,9 +213,9 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Preview or apply restoration of the latest quarantine", descriptionKey = "iris.director.commandpack.director.preview_apply_restoration_latest_quarantine", aliases = {"r"})
|
||||
public void restore(
|
||||
@Param(description = "The pack folder name to restore", descriptionKey = "iris.director.commandpack.param.pack_folder_name_restore")
|
||||
@Param(description = "The pack folder name to restore", descriptionKey = "iris.director.commandpack.param.pack_folder_name_restore", customHandler = PackFolderHandler.class)
|
||||
String pack,
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply_2", defaultValue = "preview")
|
||||
@Param(description = "preview or apply", descriptionKey = "iris.director.commandpack.param.preview_apply_2", defaultValue = "preview", customHandler = PreviewApplyModeHandler.class)
|
||||
String mode
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -271,7 +273,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Show cached validation status for a pack", descriptionKey = "iris.director.commandpack.director.show_cached_validation_status_pack", aliases = {"s"})
|
||||
public void status(
|
||||
@Param(description = "The pack folder name, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name", defaultValue = "*")
|
||||
@Param(description = "The pack folder name, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name", defaultValue = "*", customHandler = PackFolderOrAllHandler.class)
|
||||
String pack
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
@@ -299,7 +301,7 @@ public class CommandPack implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Show pack content that cannot generate on this Minecraft version", descriptionKey = "iris.director.commandpack.director.show_content_cannot_generate_this_minecraft_version", aliases = {"cp"})
|
||||
public void compat(
|
||||
@Param(description = "The pack folder name to report on, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_compat", defaultValue = "*")
|
||||
@Param(description = "The pack folder name to report on, or * for every pack", descriptionKey = "iris.director.commandpack.param.pack_folder_name_compat", defaultValue = "*", customHandler = PackFolderOrAllHandler.class)
|
||||
String pack
|
||||
) {
|
||||
VolmitSender s = sender();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.IrisStructureHandler;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.BulkStructureImporter;
|
||||
@@ -326,7 +327,7 @@ public class CommandStructure implements DirectorExecutor {
|
||||
public void info(
|
||||
@Param(description = "The dimension whose pack holds the structure", descriptionKey = "iris.director.commandstructure.param.dimension_whose_pack_holds_structure", aliases = "dim")
|
||||
IrisDimension dimension,
|
||||
@Param(description = "The iris structure key to inspect", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_inspect")
|
||||
@Param(description = "The iris structure key to inspect", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_inspect", customHandler = IrisStructureHandler.class)
|
||||
String structure
|
||||
) {
|
||||
IrisData data = dimension.getLoader();
|
||||
@@ -364,7 +365,7 @@ public class CommandStructure implements DirectorExecutor {
|
||||
public void place(
|
||||
@Param(description = "The dimension whose pack holds the structure", descriptionKey = "iris.director.commandstructure.param.dimension_whose_pack_holds_structure_2", aliases = "dim")
|
||||
IrisDimension dimension,
|
||||
@Param(description = "The iris structure key to place", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_place")
|
||||
@Param(description = "The iris structure key to place", descriptionKey = "iris.director.commandstructure.param.iris_structure_key_place", customHandler = IrisStructureHandler.class)
|
||||
String structure
|
||||
) {
|
||||
IrisData data = dimension.getLoader();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.command.specialhandlers.MarkerHandler;
|
||||
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
|
||||
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
@@ -203,7 +204,7 @@ public class CommandWhat implements DirectorExecutor {
|
||||
private static final int MARKER_SIGNAL_BATCH = 128;
|
||||
|
||||
@Director(description = "Show markers in chunk", descriptionKey = "iris.director.commandwhat.director.show_markers_chunk", origin = DirectorOrigin.PLAYER)
|
||||
public void markers(@Param(description = "Marker name such as cave_floor or cave_ceiling", descriptionKey = "iris.director.commandwhat.param.marker_name_such_as_cave_floor_cave_ceiling") String marker) {
|
||||
public void markers(@Param(description = "Marker name such as cave_floor or cave_ceiling", descriptionKey = "iris.director.commandwhat.param.marker_name_such_as_cave_floor_cave_ceiling", customHandler = MarkerHandler.class) String marker) {
|
||||
VolmitSender commandSender = sender();
|
||||
Player player = player();
|
||||
if (player == null) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.datapack.DataVersion;
|
||||
import art.arcane.iris.pack.datapack.export.WorldgenExportTargets;
|
||||
|
||||
public final class ExportVersionHandler extends FixedChoiceHandler {
|
||||
public ExportVersionHandler() {
|
||||
super(WorldgenExportTargets.SUPPORTED.stream().map(DataVersion::getVersion).toArray(String[]::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String canonicalize(String input) {
|
||||
if (input == null || input.isBlank()) {
|
||||
return "";
|
||||
}
|
||||
return WorldgenExportTargets.resolve(input).getVersion();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.datapack.DatapackIngestService;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class InstalledDatapackHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return DatapackIngestService.installed().stream().map(entry -> entry.id).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public final class MarkerHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
Engine activeEngine = engine();
|
||||
if (activeEngine == null || activeEngine.getData() == null) {
|
||||
return List.of();
|
||||
}
|
||||
return Arrays.stream(activeEngine.getData().getMarkerLoader().getPossibleKeys()).sorted().toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.command.DirectorParameterHandler;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class OpenSuggestionHandler implements DirectorParameterHandler<String> {
|
||||
protected abstract Collection<String> suggestions();
|
||||
|
||||
@Override
|
||||
public KList<String> getPossibilities() {
|
||||
return new KList<>(suggestions());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parse(String input, boolean force) {
|
||||
return input == null ? "" : input.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type == String.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.pack.PackDirectoryResolver;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
public class PackFolderHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return PackDirectoryResolver.listVisiblePackDirectories(IrisPlatforms.get().packsFolder())
|
||||
.stream()
|
||||
.map(File::getName)
|
||||
.sorted()
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public final class PackFolderOrAllHandler extends PackFolderHandler {
|
||||
private static final String ALL_PACKS = "*";
|
||||
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
List<String> options = new ArrayList<>();
|
||||
options.add(ALL_PACKS);
|
||||
options.addAll(super.suggestions());
|
||||
return options;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,8 +2,8 @@ package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public final class CleanupModeHandler extends FixedChoiceHandler {
|
||||
public CleanupModeHandler() {
|
||||
public final class PreviewApplyModeHandler extends FixedChoiceHandler {
|
||||
public PreviewApplyModeHandler() {
|
||||
super("preview", "apply");
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public final class CleanupModeHandler extends FixedChoiceHandler {
|
||||
protected String canonicalize(String input) {
|
||||
String mode = input.trim().toLowerCase(Locale.ROOT);
|
||||
if (!mode.equals("preview") && !mode.equals("apply")) {
|
||||
throw new IllegalArgumentException("Cleanup mode must be preview or apply.");
|
||||
throw new IllegalArgumentException("Mode must be preview or apply.");
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class RegisteredStructureKeyHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return IrisPlatforms.get().structureHooks().structureKeys().stream().sorted().toList();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import art.arcane.iris.generation.subterrain.IrisSubterrainFamily;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class SubterrainFeatureHandler extends OpenSuggestionHandler {
|
||||
@Override
|
||||
protected Collection<String> suggestions() {
|
||||
return Arrays.stream(IrisSubterrainFamily.values())
|
||||
.map(family -> family.name().toLowerCase(Locale.ROOT))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -26,10 +26,19 @@ public class FixedChoiceHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanupModeSuggestsAndRejectsUnknownModes() throws Exception {
|
||||
CleanupModeHandler handler = new CleanupModeHandler();
|
||||
public void previewApplyModeSuggestsAndRejectsUnknownModes() throws Exception {
|
||||
PreviewApplyModeHandler handler = new PreviewApplyModeHandler();
|
||||
assertEquals(List.of("preview", "apply"), handler.getPossibilities());
|
||||
assertEquals("apply", handler.parse("Apply", false));
|
||||
assertThrows(DirectorParsingException.class, () -> handler.parse("delete", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exportVersionKeepsBlankAsLatestAndRejectsOlderTargets() throws Exception {
|
||||
ExportVersionHandler handler = new ExportVersionHandler();
|
||||
assertEquals(List.of("26.3"), handler.getPossibilities());
|
||||
assertEquals("", handler.parse("", false));
|
||||
assertEquals("26.3", handler.parse("26.3.0", false));
|
||||
assertThrows(DirectorParsingException.class, () -> handler.parse("26.2", false));
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package art.arcane.iris.command.specialhandlers;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class OpenSuggestionHandlerTest {
|
||||
@Test
|
||||
public void subterrainSuggestsFamiliesButAcceptsFeatureIds() {
|
||||
SubterrainFeatureHandler handler = new SubterrainFeatureHandler();
|
||||
assertEquals(List.of("tectonic_fault", "cenote", "lava_tube", "travertine_terraces"), handler.getPossibilities());
|
||||
assertEquals("my_feature:room", handler.parse(" my_feature:room ", false));
|
||||
assertEquals("", handler.parse(null, false));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user