From d49198fd4ffe7de3f8b64c54bbfe422e3f317447 Mon Sep 17 00:00:00 2001 From: "Tobias Burdow [Kaleidox]" Date: Wed, 25 Oct 2023 16:08:05 +0200 Subject: [PATCH] wrap the unicode lib it seems to be broken, related to #42 --- .../mcsd/core/module/discord/DiscordModule.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/main/java/org/comroid/mcsd/core/module/discord/DiscordModule.java b/src/core/main/java/org/comroid/mcsd/core/module/discord/DiscordModule.java index 408a991c..bbd84910 100644 --- a/src/core/main/java/org/comroid/mcsd/core/module/discord/DiscordModule.java +++ b/src/core/main/java/org/comroid/mcsd/core/module/discord/DiscordModule.java @@ -11,6 +11,7 @@ import org.comroid.api.Component; import org.comroid.api.Polyfill; import org.comroid.api.SupplierX; +import org.comroid.api.ThrowingSupplier; import org.comroid.mcsd.core.entity.Server; import org.comroid.mcsd.core.entity.User; import org.comroid.mcsd.core.model.DiscordMessageSource; @@ -92,14 +93,13 @@ public DiscordModule(Server parent) { String str = msg.toString(); str = EmojiPattern.matcher(str).replaceAll(match -> { var name = match.group(1); - if (EmojiUtils.isEmoji(name)) - return EmojiUtils.getEmoji(name).getEmoji(); - else { - var results = adapter.getJda().getEmojisByName(name, true); - return SupplierX.ofStream(results.stream()) - .map(CustomEmoji::getAsMention) - .orElse(""); - } + var emoji = ThrowingSupplier.fallback(()->EmojiUtils.getEmoji(name),$->null).get(); + if (emoji != null) + return emoji.getEmoji(); + var results = adapter.getJda().getEmojisByName(name, true); + return SupplierX.ofStream(results.stream()) + .map(CustomEmoji::getAsMention) + .orElse(""); }); return new DiscordMessageSource(str) .setDisplayUser(player.getDisplayUser(User.DisplayUser.Type.Discord, User.DisplayUser.Type.Minecraft)