Skip to content

BuilderAttributeDescriptor

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

public class BuilderAttributeDescriptor

Describes a single attribute within a BuilderDescriptor. Each attribute has a name, type string, lifecycle state, descriptions, and optional metadata such as requirement level, default value, domain constraints, array length bounds, and a Validator. Uses a fluent API for configuration.

private static enum RequirementType
ConstantDescription
REQUIREDThe attribute must be present.
OPTIONALThe attribute may be omitted; a default value applies.
REQUIRED_IF_NOT_OVERRIDDENRequired unless a parent builder provides it.
public BuilderAttributeDescriptor(String name, String type, BuilderDescriptorState state, String shortDescription, String longDescription)

Creates an attribute descriptor. Defaults to OPTIONAL requirement, not computable, no default value, no domain, no validator, and no size constraints.

FieldTypeDescription
nameStringAttribute name as it appears in JSON.
typeStringType description string (e.g., “double”, “string”, “enum”).
requiredRequirementTypeWhether the attribute is required.
computablebooleanWhether the value can be an expression.
stateBuilderDescriptorStateLifecycle state of the attribute.
shortDescriptionStringBrief description of the attribute.
longDescriptionStringDetailed description of the attribute.
defaultValueStringString representation of the default value, if any.
domainStringConstraint domain string (e.g., enum values).
minSize / maxSizeintArray length bounds. -1 means unconstrained.
validatorValidatorOptional validator for the attribute’s value.
flagDescriptionsMap<String, String>Enum flag names mapped to descriptions.
@Nonnull
public BuilderAttributeDescriptor required()

Marks the attribute as required and clears any default value.

@Nonnull
public BuilderAttributeDescriptor requiredIfNotOverridden()

Marks the attribute as required unless overridden by a parent builder.

@Nonnull
public BuilderAttributeDescriptor optional(String defaultValue)

Marks the attribute as optional with the given default value. Overloaded for double[], int[], String[], and boolean[].

@Nonnull
public BuilderAttributeDescriptor computable()

Marks the attribute as supporting expression evaluation.

@Nonnull
public <E extends Enum<E>> BuilderAttributeDescriptor setBasicEnum(@Nonnull Class<E> clazz)

Sets the domain from enum constants. Uses toString() for both name and description.

@Nonnull
public <E extends Enum<E> & Supplier<String>> BuilderAttributeDescriptor setEnum(@Nonnull Class<E> clazz)

Sets the domain from enum constants. Uses toString() for the name and get() for the description.

@Nonnull
public BuilderAttributeDescriptor domain(String domain)

Sets an explicit domain constraint string.

@Nonnull
public BuilderAttributeDescriptor validator(Validator validator)

Attaches a validator to this attribute.

@Nonnull
public BuilderAttributeDescriptor length(int size)

Sets both min and max array length to the given size.

@Nonnull
public BuilderAttributeDescriptor length(int minSize, int maxSize)

Sets the minimum and maximum array length bounds.

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