Contents
Class SchemaGenerator
java.lang.Object
com.hypixel.hytale.server.core.schema.SchemaGenerator
Central registry and generator for JSON schemas.
Provides registration APIs for config schemas and custom asset schemas,
and a generate(Path, Path) method that orchestrates full schema generation
including asset schemas from AssetRegistry.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddVsCodeSchemaLink(org.bson.BsonDocument vsCodeConfig, String schemaFileName, List<String> fileMatchPatterns, String extension) Adds a VSCode schema association to the given config document.static voidGenerates all schemas and writes them to the specified output directories.Generates all asset schemas (fromAssetRegistryand registered custom schemas) and returns them in memory, including shared definitions.static voidregisterAssetSchema(String fileName, Function<SchemaContext, Schema> factory, List<String> fileMatchPatterns, String extension) Registers a custom asset-like schema for generation (e.g.static voidregisterConfig(String name, BuilderCodec<?> codec, String virtualPath, List<String> fileMatchPatterns) Registers a config schema for generation.static StringtoFileName(String name) Converts a schema name to a safe filename.static voidwriteSchemas(Map<String, Schema> schemas, Path schemaDir) Writes a map of schemas to disk as JSON files.
-
Constructor Details
-
SchemaGenerator
public SchemaGenerator()
-
-
Method Details
-
registerConfig
public static void registerConfig(@Nonnull String name, @Nonnull BuilderCodec<?> codec, @Nullable String virtualPath, @Nullable List<String> fileMatchPatterns) Registers a config schema for generation.- Parameters:
name- the display name and schema identifier (e.g. "HytaleServerConfig")codec- the codec to generate the schema fromvirtualPath- optional virtual path for documentation navigation (e.g. "Config")fileMatchPatterns- optional file match patterns relative to server root for VSCode
-
registerAssetSchema
public static void registerAssetSchema(@Nonnull String fileName, @Nonnull Function<SchemaContext, Schema> factory, @Nullable List<String> fileMatchPatterns, @Nullable String extension) Registers a custom asset-like schema for generation (e.g. InstanceConfig, NPCRole).- Parameters:
fileName- the output filename (e.g. "InstanceConfig.json")factory- a function that creates the schema given a contextfileMatchPatterns- optional file match patterns relative to/Server/for VSCodeextension- optional file extension (e.g. ".bson"); null defaults to ".json"
-
generateAssetSchemas
Generates all asset schemas (fromAssetRegistryand registered custom schemas) and returns them in memory, including shared definitions.This is used by the Asset Editor to send schemas to clients without writing to disk.
- Returns:
- a map of filename to schema, including asset schemas and shared definitions
-
generate
Generates all schemas and writes them to the specified output directories.All schemas are always processed through the shared context to build complete shared definitions. Output is written only to non-null directories.
- Parameters:
assetOutputDir- if non-null, asset schemas are written hereconfigOutputDir- if non-null, config schemas are written here
-
toFileName
-
writeSchemas
-
addVsCodeSchemaLink
public static void addVsCodeSchemaLink(@Nonnull org.bson.BsonDocument vsCodeConfig, @Nonnull String schemaFileName, @Nonnull List<String> fileMatchPatterns, @Nullable String extension) Adds a VSCode schema association to the given config document.- Parameters:
vsCodeConfig- the VSCode settings documentschemaFileName- the schema filename (without path prefix)fileMatchPatterns- the file match patterns for VSCodeextension- optional file extension to associate with JSON (e.g. ".bson")
-