Describe module settings for studio as LoadedPack.schema()

PackSchema (com.volmit.host.schema) is a JSON-free description of every catalogued
settings type: features with their module, JSON field and targets, every reachable
class once by name (cycles end at the name), options with value kind, description,
required, bounds, defaults read from a no-argument instance and @Ref references,
plus object generator settings and snippets. Everything is in a fixed order.

The pack load fails, naming class, field and module, on unsupported field types,
@Ref on fields that are not text, classes without a working no-argument constructor
and snippet names that are not folder names or are used twice. GrassSettings.block
becomes a BlockState, a block reference without @Ref.
This commit is contained in:
piexel committed 2026-10-06 12:14:34 +02:00
1 parent 93c755ffe4
commit 3465f8d390
19 files changed
+1302 -6

No files matched your search

@@ -0,0 +1,73 @@
package com.volmit.host.schema;
import com.volmit.config.Reference;
import java.util.List;
import java.util.Objects;
/** The JSON an option takes. Every settings field maps to exactly one kind; a field of any other type
* fails the pack load, so the host never sees an untyped option.
*/
public sealed interface ValueKind {
/** {@code true} or {@code false}: {@code boolean} and {@code Boolean} fields. */
record BooleanKind() implements ValueKind {}
/** A whole number: {@code byte}, {@code short}, {@code int} and {@code long} fields and their boxes. */
record IntegerKind() implements ValueKind {}
/** Any number: {@code float} and {@code double} fields and their boxes. */
record DecimalKind() implements ValueKind {}
/** A string in {@code format} that names nothing in particular. */
record TextKind(TextFormat format) implements ValueKind {
public TextKind {
Objects.requireNonNull(format, "format");
}
}
/** A string in {@code format} that names an entry of {@code reference}, such as a block. */
record ReferenceKind(Reference reference, TextFormat format) implements ValueKind {
public ReferenceKind {
Objects.requireNonNull(reference, "reference");
Objects.requireNonNull(format, "format");
}
}
/** One of the constant names of the enum class named {@code type}, in declaration order. */
record EnumKind(String type, List<EnumConstant> constants) implements ValueKind {
public EnumKind {
Objects.requireNonNull(type, "type");
constants = List.copyOf(constants);
}
}
/** A JSON array of {@code element} values: lists, arrays and, with {@code unique}, sets. */
record ListKind(ValueKind element, boolean unique) implements ValueKind {
public ListKind {
Objects.requireNonNull(element, "element");
}
}
/** A JSON object with any string keys and {@code value} values: {@code Map<String, V>} fields. */
record MapKind(ValueKind value) implements ValueKind {
public MapKind {
Objects.requireNonNull(value, "value");
}
}
/** A JSON object described by the {@link ObjectType} named {@code type} in {@link PackSchema#types()}.
* Types are referenced by name, so a type that contains itself is described once.
*/
record ObjectKind(String type) implements ValueKind {
public ObjectKind {
Objects.requireNonNull(type, "type");
}
}
/** An enum constant and its {@code @Desc}, or an empty description. */
record EnumConstant(String name, String description) {
public EnumConstant {
Objects.requireNonNull(name, "name");
Objects.requireNonNull(description, "description");
}
}
}