# Bossbar

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

**Since:** 1.2.7

**Cancellable:** No. Calling `event.cancel()` throws `UnsupportedOperationException`.

Reports each boss-bar packet action after the client handles it. [type](#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_type) identifies the
 action; [bossBar](#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_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 {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_constructor-String-UUID-LerpingBossEvent-}

```js
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](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/entity/BossBarHelper.md); a null bar leaves [bossBar](#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_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 {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_bossBar}

```js
bossBar: BossBarHelper
```

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()](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/entity/BossBarHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getName-),  
 [getPercent()](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/entity/BossBarHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getPercent-),  
 [getColor()](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/entity/BossBarHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getColor-) and
 [getStyle()](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/entity/BossBarHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper_getStyle-).

### type {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_type}

```js
type: String
```

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 {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_uuid}

```js
uuid: String
```

The bar UUID as a string, available even when [bossBar](#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_bossBar) is `null`.

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventBossbar_toString-}

```js
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
