SpongePowered / Sponge

The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
MIT License
389 stars 211 forks source link

ServerBossBar player list is not updated on player respawn #1921

Open Yeregorix opened 6 years ago

Yeregorix commented 6 years ago

I am currently running

Issue Description I found while testing a private plugin that when a player die, the player object is recreated but the player list in a ServerBossBar object is not updated. Therefore it causes issues for plugins depending on ServerBossBar#getPlayers

How to reproduce Using a plugin, create a ServerBossBar object, add a player in, print each second the position of all players in ServerBossBar#getPlayers. In game, at the beginning, printed positions will correspond the player position. Now, kill the player, new printed positions will no longer be synced with player position but it will print the world spawn position.

ImMorpheus commented 6 years ago

@Yeregorix Can you reproduce this on stable-7 ?

Yeregorix commented 6 years ago

Good question, I will try 🤔

Yeregorix commented 6 years ago

This issue also affects SV 1.12.2-7.1.0-BETA-111 and SF 1.12.2-2705-7.1.0-BETA-3422.

RedNesto commented 6 years ago

I searched a bit and it seems it's a Minecraft "behavior". It seems the BossInfoServer is only updated when a player enters or leaves a boss zone, but not when a player is killed and respawned.

It can be easily fixed by a plugin by listening to RespawnPlayerEvent to restore the bossbar to the player based on the getOriginalPlayer return value.

But it needs a fix in Sponge IMO.

ImMorpheus commented 6 years ago

I don't think we should be fixing minecraft intended behaviour. If it's a bug with the game, you need to open an issue on their issue tracker.

Zidane commented 6 years ago

@ImMorpheus

It is a bug, not intended behavior and likely something they missed internally when testing bars. Generally one doesn't respawn on top of a boss. Fixing this in Sponge doesn't break any behavior, just because the Player object got re-created doesn't mean the Player isn't still applicable to the bar in question (again so long as they are within range of it). This wouldn't be the first time we've fixed Vanilla bugs like this.

Yeregorix commented 6 years ago

I think it's neither a bug, neither an intended behavior, in vanilla, boss bars are removed on player death, Mojang just didn't thought that some developers will use boss bars in other situations. Anyway, it would be easier for plugin developers if Sponge API can guarantee that getPlayers() never contains an outdated Player object.

Zidane commented 6 years ago

@Yeregorix

It is a bug lol. They just didn't remove the old object and then add you back to the bar after respawn if you're still in range of it. It is a consequence of how they handle respawn itself. You fix that and then the List is fine lol.

ryantheleach commented 6 years ago

In addition, the boss bar commands are a first class minecraft feature in 1.13.