Skip to content

BossBarHelper ​

com.jsmacrosce.jsmacros.client.api.helper.world.entity.BossBarHelper

Since1.2.1

A wrapper exposing the state of one boss bar known to the client.

World.getBossBars() returns a map keyed by the string from getUUID().
The boss-bar event's bossBar field is null when a bar is removed.

The percentage is the smoothed one the overlay animates towards rather than the value the server last sent: the bar eases from the previous percentage to the new one over 100 milliseconds, so reads can differ even when the server has sent nothing in between.

js
const bars = World.getBossBars();  
Chat.log(`${bars.size()} boss bar(s) on screen`);  
for (const entry of bars.entrySet()) {
 const bar = entry.getValue();  
 // the percentage is a fraction from 0 to 1, not a number from 0 to 100
 const percent = Math.round(bar.getPercent() * 100);  
 Chat.log(`${bar.getName().getString()} at ${percent}% (${bar.getColor()}, ${bar.getStyle()})`);  
}

Constructors ​

new BossBarHelper ​

new BossBarHelper(BossEvent b)#
Wraps the supplied boss-bar event.

Parameters:

  • b: raw boss event to wrap

Methods ​

getColor ​

getColor(): StringSince1.2.1#
Returns the BossEvent.BossBarColor enum name in uppercase, so one of PINK, BLUE, RED, GREEN, YELLOW, PURPLE or WHITE. These are the seven the game defines, and the string is what the TypeScript typings narrow this to. This name does not uniquely identify the formatting: PINK and RED both use red formatting. Use getColorFormat() or getColorValue() for the formatting or its RGB value.
Returns: the uppercase enum name.

getColorFormat ​

getColorFormat(): FormattingHelperSince1.8.4#
Returns the formatting associated with the bar's color.
Returns: the bar color's formatting.

getColorValue ​

getColorValue(): intSince1.8.4#
Returns the packed RGB value of the bar's formatting, or -1 if it has no RGB value.
Returns: the formatting's RGB value, or -1 if absent.

getName ​

getName(): TextHelperSince1.2.1#
Returns the bar's title as a TextHelper, preserving its text styling.
Returns: the bar's styled title.

getPercent ​

getPercent(): floatSince1.2.1#
Returns the current smoothed progress as a fraction from 0 to 1. The client animates this value toward the latest progress received from the server.
Returns: current progress fraction; values are not converted to percentages.

getStyle ​

getStyle(): StringSince1.2.1#
Returns the BossEvent.BossBarOverlay enum name in uppercase, so one of PROGRESS, NOTCHED_6, NOTCHED_10, NOTCHED_12 or NOTCHED_20. The notched ones are the same bar with the notches added, and the number is how many segments it is cut into.
Returns: the uppercase overlay enum name.

getUUID ​

getUUID(): StringSince1.2.1#
Returns the bar's UUID as a string, matching its key in World.getBossBars().
Returns: this bar's UUID.

toString ​

toString(): String#
Returns a diagnostic string containing the bar's plain name and raw progress value.
Returns: a diagnostic representation of the bar