Skip to content

Commit

Permalink
Fixed item names containing vertical bars displaying incorrectly (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Sep 25, 2023
1 parent d944c2b commit e49913b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/coreprotect/spigot/SpigotAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ public void sendComponent(CommandSender sender, String string, String bypass) {

Chat.sendMessage(sender, message.toString());
}

public String processComponent(String component) {
return component.replace(Chat.COMPONENT_PIPE, "|");
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/coreprotect/spigot/Spigot_v1_16.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void addHoverComponent(Object message, String[] data) {
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 {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/coreprotect/utility/Chat.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/coreprotect/utility/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static String createTooltip(String phrase, String tooltip) {
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);
Expand Down

0 comments on commit e49913b

Please sign in to comment.