From 5da1359682722420190e5b5cde339fe94c0c9674 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 3 Nov 2016 18:10:44 +0100 Subject: [PATCH] Fixes --- .../java/buttondevteam/lib/chat/TBMCChatAPI.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 54e69b3..b14da5c 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -101,15 +101,18 @@ public class TBMCChatAPI { * The command's class to create it (because why let you create the command class) */ public static void AddCommand(JavaPlugin plugin, Class thecmdclass, Object... params) { - plugin.getLogger().info("Registering command " + thecmdclass.getName() + " for " + plugin.getName()); + plugin.getLogger().info("Registering command " + thecmdclass.getSimpleName() + " for " + plugin.getName()); try { - TBMCCommandBase c = thecmdclass - .getConstructor(Arrays.stream(params).map(p -> p.getClass()).toArray(Class[]::new)) - .newInstance(params); + TBMCCommandBase c; + if (params.length > 0) + c = thecmdclass.getConstructor(Arrays.stream(params).map(p -> p.getClass()).toArray(Class[]::new)) + .newInstance(params); + else + c = thecmdclass.newInstance(); c.plugin = plugin; commands.put(c.GetCommandPath(), c); } catch (Exception e) { - TBMCCoreAPI.SendException("An error occured while registering command " + thecmdclass.getName(), e); + TBMCCoreAPI.SendException("An error occured while registering command " + thecmdclass.getSimpleName(), e); } }