PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
10.04k stars 2.34k forks source link

Player List Health Always Displays as Integer when set in Bukkit's API #5362

Closed Wyatt-James closed 3 years ago

Wyatt-James commented 3 years ago

What behaviour is expected:

Player health shown as hearts when using RenderType.HEARTS.

What behaviour is observed:

Player health is shown as an Integer.

Steps/models to reproduce:

In a Bukkit plugin, execute this code:

Scoreboard mainScoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
Objective healthDisplay = mainScoreboard.registerNewObjective("health", "health", "Health", RenderType.HEARTS);
healthDisplay.setDisplaySlot(DisplaySlot.PLAYER_LIST);

Plugin list:

Just a testing Plugin as described above.

Paper version:

git-Paper-547 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)

Anything else:

Works as expected with scoreboard command.

Started happening in Paper-473. Works correctly in Spigot.

montlikadani commented 3 years ago

Third parameter of Scoreboard#registerNewObjective method requires Component as display name. So just deserialize the Health name using

PlainComponentSerializer.plain().deserialize("Health")

for temporary solution. Obviously if you have Paper dependency.

kashike commented 3 years ago
PlainComponentSerializer.plain().deserialize("Health")

or Component.text("Health") :wink:

Wyatt-James commented 3 years ago

for temporary solution. Obviously if you have Paper dependency.

Or alternately just run as a command with the console command sender.

Wyatt-James commented 3 years ago

Thanks 👍