From ee0d746a0446cf7e0c681bb30dbbedc76153c696 Mon Sep 17 00:00:00 2001 From: Pingex Date: Sat, 7 May 2016 21:47:07 +0200 Subject: [PATCH] No longer spams the log when rebuilding commands list. --- .../net/pingex/discordbot/CommandDispatcher.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pingex/discordbot/CommandDispatcher.java b/src/main/java/net/pingex/discordbot/CommandDispatcher.java index 66d91d3..abcd4dd 100644 --- a/src/main/java/net/pingex/discordbot/CommandDispatcher.java +++ b/src/main/java/net/pingex/discordbot/CommandDispatcher.java @@ -184,18 +184,21 @@ class CommandDispatcher commandList = new TreeMap<>(); shortList = new TreeMap<>(); + int count = 0; + int invalidCount = 0; + for(AbstractModule i : registry) if(i.getClass().isAnnotationPresent(Controllable.class)) for(Method j : i.getClass().getDeclaredMethods()) if(j.isAnnotationPresent(Command.class)) { String id = i.getClass().getAnnotation(Controllable.class).name() + ":" + j.getName().toLowerCase(); - logger.info("Found " + id); if(j.getParameterCount() >= 1 && j.getParameterTypes()[0] == MessageReceivedEvent.class && j.getReturnType() == String.class) if(!commandList.containsKey(id)) { commandList.put(id, new InvokableMethod(j, i)); + count++; // Eventual command shorthands if(!j.getAnnotation(Command.class).shorthand().isEmpty()) @@ -205,11 +208,18 @@ class CommandDispatcher logger.warning("Conflicting shorthand for command " + id); } else + { logger.warning("Conflicting command " + id); + invalidCount++; + } else + { logger.warning("Command [" + id + "]: incorrect function prototype, thus won't be added to the command list."); + invalidCount++; + } } + logger.info("Found " + count + " valid commands and " + invalidCount + " invalid commands."); logger.info("... Done"); }