Make addCommand method accessible to inherited classes

This commit is contained in:
Steven Tracey 2022-06-22 22:08:03 -04:00
parent 07db7b7abd
commit 2b29cd535b
3 changed files with 3 additions and 6 deletions

View File

@ -8,7 +8,7 @@ plugins {
mainClassName = 'net.nevet5gi.buzzbot.Bot'
group 'net.nevet5gi'
version '0.5.1'
version '0.5.2'
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

View File

@ -19,6 +19,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
//TODO Make reload command for modules
public class CommandManager {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandManager.class);
protected final List<ICommand> commands = new ArrayList<>();
@ -40,7 +41,7 @@ public class CommandManager {
//addCommand(new CommandClass());
}
private void addCommand(ICmdGeneric cmd) {
protected void addCommand(ICmdGeneric cmd) {
boolean nameFound = commands.stream().anyMatch(it -> it.getName().equalsIgnoreCase(cmd.getName()));
if (nameFound) {
throw new IllegalArgumentException("A command with this name is already present");

View File

@ -55,10 +55,6 @@ public class ModuleLoader {
URLClassLoader urlClassLoader = URLClassLoader.newInstance(urls);
if (urlClassLoader == null) {
System.out.println("Classloader is null");
}
Class<?> mainClass = Class.forName(className, true, urlClassLoader);
BuzzyModule newModule = (BuzzyModule) mainClass.getDeclaredConstructor().newInstance();
newModule.onPreEnable();