Merge pull request #197 from kezz/get-players-boss-bars

Expose player to/from boss bar methods
This commit is contained in:
TheMode 2021-03-28 17:37:27 +02:00 committed by GitHub
commit 3f1d1531ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,6 +135,38 @@ public class BossBarManager {
}
}
/**
* Gets a collection of all boss bars currently visible to a given player.
*
* @param player the player
* @return the boss bars
*/
public @NotNull Collection<BossBar> getPlayerBossBars(@NotNull Player player) {
Collection<BossBarHolder> holders = this.playerBars.get(player.getUuid());
if (holders == null) {
return Collections.emptyList();
} else {
return holders.stream().map(holder -> holder.bar).collect(Collectors.toUnmodifiableList());
}
}
/**
* Gets all the players for whom the given boss bar is currently visible.
*
* @param bossBar the boss bar
* @return the players
*/
public @NotNull Collection<Player> getBossBarViewers(@NotNull BossBar bossBar) {
BossBarHolder holder = this.bars.get(bossBar);
if (holder == null) {
return Collections.emptyList();
} else {
return Collections.unmodifiableCollection(holder.players);
}
}
/**
* Gets or creates a handler for this bar.
*