Fix chat history wrapping

This commit is contained in:
Twiglet1022
2019-04-22 12:12:00 +01:00
parent e7cdf50cfb
commit b8f017a49b

View File

@@ -145,8 +145,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
.type(chatMessage.getType()) .type(chatMessage.getType())
.name(chatMessage.getName()) .name(chatMessage.getName())
.sender(chatMessage.getSender()) .sender(chatMessage.getSender())
.value(nbsp(chatMessage.getMessage())) .value(tweakSpaces(chatMessage.getMessage()))
.runeLiteFormattedMessage(nbsp(chatMessage.getMessageNode().getRuneLiteFormatMessage())) .runeLiteFormattedMessage(tweakSpaces(chatMessage.getMessageNode().getRuneLiteFormatMessage()))
.timestamp(chatMessage.getTimestamp()) .timestamp(chatMessage.getTimestamp())
.build(); .build();
@@ -177,15 +177,17 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
} }
/** /**
* Small hack to prevent plugins checking for specific messages to match * Small hack to prevent plugins checking for specific messages to match. This works because the "—" character
* cannot be seen in-game. This replacement preserves wrapping on chat history messages.
* @param message message * @param message message
* @return message with nbsp * @return message with invisible character before every space
*/ */
private static String nbsp(final String message) private static String tweakSpaces(final String message)
{ {
if (message != null) if (message != null)
{ {
return message.replace(' ', '\u00A0'); // First replacement cleans up prior applications of this so as not to keep extending the message
return message.replace("", " ").replace(" ", "");
} }
return null; return null;