diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandDeveloper.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandDeveloper.java index 86e7a7669..36b5e9ffe 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandDeveloper.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandDeveloper.java @@ -94,7 +94,7 @@ public class CommandDeveloper implements DirectorExecutor { @Director(description = "Hash generated block output of a fixed area for determinism/identity testing", descriptionKey = "iris.director.commanddeveloper.director.hash_generated_block_output_fixed_area_determinism_identity_testing", origin = DirectorOrigin.BOTH) public void genhash( - @Param(description = "The world to hash", descriptionKey = "iris.director.commanddeveloper.param.world_hash", contextual = true) + @Param(description = "The world to hash", descriptionKey = "iris.director.commanddeveloper.param.world_hash", contextual = true, contextualOverride = true) World world, @Param(description = "Radius in chunks around the center", descriptionKey = "iris.director.commanddeveloper.param.radius_chunks_around_center", defaultValue = "4") int radius, @@ -192,9 +192,9 @@ public class CommandDeveloper implements DirectorExecutor { @Director(description = "Update the pack of a world (UNSAFE!)", descriptionKey = "iris.director.commanddeveloper.director.update_pack_world_unsafe", name = "update-world", aliases = "^world") public void updateWorld( - @Param(description = "The world to update", descriptionKey = "iris.director.commanddeveloper.param.world_update", contextual = true) + @Param(description = "The world to update", descriptionKey = "iris.director.commanddeveloper.param.world_update", contextual = true, contextualOverride = true) World world, - @Param(description = "The pack to install into the world", descriptionKey = "iris.director.commanddeveloper.param.pack_install_into_world", contextual = true, aliases = "dimension") + @Param(description = "The pack to install into the world", descriptionKey = "iris.director.commanddeveloper.param.pack_install_into_world", contextual = true, contextualOverride = true, aliases = "dimension") IrisDimension pack, @Param(description = "Make sure to make a backup & read the warnings first!", descriptionKey = "iris.director.commanddeveloper.param.make_sure_make_backup_read_warnings_first", defaultValue = "false", aliases = "c") boolean confirm @@ -390,7 +390,7 @@ public class CommandDeveloper implements DirectorExecutor { @Director(name = "goldenhash", aliases = {"gold"}, description = "Generate chunks into buffers (no world writes) and hash blocks+biomes; captures a golden file or verifies against an existing one. Deletes the world's entire mantle - use on disposable test worlds.", descriptionKey = "iris.director.commanddeveloper.director.generate_chunks_into_buffers_no_world_writes_hash_blocks_biomes_captures_golden", origin = DirectorOrigin.BOTH) public void goldenhash( - @Param(description = "The world to scan", descriptionKey = "iris.director.commanddeveloper.param.world_scan", contextual = true) + @Param(description = "The world to scan", descriptionKey = "iris.director.commanddeveloper.param.world_scan", contextual = true, contextualOverride = true) World world, @Param(name = "radius", description = "Radius in chunks around the center", descriptionKey = "iris.director.commanddeveloper.param.radius_chunks_around_center_2", defaultValue = "8") int radius, diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandIris.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandIris.java index 9452c571c..d3107721c 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandIris.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandIris.java @@ -862,10 +862,12 @@ public class CommandIris implements DirectorExecutor { public static class PackDimensionTypeHandler implements DirectorParameterHandler { @Override public KList getPossibilities() { - Set options = new LinkedHashSet<>(); - options.add("default"); + return packDimensionOptions(Iris.instance.getDataFolder("packs")); + } + + static KList packDimensionOptions(File packsFolder) { + Set options = new LinkedHashSet<>(); - File packsFolder = Iris.instance.getDataFolder("packs"); for (File pack : PackDirectoryResolver.listVisiblePackDirectories(packsFolder)) { options.add(pack.getName()); diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandObject.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandObject.java index 47eb8ab0b..f564659d7 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandObject.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandObject.java @@ -610,7 +610,7 @@ public class CommandObject implements DirectorExecutor { @Director(description = "Save an object", descriptionKey = "iris.director.commandobject.director.save_object") public void save( - @Param(description = "The dimension to store the object in", descriptionKey = "iris.director.commandobject.param.dimension_store_object", contextual = true) + @Param(description = "The dimension to store the object in", descriptionKey = "iris.director.commandobject.param.dimension_store_object", contextual = true, contextualOverride = true) IrisDimension dimension, @Param(description = "The file to store it in, can use / for subfolders", descriptionKey = "iris.director.commandobject.param.file_store_it_can_use_subfolders") String name, diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandPregen.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandPregen.java index 96b642f17..51e0a654e 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandPregen.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandPregen.java @@ -42,7 +42,7 @@ public class CommandPregen implements DirectorExecutor { public void start( @Param(description = "The radius of the pregen in blocks", descriptionKey = "iris.director.commandpregen.param.radius_pregen_blocks", aliases = "size") int radius, - @Param(description = "The world to pregen", descriptionKey = "iris.director.commandpregen.param.world_pregen", contextual = true) + @Param(description = "The world to pregen", descriptionKey = "iris.director.commandpregen.param.world_pregen", contextual = true, contextualOverride = true) World world, @Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", descriptionKey = "iris.director.commandpregen.param.center_location_pregen_use_me_your_current_location", defaultValue = "0,0") Vector center, diff --git a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStudio.java b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStudio.java index 56ccdc9e0..560bc9131 100644 --- a/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStudio.java +++ b/adapters/bukkit/plugin/src/main/java/art/arcane/iris/core/commands/CommandStudio.java @@ -237,6 +237,7 @@ public class CommandStudio implements DirectorExecutor { description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.", descriptionKey = "iris.director.commandstudio.param.copy_contents_existing_project_your_packs_folder_use_it_as_template_this", defaultValue = "null", contextual = true, + contextualOverride = true, customHandler = NullableDimensionHandler.class ) IrisDimension template) { @@ -249,7 +250,7 @@ public class CommandStudio implements DirectorExecutor { @Director(description = "Get the version of a pack", descriptionKey = "iris.director.commandstudio.director.get_version_pack") public void version( - @Param(defaultValue = "default", description = "The dimension get the version of", descriptionKey = "iris.director.commandstudio.param.dimension_get_version", aliases = "dim", contextual = true, customHandler = DimensionHandler.class) + @Param(defaultValue = "default", description = "The dimension get the version of", descriptionKey = "iris.director.commandstudio.param.dimension_get_version", aliases = "dim", contextual = true, contextualOverride = true, customHandler = DimensionHandler.class) IrisDimension dimension ) { sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_PACK_HAS_VERSION, MessageArgument.untrusted("value", dimension.getName()), MessageArgument.untrusted("value2", dimension.getVersion()))); @@ -257,7 +258,7 @@ public class CommandStudio implements DirectorExecutor { @Director(description = "Open the noise explorer (External GUI)", descriptionKey = "iris.director.commandstudio.director.open_noise_explorer_external_gui", aliases = {"nmap"}) public void noise( - @Param(description = "Optional pack generator to preview", descriptionKey = "iris.director.commandstudio.param.optional_pack_generator_preview", defaultValue = "null", contextual = true) + @Param(description = "Optional pack generator to preview", descriptionKey = "iris.director.commandstudio.param.optional_pack_generator_preview", defaultValue = "null", contextual = true, contextualOverride = true) IrisGenerator generator, @Param(description = "The seed to preview the generator with", descriptionKey = "iris.director.commandstudio.param.seed_preview_generator_with", defaultValue = "12345") long seed @@ -414,7 +415,7 @@ public class CommandStudio implements DirectorExecutor { @Director(description = "Render a world map (External GUI)", descriptionKey = "iris.director.commandstudio.director.render_world_map_external_gui", aliases = "render") public void map( - @Param(name = "world", description = "The world to open the generator for", descriptionKey = "iris.director.commandstudio.param.world_open_generator", contextual = true) + @Param(name = "world", description = "The world to open the generator for", descriptionKey = "iris.director.commandstudio.param.world_open_generator", contextual = true, contextualOverride = true) World world ) { if (noGUI()) return; @@ -430,7 +431,7 @@ public class CommandStudio implements DirectorExecutor { @Director(description = "Package a dimension into a compressed format", descriptionKey = "iris.director.commandstudio.director.package_dimension_into_compressed_format", aliases = "package") public void pkg( - @Param(name = "dimension", description = "The dimension pack to compress", descriptionKey = "iris.director.commandstudio.param.dimension_pack_compress", contextual = true, defaultValue = "default", customHandler = DimensionHandler.class) + @Param(name = "dimension", description = "The dimension pack to compress", descriptionKey = "iris.director.commandstudio.param.dimension_pack_compress", contextual = true, contextualOverride = true, defaultValue = "default", customHandler = DimensionHandler.class) IrisDimension dimension, @Param(name = "obfuscate", description = "Whether or not to obfuscate the pack", descriptionKey = "iris.director.commandstudio.param.whether_not_obfuscate_pack", defaultValue = "false") boolean obfuscate, @@ -442,7 +443,7 @@ public class CommandStudio implements DirectorExecutor { @Director(description = "Profiles the performance of a dimension", descriptionKey = "iris.director.commandstudio.director.profiles_performance_dimension", origin = DirectorOrigin.PLAYER) public void profile( - @Param(description = "The dimension to profile", descriptionKey = "iris.director.commandstudio.param.dimension_profile", contextual = true, defaultValue = "default", customHandler = DimensionHandler.class) + @Param(description = "The dimension to profile", descriptionKey = "iris.director.commandstudio.param.dimension_profile", contextual = true, contextualOverride = true, defaultValue = "default", customHandler = DimensionHandler.class) IrisDimension dimension ) { // Todo: Make this more accurate @@ -659,7 +660,7 @@ public class CommandStudio implements DirectorExecutor { public void spawn( @Param(description = "The entity to spawn", descriptionKey = "iris.director.commandstudio.param.entity_spawn") IrisEntity entity, - @Param(description = "The location to spawn the entity at", descriptionKey = "iris.director.commandstudio.param.location_spawn_entity_at", contextual = true) + @Param(description = "The location to spawn the entity at", descriptionKey = "iris.director.commandstudio.param.location_spawn_entity_at", contextual = true, contextualOverride = true) Vector location ) { VolmitSender commandSender = sender(); @@ -701,7 +702,7 @@ public class CommandStudio implements DirectorExecutor { @Director(description = "Update your dimension projects VSCode workspace", descriptionKey = "iris.director.commandstudio.director.update_your_dimension_projects_vscode_workspace") public void update( - @Param(description = "The dimension to update the workspace of", descriptionKey = "iris.director.commandstudio.param.dimension_update_workspace", contextual = true, defaultValue = "default", customHandler = DimensionHandler.class) + @Param(description = "The dimension to update the workspace of", descriptionKey = "iris.director.commandstudio.param.dimension_update_workspace", contextual = true, contextualOverride = true, defaultValue = "default", customHandler = DimensionHandler.class) IrisDimension dimension ) { sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_UPDATING_CODE_WORKSPACE, MessageArgument.untrusted("value", dimension.getName()))); diff --git a/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/CommandIrisPackDimensionTypeHandlerTest.java b/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/CommandIrisPackDimensionTypeHandlerTest.java index 610330b9e..345328834 100644 --- a/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/CommandIrisPackDimensionTypeHandlerTest.java +++ b/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/CommandIrisPackDimensionTypeHandlerTest.java @@ -1,10 +1,30 @@ package art.arcane.iris.core.commands; +import art.arcane.volmlib.util.collection.KList; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class CommandIrisPackDimensionTypeHandlerTest { + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Test + public void emptyPackDirectoryDoesNotAdvertiseDefaultSentinel() throws Exception { + File packsFolder = temporaryFolder.newFolder("packs"); + + KList options = CommandIris.PackDimensionTypeHandler.packDimensionOptions(packsFolder); + + assertTrue(options.isEmpty()); + assertFalse(options.contains("default")); + } + @Test public void matchingPackAndDimensionUsesBarePackName() { assertEquals("overworld", diff --git a/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/CommandPregenCompletionContractTest.java b/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/CommandPregenCompletionContractTest.java new file mode 100644 index 000000000..6339c5bfd --- /dev/null +++ b/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/CommandPregenCompletionContractTest.java @@ -0,0 +1,48 @@ +package art.arcane.iris.core.commands; + +import art.arcane.volmlib.util.director.compat.DirectorEngineFactory; +import art.arcane.volmlib.util.director.runtime.DirectorInvocation; +import art.arcane.volmlib.util.director.runtime.DirectorRuntimeEngine; +import art.arcane.volmlib.util.director.runtime.DirectorSender; +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class CommandPregenCompletionContractTest { + @Test + public void startCompletesEveryConfigurableValueWithItsCanonicalKey() { + DirectorRuntimeEngine engine = DirectorEngineFactory.create(new CommandPregen()); + DirectorInvocation invocation = new DirectorInvocation(new TestSender(), "iris", List.of("start", "")); + + List suggestions = engine.tabComplete(invocation); + + assertTrue(suggestions.contains("radius=")); + assertTrue(suggestions.contains("world=")); + assertTrue(suggestions.contains("center=")); + assertTrue(suggestions.contains("gui=false")); + assertTrue(suggestions.contains("gui=true")); + assertTrue(suggestions.contains("serial=false")); + assertTrue(suggestions.contains("serial=true")); + assertFalse(suggestions.contains("true")); + assertFalse(suggestions.contains("false")); + } + + private static final class TestSender implements DirectorSender { + @Override + public String getName() { + return "test"; + } + + @Override + public boolean isPlayer() { + return false; + } + + @Override + public void sendMessage(String message) { + } + } +} diff --git a/core/src/main/java/art/arcane/iris/engine/platform/BukkitChunkGenerator.java b/core/src/main/java/art/arcane/iris/engine/platform/BukkitChunkGenerator.java index 7e4f8e841..f32ef4335 100644 --- a/core/src/main/java/art/arcane/iris/engine/platform/BukkitChunkGenerator.java +++ b/core/src/main/java/art/arcane/iris/engine/platform/BukkitChunkGenerator.java @@ -208,7 +208,9 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun } spawnChunks.complete(INMS.get().getSpawnChunkCount(world)); BukkitPlatform.volmitPlugin().unregisterListener(this); - IrisWorlds.get().put(WorldIdentity.serialize(world), dimensionKey); + if (shouldPersistWorldRegistration(studio)) { + IrisWorlds.get().put(WorldIdentity.serialize(world), dimensionKey); + } return true; } @@ -310,6 +312,10 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun : IrisEngine.InitializationMode.STUDIO; } + static boolean shouldPersistWorldRegistration(boolean studio) { + return !studio; + } + @NotNull @Override public EngineTarget getTarget() { diff --git a/core/src/test/java/art/arcane/iris/engine/platform/BukkitChunkGeneratorInitializationModeTest.java b/core/src/test/java/art/arcane/iris/engine/platform/BukkitChunkGeneratorInitializationModeTest.java index 244da2c8c..3ba1c7fa4 100644 --- a/core/src/test/java/art/arcane/iris/engine/platform/BukkitChunkGeneratorInitializationModeTest.java +++ b/core/src/test/java/art/arcane/iris/engine/platform/BukkitChunkGeneratorInitializationModeTest.java @@ -49,4 +49,10 @@ public class BukkitChunkGeneratorInitializationModeTest { assertFalse(BukkitChunkGenerator.shouldRunStudioHotload(true, false, true)); assertTrue(BukkitChunkGenerator.shouldRunStudioHotload(true, false, false)); } + + @Test + public void transientStudioWorldsAreNotPersisted() { + assertFalse(BukkitChunkGenerator.shouldPersistWorldRegistration(true)); + assertTrue(BukkitChunkGenerator.shouldPersistWorldRegistration(false)); + } }