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())
.name(chatMessage.getName())
.sender(chatMessage.getSender())
.value(nbsp(chatMessage.getMessage()))
.runeLiteFormattedMessage(nbsp(chatMessage.getMessageNode().getRuneLiteFormatMessage()))
.value(tweakSpaces(chatMessage.getMessage()))
.runeLiteFormattedMessage(tweakSpaces(chatMessage.getMessageNode().getRuneLiteFormatMessage()))
.timestamp(chatMessage.getTimestamp())
.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
* @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)
{
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;