Skip to main content
This documentation is for NameplateBuilder v4.260326.2 with API v2.0.0.

NameplateAPI - Static Methods

Segment Definition

MethodReturnsDescription
define(plugin, segmentId, displayName)SegmentBuilderDefine a segment. Defaults to SegmentTarget.ALL, no example.
define(plugin, segmentId, displayName, target)SegmentBuilderDefine a segment with an entity target hint.
define(plugin, segmentId, displayName, target, example)SegmentBuilderDefine a segment with target hint and example preview text.
defineVariants(plugin, segmentId, variantNames)voidRegister format variant names for a segment. Index 0 is the default.
undefine(plugin, segmentId)voidRemove a segment definition from the UI at runtime.

Per-Entity Text

MethodReturnsDescription
setText(store, entityRef, segmentId, text)voidSet or update nameplate text for a segment on an entity. Creates NameplateData if needed.
clearText(store, entityRef, segmentId)voidClear a segment’s text from an entity. Auto-removes NameplateData if empty.

Component Access

MethodReturnsDescription
getComponentType()ComponentType<EntityStore, NameplateData>Get the component type for direct ECS access.

Parameter Details

define() parameters:
ParameterTypeDescription
pluginJavaPluginYour plugin instance (pass this from setup())
segmentIdStringUnique key for this segment within your plugin (e.g. "health", "guild")
displayNameStringHuman-readable name shown in the UI (e.g. "Health Bar")
targetSegmentTargetUI hint for which entity types this applies to
exampleStringPreview text shown in the UI (e.g. "67/67"). Nullable.
setText() parameters:
ParameterTypeDescription
storeStore<EntityStore>The entity store
entityRefRef<EntityStore>Reference to the target entity
segmentIdStringThe segment key (must match what you passed to define())
textStringThe text value to display. Must not be blank - use clearText() to clear.

SegmentBuilder - Instance Methods

Returned by define(). Methods chain fluently and write through to the registry immediately - no build() call needed.
MethodReturnsDescription
resolver(resolver)SegmentBuilderRegister a function that computes text per entity every tick.
requires(componentType)SegmentBuilderOptimization hint: only call the resolver for entities whose archetype contains this component.
cacheTicks(ticks)SegmentBuilderHow many ticks to cache the resolver result per entity. Default: 1 (every tick).

SegmentResolver - Functional Interface

@FunctionalInterface
public interface SegmentResolver {
    String resolve(Store<EntityStore> store, Ref<EntityStore> entityRef, int variantIndex);
}
ParameterTypeDescription
storeStore<EntityStore>The entity store for reading components
entityRefRef<EntityStore>Reference to the entity being processed
variantIndexintThe viewer’s selected variant (0 = default)
ReturnsStringThe segment text to display, or null if this segment does not apply to this entity

NameplateData - Instance Methods

MethodReturnDescription
setText(key, text)voidSet or update a segment’s text. Pass null to remove.
getText(key)StringGet a segment’s current text. Returns null if not set.
removeText(key)voidRemove a segment.
getEntries()Set<Map.Entry>Unmodifiable view of all key-value entries.
isEmpty()booleanReturns true if no entries exist.

SegmentTarget - Enum

ValueUI TagDescription
ALL[All]Applies to all entity types
PLAYERS[Players]Intended for player entities
NPCS[NPCs]Intended for NPC entities
The target is a UI hint only. It does not restrict which entity types you can set text on or which entities a resolver runs for (use requires() for that).

Exceptions

ExceptionParentWhen It’s Thrown
NameplateExceptionRuntimeExceptionBase class - not thrown directly
NameplateNotInitializedExceptionNameplateExceptionAPI called before NameplateBuilder loaded. Check manifest.json dependency.
NameplateArgumentExceptionNameplateExceptionnull or blank passed to a required parameter.

Key Conventions

Segment IDs

  • Must be non-null and non-blank
  • Scoped to your plugin - two mods can both use "health" without conflict
  • Used as the key in NameplateData.setText() and NameplateData.getText()

Variant Key Suffixes (Manual Text Only)

  • Variant 0 (default) uses the base key: "health"
  • Variant 1 uses .1 suffix: "health.1"
  • Variant 2 uses .2 suffix: "health.2"
  • The aggregator falls back to the base key if a suffixed key is missing
  • Not needed when using resolvers - the variantIndex parameter handles this

Hidden Keys

  • Keys starting with _ (underscore) are hidden metadata
  • Stored in NameplateData but never shown in output or UI
  • Example: "_spawn_tick", "_phase"
  • See Advanced - Hidden Metadata Keys

Guides