Boss bars
Create a boss bar, manage who sees it, and remove it when the feature ends.
Create and update
boss_bar::BossBar::new(title, BossBarColor, BossBarDivision) creates a bar. It has getters and setters for the title, the health (progress), the color, the division and its metadata flags. Keep the progress between 0 and 1 and never pass NaN.
Viewers
add_player and remove_player change who sees the bar; get_players lists them. Keep the viewer list bounded and do not resend an unchanged title or progress every tick.
Cleanup
remove_all hides the bar from everyone. Call it when the feature ends, then drop your handle. When your script's instance ends (an unload, a reload, a restart after a failure, the server stop), the server removes the bars it still shows from every player.
The boss-bar reference lists the exact types and functions.