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)
|
* 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) {
|
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 {
|
try {
|
||||||
TBMCCommandBase c = thecmdclass
|
TBMCCommandBase c;
|
||||||
.getConstructor(Arrays.stream(params).map(p -> p.getClass()).toArray(Class[]::new))
|
if (params.length > 0)
|
||||||
.newInstance(params);
|
c = thecmdclass.getConstructor(Arrays.stream(params).map(p -> p.getClass()).toArray(Class[]::new))
|
||||||
|
.newInstance(params);
|
||||||
|
else
|
||||||
|
c = thecmdclass.newInstance();
|
||||||
c.plugin = plugin;
|
c.plugin = plugin;
|
||||||
commands.put(c.GetCommandPath(), c);
|
commands.put(c.GetCommandPath(), c);
|
||||||
} catch (Exception e) {
|
} 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