diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java index bd8d849d..81519493 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java @@ -58,9 +58,8 @@ public class DiscordToMinecraftListener extends ListenerAdapter final Message msg = event.getMessage(); final String content = msg.getContentStripped(); - if (content.startsWith(ConfigEntry.DISCORD_PREFIX.getString())) + if (content.startsWith(ConfigEntry.DISCORD_PREFIX.getString()) && Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel)) { - Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel); return; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandManager.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandManager.java index 55e52ca6..1426444b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandManager.java @@ -46,11 +46,21 @@ public class DiscordCommandManager FLog.info("Loaded " + commands.size() + " Discord commands."); } - public void parse(String content, Member member, TextChannel channel) + public boolean parse(String content, Member member, TextChannel channel) { List args = new ArrayList<>(Arrays.asList(content.split(" "))); + if (args.isEmpty()) + { + return false; + } - final String alias = args.remove(0).split(PREFIX)[1]; // The joys of command parsing + final String[] aliasParts = args.remove(0).split(PREFIX); + if (aliasParts.length < 2) + { + return false; + } + + final String alias = aliasParts[1]; for (DiscordCommand command : commands) { @@ -63,6 +73,7 @@ public class DiscordCommandManager final CompletableFuture futureMessage = channel.sendMessage(message).submit(true); this.discord.sentMessages.add(futureMessage); + return true; } else { @@ -77,8 +88,11 @@ public class DiscordCommandManager final CompletableFuture futureMessage = channel.sendMessage(message).submit(true); this.discord.sentMessages.add(futureMessage); + return true; } } } + + return false; } }