Skip to content

BuilderManager

Package: com.hypixel.hytale.server.npc.asset.builder

public class BuilderManager

The central manager for loading, caching, validating, and hot-reloading NPC role JSON assets from asset packs. Maintains a concurrent cache of BuilderInfo entries indexed by integer IDs, a map of BuilderFactory instances by category class, and a case-insensitive name-to-index map.

The manager walks the Server/NPC/Roles/ directory tree, parses each JSON file, selects the appropriate factory based on the "Class" key (defaulting to "Role"), creates and reads the builder, validates it, and caches it. It supports file-system monitoring for hot-reload during development.

ConstantTypeValue
CONTENT_KEYString"Content"
FieldTypeDescription
builderCacheInt2ObjectConcurrentHashMap<BuilderInfo>Thread-safe builder cache indexed by integer ID.
factoryMapMap<Class<?>, BuilderFactory<?>>Builder factories keyed by category class.
categoryNamesMap<String, Class<?>>Category name to class mapping.
nameToIndexMapObject2IntMap<String>Case-insensitive name to index mapping.
SCHEMA_BUILDER_MANAGERBuilderManagerStatic instance used for schema generation.
public <T> void registerFactory(@Nonnull BuilderFactory<T> factory)

Registers a builder factory for a category. Called by NPCPlugin during setup.

public void addCategory(String name, Class<?> clazz)

Maps a string name (e.g., "Role", "Action") to a category class.

public int getIndex(@Nullable String name)
public int getOrCreateIndex(String name)
@Nullable
public String lookupName(int index)

Name-to-index mapping with read/write locking for thread safety.

public boolean loadBuilders(@Nonnull AssetPack pack, boolean includeTests)

Walks the NPC role asset directory, loads all JSON files, validates builders, resolves dependencies, and fires AllNPCsLoadedEvent on completion.

public void unloadBuilders(AssetPack pack)

Removes all builders loaded from the given asset pack.

public <T> BuilderFactory<T> getFactory(Class<?> classType)

Returns the factory for the given category class.

tryGetCachedValidBuilder / getCachedBuilder

Section titled “tryGetCachedValidBuilder / getCachedBuilder”
@Nullable
public <T> Builder<T> tryGetCachedValidBuilder(int index, Class<?> classType)
public <T> Builder<T> getCachedBuilder(int index, Class<?> classType)

Retrieves a cached, validated builder by index.

public void setAutoReload(boolean autoReload)

Enables or disables file-system hot-reload.

Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.