Use spaces for "empty" titles.

Due to a breaking change in Spigot 1.17, sending a title with an empty string no longer works, even if a non-empty subtitle is provided. The TitleAnnouncer and TitleHealthBar components only use the subtitle portion of the title API to avoid obtrusive behavior.

With this commit, the two components send a single space character as the title. Effectively, there is no difference between showing the empty string or a single space on the client-side. It's a dirty hack to fix something that should be fixed in Spigot instead, but odds are that it won't be.

Fixes #683
This commit is contained in:
Nesseley
2021-08-09 21:32:55 +02:00
committed by Andreas Troelsen
parent c143cc81c9
commit c9766dee97
3 changed files with 3 additions and 2 deletions
@@ -16,7 +16,7 @@ public class TitleAnnouncer implements Announcer {
@Override
public void announce(Player player, String message) {
player.sendTitle("", message, fadeIn, stay, fadeOut);
player.sendTitle(" ", message, fadeIn, stay, fadeOut);
}
}
@@ -27,7 +27,7 @@ class TitleHealthBar implements HealthBar {
String message = title.isEmpty() ? health : title + " " + health;
players.forEach(player -> player.sendTitle(
"",
" ",
message,
FADE_IN_TICKS,
STAY_TICKS,