Skip to content

Bossbar ​

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

Since1.2.7Not cancellable

Reports each boss-bar packet action after the client handles it. type identifies the action; bossBar is the full bar state when available.

js
JsMacros.on("Bossbar", JavaWrapper.methodToJava(function (event) {
 if (event.bossBar === null) {
   Chat.log(`Bossbar ${event.uuid} (${event.type}) is not on screen`);  
   return;  
 }
 const bar = event.bossBar;  
 Chat.log(`${event.type} ${bar.getName().getString()} ${(bar.getPercent() * 100).toFixed(1)}% (${bar.getColor()})`);  
}))

Constructors ​

new EventBossbar ​

new EventBossbar(String type, UUID uuid, LerpingBossEvent bossBar)#
Initializes this event from the supplied action, bar identifier, and optional raw bar. A non-null bar is wrapped in a BossBarHelper; a null bar leaves bossBar null. The supplied action is stored unchanged and is not validated against the bar or identifier. A null identifier throws NullPointerException while converting it to a string.

Parameters:

  • type: supplied action label; arbitrary values, including null, are stored unchanged
  • uuid: identifier for the bar; must be non-null
  • bossBar: raw bar to wrap, or null when no bar is available

Fields ​

bossBar ​

bossBar: BossBarHelperread-only#
The full boss bar state, or null if the overlay has no bar for this UUID. A 'REMOVE' event always has null; other update types may also have null. When non-null, it exposes the bar's getName(), getPercent(), getColor() and getStyle().

type ​

type: Stringread-only#
The boss-bar packet action. 'ADD' for a new bar, 'REMOVE' when it is taken away, and 'UPDATE_PERCENT', 'UPDATE_NAME', 'UPDATE_STYLE' or 'UPDATE_PROPERTIES' for the respective changes to an existing bar.

uuid ​

uuid: Stringread-only#
The bar UUID as a string, available even when bossBar is null.

Methods ​

toString ​

toString(): String#
Formats a diagnostic string containing the event name and the current helper's string, or the stored UUID string when no helper is present. The fallback is unquoted and is not a standalone UUID field or a JSON serialization.
Returns: event name followed by :{"bossBar": %s}, with %s replaced by the helper string or UUID string