diff --git a/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java b/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java index 2556c45..9df9a07 100644 --- a/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java +++ b/src/main/java/com/github/ucchyocean/lc3/util/ClickableFormat.java @@ -71,7 +71,7 @@ public class ClickableFormat { LunaChatAPI api = LunaChat.getAPI(); - ClickableFormat msg = new ClickableFormat(new KeywordReplacer(Utility.replaceColorCode(format))); + ClickableFormat msg = new ClickableFormat(new KeywordReplacer(Utility.replaceColorCode(withoutPartMarkers(format)))); if ( channel != null ) { @@ -141,7 +141,7 @@ public class ClickableFormat { */ public static ClickableFormat makeChannelClickableMessage(String format, String channelName) { - ClickableFormat msg = new ClickableFormat(new KeywordReplacer(Utility.replaceColorCode(format))); + ClickableFormat msg = new ClickableFormat(new KeywordReplacer(Utility.replaceColorCode(withoutPartMarkers(format)))); String stripped = Utility.stripColorCode(channelName); msg.replaceWithRunCommand("%channel%", channelName, diff --git a/src/test/java/com/github/ucchyocean/lc3/util/ClickableFormatTest.java b/src/test/java/com/github/ucchyocean/lc3/util/ClickableFormatTest.java index 6b7ff03..9cae156 100644 --- a/src/test/java/com/github/ucchyocean/lc3/util/ClickableFormatTest.java +++ b/src/test/java/com/github/ucchyocean/lc3/util/ClickableFormatTest.java @@ -121,6 +121,16 @@ public class ClickableFormatTest extends TestCase { assertNotNull(findByClickEvent(comps, ClickEvent.runCommand("/lunachat join r"))); } + public void testTemplateMarkersAreDropped() { + + ClickableFormat f = ClickableFormat.makeFormat("\uE0009\uE001%username: %msg", new ChannelMemberDummy()); + f.replaceMessage("%msg", "hello"); + Component comps = f.makeComponent(); + + assertEquals("9うっちぃ: hello", plain(comps)); + assertEquals(1, countClickEvents(comps)); + } + public void testChannelMessage() { Component comps = Messages.joinMessage("&b", "r", "ucchy");