Skip to content

Commit

Permalink
fix: Add more logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Jan 24, 2025
1 parent a893633 commit 9aab005
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/de/presti/ree6/commands/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ public void addCommand(ICommand command) throws CommandInitializerException {

if (!commands.contains(command)) {
commands.add(command);
log.info("Loaded Command {}", command.getClass().getSimpleName());

Command commandAnnotation = command.getClass().getAnnotation(Command.class);

Expand All @@ -360,6 +361,8 @@ public void addCommand(ICommand command) throws CommandInitializerException {

SettingsManager.getSettings().add(new Setting(-1,
"command_" + commandAnnotation.name().toLowerCase(), commandAnnotation.name(), true));
} else {
throw new CommandInitializerException(command.getClass());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CommandInitializerException extends ObjectStreamException {
* @param commandClass the class.
*/
public CommandInitializerException(Class<?> commandClass) {
this(commandClass != null ? commandClass.getName() : "Null!", commandClass == null ? "Class is null!" : Arrays.stream(commandClass.getInterfaces()).noneMatch(classname -> classname.isInstance(ICommand.class)) ? "Does not implement the ICommand Interface." : !commandClass.isAnnotationPresent(Command.class) ? "Command Annotation is not present." : commandClass.getAnnotation(Command.class).category() == null ? "It is not allowed to use NULL as Category!" : "Unknown Error!");
this(commandClass != null ? commandClass.getName() : "Null!", commandClass == null ? "Class is null!" : Arrays.stream(commandClass.getInterfaces()).noneMatch(classname -> classname.isInstance(ICommand.class)) ? "Does not implement the ICommand Interface." : !commandClass.isAnnotationPresent(Command.class) ? "Command Annotation is not present." : commandClass.getAnnotation(Command.class).category() == null ? "It is not allowed to use NULL as Category!" : "Already registered or unknown!");
}

/**
Expand Down

0 comments on commit 9aab005

Please sign in to comment.