SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 342 forks source link

Fire an event when a ServerBossBar is created/modified #1533

Open VapidLinus opened 7 years ago

VapidLinus commented 7 years ago

It would be great with an event that fires when a ServerBossBar is created or modified, as well for when a player is added or removed from one.

See the first and last posts in this thread: https://forums.spongepowered.org/t/solved-serverbossbar-retrieval-help/18268/5

mosemister commented 7 years ago

The original post suggests that you also want a way so you can retrieve bossBars from the player such as one of the following ways

List<BossBar> list = Player.getBossBars();

Or

List<ServerBossBar> list = Sponge.getServer().getBossBars();
//From there filter bars with the player
VapidLinus commented 7 years ago

@mosemister Yes that's correct.

I was thinking though if the Sponge team didn't want to do that for whatever reason, then having events fired when they're created/joined/left would be enough for a plugin to track that by itself.

However, having both the events and player.getBossBars() and server.getBossBars() would be the best.

ryantheleach commented 7 years ago

@VapidLinus we have been discussing what the possible API would look like for this, and were wondering what the usecase was, so we can make sure that whatever gets proposed would suit.

Some brainstorming we came up with:

Renaming withers to say who spawned them. editing the text to have a countdown timer for how long the wither will last. Stopping the bars being displayed for riding enderdragons.

I havn't tested the forum usecase, but presumably if you are giving the player a bossbar, your own plugin could cache / keep a collection of the bossbars it has issued and manage them that way.

kashike commented 7 years ago

You can obtain the ServerBossBar for a Wither now: https://github.com/SpongePowered/SpongeAPI/pull/1534/files#diff-96e1f3b357e27049ddf52fd33571cadfR63 Access to the dragon bossbar is coming later.