mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Render @MinItems as minItems in studio's module settings schema
This commit is contained in:
1 parent
2775a4965b
commit
f3619e1c30
3 files changed
+18
No files matched your search
@@ -177,6 +177,7 @@ final class ModuleSchemaRenderer {
|
||||
}
|
||||
option.minimum().ifPresent(minimum -> property.put("minimum", minimum));
|
||||
option.maximum().ifPresent(maximum -> property.put("maximum", maximum));
|
||||
option.minItems().ifPresent(minItems -> property.put("minItems", minItems));
|
||||
option.defaultValue().ifPresent(value -> property.put("default", JSONObject.wrap(value)));
|
||||
return property;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.volmit.config.PackSettings;
|
||||
import com.volmit.host.LoadedPack;
|
||||
import com.volmit.host.ResolvedGraph;
|
||||
import com.volmit.host.schema.FeatureSchema;
|
||||
import com.volmit.host.schema.ObjectType;
|
||||
import com.volmit.host.schema.SchemaOption;
|
||||
import com.volmit.host.schema.ValueKind;
|
||||
import com.volmit.stage.MantleStage;
|
||||
@@ -40,6 +41,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -108,6 +110,18 @@ public class BuiltInGenerationGraphTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depositGeneratorsKeepTheMinimumListLengthsTheOldClassHad() throws IOException {
|
||||
try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) {
|
||||
ObjectType generator = pack.schema().type(DepositGenerator.class.getName());
|
||||
|
||||
for (String list : List.of("palette", "replaceableBlocks", "includedBiomes", "excludedBiomes")) {
|
||||
SchemaOption option = generator.options().stream().filter(candidate -> candidate.name().equals(list)).findFirst().orElseThrow();
|
||||
assertEquals(list, OptionalInt.of(1), option.minItems());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> ids(ResolvedGraph graph) {
|
||||
return graph.stages().stream().map(stage -> stage.stage().id().toString()).toList();
|
||||
}
|
||||
|
||||
@@ -280,6 +280,8 @@ public class SchemaBuilderParityTest {
|
||||
JSONObject tint = definitions.getJSONObject(definitionKey(rootProperties(schema).getJSONObject("example:tint")))
|
||||
.getJSONObject("properties");
|
||||
|
||||
assertEquals("@MinItems renders as minItems", 1, tint.getJSONObject("palette").getInt("minItems"));
|
||||
assertFalse("options without it have none", tint.getJSONObject("style").has("minItems"));
|
||||
JSONObject spec = definitions.getJSONObject(definitionKey(tint.getJSONObject("palette").getJSONObject("items")));
|
||||
assertEquals("obj-art-arcane-iris-engine-object-material-irisblockdata", definitionKey(spec));
|
||||
assertTrue(definitions.getJSONObject("obj-art-arcane-iris-engine-object-material-irisblockdata").getJSONObject("properties").has("block"));
|
||||
@@ -674,6 +676,7 @@ public class SchemaBuilderParityTest {
|
||||
|
||||
@Feature(id = "example:tint", name = "Tint", targets = Target.OBJECT_PLACEMENT)
|
||||
public static final class TintSettings implements IrisFeature {
|
||||
@com.volmit.config.MinItems(1)
|
||||
private List<com.volmit.block.BlockSpec> palette = List.of();
|
||||
private com.volmit.noise.NoiseStyle style = com.volmit.noise.NoiseStyle.of("SIMPLEX");
|
||||
private java.util.Map<String, Object> extra = java.util.Map.of();
|
||||
|
||||
Reference in new issue
Block a user