Fixed newline at the end of hover messages

This commit is contained in:
Risto Lahtela 2020-09-14 10:50:52 +03:00
parent 7e34084b85
commit d197e588ee
3 changed files with 7 additions and 10 deletions

View File

@ -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<String> 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;
}

View File

@ -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<String> 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;
}

View File

@ -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<String> collection) {
public MessageBuilder hover(Collection<String> 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;
}