diff --git a/mc2discord-core/src/main/java/fr/denisd3d/mc2discord/core/M2DUtils.java b/mc2discord-core/src/main/java/fr/denisd3d/mc2discord/core/M2DUtils.java index f7dea4d..f6ab030 100644 --- a/mc2discord-core/src/main/java/fr/denisd3d/mc2discord/core/M2DUtils.java +++ b/mc2discord-core/src/main/java/fr/denisd3d/mc2discord/core/M2DUtils.java @@ -19,7 +19,7 @@ public class M2DUtils { public static final File CONFIG_FILE = new File("config", "mc2discord.toml"); public static final Snowflake NIL_SNOWFLAKE = Snowflake.of(0); - private static final Pattern ANY_DISCORD_MENTION_PATTERN = Pattern.compile("<(?::\\w+:|@&*|#)\\d+>"); + private static final Pattern ANY_DISCORD_MENTION_PATTERN = Pattern.compile("<(?:a?:\\w+:|@&*|#)\\d+>"); private static final Pattern ANY_DISCORD_NAMED_PATTERN = Pattern.compile("@\\w+|#\\w+|:\\w+:"); @@ -83,7 +83,7 @@ public static List breakStringInMessages(String input, int maxLineLength output.append(word); lineLen += word.length(); } - if (output.length() > 0) { + if (!output.isEmpty()) { if (surroundWithCodeBlock) { output.insert(0, "```"); output.append("```"); @@ -108,8 +108,8 @@ public static String replaceAllMentions(String str, List users, List while (matcher.find()) { String replacement = matcher.group(0); - if (replacement.matches("<(:\\w+:)\\d+>")) { // Emojis - matcher.appendReplacement(builder, Matcher.quoteReplacement(":" + replacement.split(":")[1] + ":")); + if (replacement.matches("")) { // Emojis + matcher.appendReplacement(builder, Matcher.quoteReplacement(":" + replacement.split(":")[1].toLowerCase() + ":")); } else if (replacement.matches("<@(\\d+)>")) { // Users users.stream().filter(partialMember -> partialMember.getId().asString().equals(replacement.substring(2, replacement.length() - 1))).findFirst().ifPresent(user -> matcher.appendReplacement(builder, Matcher.quoteReplacement("@" + user.getUsername()))); } else if (replacement.matches("<@&(\\d+)>")) { // Roles diff --git a/shared.properties b/shared.properties index eef91b1..f775bba 100644 --- a/shared.properties +++ b/shared.properties @@ -6,4 +6,3 @@ modDescription=Link your Minecraft chat with your Discord server modIssueTrackerUrl=https://github.com/DenisD3D/Mc2Discord/issues modUpdateJsonUrl=https://raw.githubusercontent.com/DenisD3D/Mc2Discord/main/update.json modDisplayUrl=https://www.curseforge.com/minecraft/mc-mods/mc2discord -discord4jVersion=3.3.0-M2 \ No newline at end of file