Fixed item names containing vertical bars displaying incorrectly (fixes #450)

This commit is contained in:
Intelli 2023-09-25 14:27:02 -06:00
parent d944c2bd89
commit e49913bc09
4 changed files with 7 additions and 2 deletions

View File

@ -82,4 +82,8 @@ public class SpigotAdapter implements SpigotInterface {
Chat.sendMessage(sender, message.toString());
}
public String processComponent(String component) {
return component.replace(Chat.COMPONENT_PIPE, "|");
}
}

View File

@ -19,7 +19,7 @@ public class Spigot_v1_16 extends SpigotHandler implements SpigotInterface {
try {
if (Config.getGlobal().HOVER_EVENTS) {
TextComponent component = new TextComponent(TextComponent.fromLegacyText(data[2]));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextComponent.fromLegacyText(data[1]))));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextComponent.fromLegacyText(processComponent(data[1])))));
((TextComponent) message).addExtra(component);
}
else {

View File

@ -17,6 +17,7 @@ public final class Chat {
public static final String COMPONENT_TAG_CLOSE = "</COMPONENT>";
public static final String COMPONENT_COMMAND = "COMMAND";
public static final String COMPONENT_POPUP = "POPUP";
public static final String COMPONENT_PIPE = "<PIPE/>";
private Chat() {
throw new IllegalStateException("Utility class");

View File

@ -304,7 +304,7 @@ public class Util extends Queue {
StringBuilder message = new StringBuilder(Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP);
// tooltip
message.append("|" + tooltip + "|");
message.append("|" + tooltip.replace("|", Chat.COMPONENT_PIPE) + "|");
// chat output
message.append(phrase);