diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java index 05155cec..484d6016 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java @@ -13,6 +13,8 @@ import java.util.Objects; import java.util.SplittableRandom; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.security.auth.login.LoginException; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.admin.Admin; @@ -60,6 +62,7 @@ public class Discord extends FreedomService public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR; public List> sentMessages = new ArrayList<>(); public Boolean enabled = false; + private final Pattern DISCORD_MENTION_PATTERN = Pattern.compile("(<@!?([0-9]{16,20})>)"); public static String getMD5(String string) { @@ -408,6 +411,15 @@ public class Discord extends FreedomService message = StringUtils.remove(message, "§"); } + + Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message); + + while (DISCORD_MENTION_MATCHER.find()) + { + String mention = DISCORD_MENTION_MATCHER.group(1); + message = message.replace(mention, mention.replace("@","")); + } + if (enabled && !chat_channel_id.isEmpty()) { CompletableFuture sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true); @@ -433,6 +445,15 @@ public class Discord extends FreedomService message = StringUtils.remove(message, "§"); } + + Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message); + + while (DISCORD_MENTION_MATCHER.find()) + { + String mention = DISCORD_MENTION_MATCHER.group(1); + message = message.replace(mention, mention.replace("@","")); + } + if (enabled && !chat_channel_id.isEmpty()) { CompletableFuture sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index b6e5390f..7db66b08 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -72,10 +72,10 @@ public class FUtil "c8e5af82-6aba-4dd7-83e8-474381380cc9", // Paldiu "38ea7c82-7bdc-4f48-b7fd-0e93fc26813d", // AwesomePinch "ba5aafba-9012-418f-9819-a7020d591068", // TFTWPhoenix - "b051abdf-66d1-48c0-96ef-67fb8af96f2a", // Abhi + "d6dd9740-40db-45f5-ab16-4ee16a633009", // Abhi "2e06e049-24c8-42e4-8bcf-d35372af31e6" // unsuperiordev ); - public static final List DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix","Spigot_Abhiram", "unsuperiordev"); + public static final List DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix","abhithedev", "unsuperiordev"); public static final Map CHAT_COLOR_NAMES = new HashMap<>(); public static final List CHAT_COLOR_POOL = Arrays.asList( ChatColor.DARK_RED,