mirror of
https://github.com/AXOLOTsh/PluginUtils.git
synced 2026-09-21 03:46:23 +03:00
fix: strict parent command class in ICommand interface
This commit is contained in:
@@ -107,16 +107,17 @@ public abstract class BaseJavaPlugin extends JavaPlugin {
|
||||
for (var command : commands) {
|
||||
var clazzName = command.getClass().getName();
|
||||
|
||||
command.parentCommand().ifPresent(parentClazz -> {
|
||||
var parent = commandsByClazz.get(parentClazz);
|
||||
var parentCommand = command.parentCommand();
|
||||
if (parentCommand != null) {
|
||||
var parent = commandsByClazz.get(parentCommand);
|
||||
|
||||
if (parent == null) {
|
||||
logger.error("Parent command '{}' for command '{}' cannot be found.",
|
||||
parentClazz.getName(),
|
||||
parentCommand.getName(),
|
||||
clazzName);
|
||||
} else
|
||||
result.get(parent).add(command);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.axolotsh.pluginutils.dependency_injection.entities;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
@@ -12,5 +12,6 @@ public interface ICommand {
|
||||
|
||||
public CommandAPICommand command();
|
||||
|
||||
public Optional<Class<ICommand>> parentCommand();
|
||||
@Nullable
|
||||
public Class<? extends ICommand> parentCommand();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user