NameChange
com.jsmacrosce.jsmacros.client.api.event.impl.world.EventNameChange
Fires when an entity's custom-name data changes. Cancelling prevents the update; otherwise, a joined listener can replace the name with setNewName(...), including setting it to null to clear it.
Constructors
new EventNameChange
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 wrapoldName: previous raw custom-name component, ornullif none was setnewName: supplied raw custom-name component, ornullto clear the name
Fields
entity
Entity whose custom name is changing.
newName
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).Deprecated: Removal in 3.0.0: Use getNewName() and setNewName(TextHelper) instead.
oldName
Previous custom name, or
null if none was set.Methods
getNewName
Returns the incoming custom name, or
null when the name is being cleared.Returns: the current replacement helper, or
nullsetNewName
Replaces the incoming custom name.
null clears the name. Create replacement text with Chat.createTextHelperFromString(String).Parameters:
newName: replacement helper, ornullto clear the name
toString
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}