From d197e588ee041edc49da40405870f808d3f754c4 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Mon, 14 Sep 2020 10:50:52 +0300 Subject: [PATCH] Fixed newline at the end of hover messages --- .../djrapitops/plan/commands/use/BukkitPartBuilder.java | 5 ++--- .../com/djrapitops/plan/command/use/BungeePartBuilder.java | 5 ++--- .../plan/commands/use/VelocityMessageBuilder.java | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/commands/use/BukkitPartBuilder.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/commands/use/BukkitPartBuilder.java index ebee35126..d42b8a996 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/commands/use/BukkitPartBuilder.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/commands/use/BukkitPartBuilder.java @@ -19,6 +19,7 @@ package com.djrapitops.plan.commands.use; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; +import org.apache.commons.text.TextStringBuilder; import java.util.Arrays; import java.util.Collection; @@ -78,9 +79,7 @@ class BukkitPartBuilder implements MessageBuilder { @Override public MessageBuilder hover(Collection lines) { ComponentBuilder hoverMsg = new ComponentBuilder(""); - for (String line : lines) { - hoverMsg.append(line + "\n"); - } + hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").build()); part.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverMsg.create())); return this; } diff --git a/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeePartBuilder.java b/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeePartBuilder.java index 146e1a060..2021a20f8 100644 --- a/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeePartBuilder.java +++ b/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeePartBuilder.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.commands.use.MessageBuilder; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; +import org.apache.commons.text.TextStringBuilder; import java.util.Arrays; import java.util.Collection; @@ -79,9 +80,7 @@ class BungeePartBuilder implements MessageBuilder { @Override public MessageBuilder hover(Collection lines) { ComponentBuilder hoverMsg = new ComponentBuilder(""); - for (String line : lines) { - hoverMsg.append(line + "\n"); - } + hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").build()); part.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverMsg.create())); return this; } diff --git a/Plan/velocity/src/main/java/com/djrapitops/plan/commands/use/VelocityMessageBuilder.java b/Plan/velocity/src/main/java/com/djrapitops/plan/commands/use/VelocityMessageBuilder.java index 4d8f14a7b..b43cefa15 100644 --- a/Plan/velocity/src/main/java/com/djrapitops/plan/commands/use/VelocityMessageBuilder.java +++ b/Plan/velocity/src/main/java/com/djrapitops/plan/commands/use/VelocityMessageBuilder.java @@ -19,6 +19,7 @@ package com.djrapitops.plan.commands.use; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; +import org.apache.commons.text.TextStringBuilder; import java.util.Collection; @@ -73,11 +74,9 @@ public class VelocityMessageBuilder implements MessageBuilder { } @Override - public MessageBuilder hover(Collection collection) { + public MessageBuilder hover(Collection lines) { TextComponent.Builder hoverText = TextComponent.builder(); - for (String string : collection) { - hoverText.content(string); - } + hoverText.content(new TextStringBuilder().appendWithSeparators(lines, "\n").build()); builder.hoverEvent(HoverEvent.showText(hoverText.build())); return this; }