diff --git a/README.md b/README.md index 8000f99f5..4d1ed2d05 100644 --- a/README.md +++ b/README.md @@ -651,7 +651,7 @@ public final class FloraSettings implements IrisFeature { use them. Both are deprecated for removal: transitional, until the cut-over. - Settings named in `when(...)` and object generator settings are described automatically. Settings that no stage names, such as ones read only through `FeatureSettings.at(...)`, are registered with - `setup.registry().registerSettings(WindSettings.class, GustSettings.class)` in `setup`. Their feature id follows the module + `setup.registry().registerSettings(WindSettings.class)` in `setup`, one call per type. Their feature id follows the module id like any other, and once registered, other modules may name them in `when(...)`. A load error names the field, the settings and the module: diff --git a/api/src/main/java/com/volmit/FeatureRegistry.java b/api/src/main/java/com/volmit/FeatureRegistry.java index 54b980a43..a7775cc7d 100644 --- a/api/src/main/java/com/volmit/FeatureRegistry.java +++ b/api/src/main/java/com/volmit/FeatureRegistry.java @@ -23,14 +23,14 @@ public interface FeatureRegistry { */ void registerMantle(MantleKey key, MantleLifetime lifetime, MantleCodec codec); - /** Catalogs settings types that no stage names in {@code when(...)}, such as ones read only - * through {@link com.volmit.config.FeatureSettings#at}, so the host decodes them and studio - * describes them: {@code registerSettings(WindSettings.class, GustSettings.class)}. Settings that a - * stage names are catalogued without this; registering them as well changes nothing. Each type's - * feature id must be this module's id or start with it and {@code /}. Once registered, other - * modules may name the types in {@code when(...)} (see {@link StageGraph}). + /** Catalogs a settings type that no stage names in {@code when(...)}, such as one read only + * through {@link com.volmit.config.FeatureSettings#at}, so the host decodes it and studio + * describes it: {@code registerSettings(WindSettings.class)}. Settings that a stage names are + * catalogued without this; registering them as well changes nothing. The type's feature id must + * be this module's id or start with it and {@code /}. Once registered, other modules may name + * the type in {@code when(...)} (see {@link StageGraph}). */ - void registerSettings(Class... settingsTypes); + void registerSettings(Class settingsType); /** Declares a kind of pack resource this module reads: the JSON files under the kind's folder, served through * {@link com.volmit.resource.PackResources} by the kind's type and described for studio from its class like diff --git a/host/src/main/java/com/volmit/host/ModuleRegistry.java b/host/src/main/java/com/volmit/host/ModuleRegistry.java index b3987ec70..cacfa2a76 100644 --- a/host/src/main/java/com/volmit/host/ModuleRegistry.java +++ b/host/src/main/java/com/volmit/host/ModuleRegistry.java @@ -94,14 +94,9 @@ public final class ModuleRegistry implements FeatureRegistry, ToolingRegistry { } @Override - public void registerSettings(Class... settingsTypes) { + public void registerSettings(Class settingsType) { checkOpen(); - for (var settingsType : settingsTypes) { - registerOneSettings(settingsType); - } - } - - private void registerOneSettings(Class settingsType) { + Objects.requireNonNull(settingsType, "settingsType"); var descriptor = FeatureDescriptor.of(settingsType); requireOwnedId("Settings " + settingsType.getName() + " with feature id", descriptor.id()); catalogSettings(descriptor, registering); diff --git a/host/src/test/java/com/volmit/host/ModuleRegistryTest.java b/host/src/test/java/com/volmit/host/ModuleRegistryTest.java index c359dafbe..b3c9ed0c1 100644 --- a/host/src/test/java/com/volmit/host/ModuleRegistryTest.java +++ b/host/src/test/java/com/volmit/host/ModuleRegistryTest.java @@ -352,15 +352,6 @@ class ModuleRegistryTest { assertTrue(registry.registeredByOwner(One.class)); } - @Test - void oneCallRegistersSeveralSettingsTypes() { - var registry = new ModuleRegistry(); - registerAs(registry, "test:core", settings -> settings.registerSettings(One.class, Two.class)); - - assertEquals(List.of("test:core/one", "test:core/two"), - registry.freeze().settings().stream().map(value -> value.id().toString()).sorted().toList()); - } - @Test void explicitSettingsFollowTheRegisteringModulesIdAndStillCollide() { var registry = new ModuleRegistry();