From dc0358957efba5cebd16115654478631f808d990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Sun, 5 Jul 2020 18:02:43 +0200 Subject: [PATCH] Add prefix replacement to messages and skip sending empty messages --- .../com/plotsquared/bukkit/player/BukkitPlayer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 8a66f1fd0..2cf57f36b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -33,6 +33,7 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Caption; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; @@ -64,6 +65,7 @@ import org.jetbrains.annotations.NotNull; import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Arrays; +import java.util.List; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -245,8 +247,15 @@ public class BukkitPlayer extends PlotPlayer { @Override public void sendMessage(@NotNull final Caption caption, @NotNull final Template... replacements) { - // TODO: Inject the prefix here - final Component component = MINI_MESSAGE.parse(caption.getComponent(this), replacements); + final String message = caption.getComponent(this); + if (message.isEmpty()) { + return; + } + // Create the template list, and add the prefix as a replacement + final List