mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Catch IAE when registering duplicate ESSXD message types
This commit is contained in:
1 parent
179d5b0c76
commit
129bdc3f24
1 file changed
+9
-2
@@ -40,6 +40,7 @@ public final class DiscordMessageListener implements Listener {
|
|||||||
private final CarbonChat carbonChat;
|
private final CarbonChat carbonChat;
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private final Map<Key, MessageType> channelMessageTypes = new HashMap<>();
|
private final Map<Key, MessageType> channelMessageTypes = new HashMap<>();
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DiscordMessageListener(
|
private DiscordMessageListener(
|
||||||
@@ -49,7 +50,9 @@ public final class DiscordMessageListener implements Listener {
|
|||||||
) {
|
) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.carbonChat = carbonChat;
|
this.carbonChat = carbonChat;
|
||||||
logger.info("EssentialsXDiscord found! Enabling hook.");
|
this.logger = logger;
|
||||||
|
|
||||||
|
this.logger.info("EssentialsXDiscord found! Enabling hook.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minecraft -> Discord
|
// Minecraft -> Discord
|
||||||
@@ -82,7 +85,11 @@ public final class DiscordMessageListener implements Listener {
|
|||||||
if (discord != null) {
|
if (discord != null) {
|
||||||
this.carbonChat.channelRegistry().allKeys(key -> {
|
this.carbonChat.channelRegistry().allKeys(key -> {
|
||||||
final MessageType channelMessageType = new MessageType(key.value());
|
final MessageType channelMessageType = new MessageType(key.value());
|
||||||
discord.registerMessageType(this.plugin, channelMessageType);
|
try {
|
||||||
|
discord.registerMessageType(this.plugin, channelMessageType);
|
||||||
|
} catch (final IllegalArgumentException exception) {
|
||||||
|
this.logger.info("Skipping registration of message type [" + channelMessageType + "]");
|
||||||
|
}
|
||||||
this.channelMessageTypes.put(key, channelMessageType);
|
this.channelMessageTypes.put(key, channelMessageType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user