Skip to content

NameChange ​

com.jsmacrosce.jsmacros.client.api.event.impl.world.EventNameChange

Since1.9.1Cancellable

Fires when an entity's custom-name data changes. Cancelling prevents the update; otherwise,
listeners can replace newName, including setting it to null to clear the name.

Constructors ​

new EventNameChange ​

new EventNameChange(Entity entity, Component oldName, Component newName)#
Wraps the entity and custom-name values for a name-change event; it does not apply the change or dispatch the event. Passing null for entity causes a NullPointerException.

Parameters:

  • entity: non-null entity to wrap
  • oldName: previous raw custom-name component, or null if none was set
  • newName: supplied raw custom-name component, or null to clear the name

Fields ​

entity ​

entity: EntityHelper<?>read-only#
Entity whose custom name is changing.

newName ​

newName: TextHelper#
New custom name, or null to clear it. A listener may replace the incoming value; cancellation prevents the update. Create replacement text with Chat.createTextHelperFromString(String).

oldName ​

oldName: TextHelperread-only#
Previous custom name, or null if none was set.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and current name values. Each value is the corresponding helper's getString() result, or the unquoted token null; newName therefore reflects its current, potentially listener-replaced value. This is not JSON serialization.
Returns: a string in the form eventName:{"oldName": oldValue, "newName": newValue}