From c9766dee975624545d93b93087da8ea78fdf024b Mon Sep 17 00:00:00 2001 From: Nesseley Date: Mon, 9 Aug 2021 21:29:38 +0200 Subject: [PATCH] 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 --- changelog.md | 1 + .../java/com/garbagemule/MobArena/announce/TitleAnnouncer.java | 2 +- .../java/com/garbagemule/MobArena/healthbar/TitleHealthBar.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 2591ae7..476e1e1 100644 --- a/changelog.md +++ b/changelog.md @@ -27,6 +27,7 @@ These changes will (most likely) be included in the next version. - Pillagers and vindicators no longer spawn without their much-needed weapons. - Piglins, piglin brutes, and hoglins no longer zombify. This fixes a bug where the mobs would despawn due to the zombification process. - Reward groups with `nothing` in them no longer cause errors when earned/granted. +- The title-based announcer and the title-based boss health bar have been fixed to work with the breaking change to the Title API in Spigot 1.17. ## [0.106] - 2021-05-09 ### Added diff --git a/src/main/java/com/garbagemule/MobArena/announce/TitleAnnouncer.java b/src/main/java/com/garbagemule/MobArena/announce/TitleAnnouncer.java index bd41c57..6cf4e2c 100644 --- a/src/main/java/com/garbagemule/MobArena/announce/TitleAnnouncer.java +++ b/src/main/java/com/garbagemule/MobArena/announce/TitleAnnouncer.java @@ -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); } } diff --git a/src/main/java/com/garbagemule/MobArena/healthbar/TitleHealthBar.java b/src/main/java/com/garbagemule/MobArena/healthbar/TitleHealthBar.java index 7bdf991..5bcf45a 100644 --- a/src/main/java/com/garbagemule/MobArena/healthbar/TitleHealthBar.java +++ b/src/main/java/com/garbagemule/MobArena/healthbar/TitleHealthBar.java @@ -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,