Fixes
This commit is contained in:
parent
86d0125f34
commit
5da1359682
1 changed files with 8 additions and 5 deletions
|
@ -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<? extends TBMCCommandBase> 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))
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue