mirror of
https://github.com/AXOLOTsh/PluginUtils.git
synced 2026-09-29 15:48:33 +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) {
|
for (var command : commands) {
|
||||||
var clazzName = command.getClass().getName();
|
var clazzName = command.getClass().getName();
|
||||||
|
|
||||||
command.parentCommand().ifPresent(parentClazz -> {
|
var parentCommand = command.parentCommand();
|
||||||
var parent = commandsByClazz.get(parentClazz);
|
if (parentCommand != null) {
|
||||||
|
var parent = commandsByClazz.get(parentCommand);
|
||||||
|
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
logger.error("Parent command '{}' for command '{}' cannot be found.",
|
logger.error("Parent command '{}' for command '{}' cannot be found.",
|
||||||
parentClazz.getName(),
|
parentCommand.getName(),
|
||||||
clazzName);
|
clazzName);
|
||||||
} else
|
} else
|
||||||
result.get(parent).add(command);
|
result.get(parent).add(command);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package org.axolotsh.pluginutils.dependency_injection.entities;
|
package org.axolotsh.pluginutils.dependency_injection.entities;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import dev.jorel.commandapi.CommandAPICommand;
|
import dev.jorel.commandapi.CommandAPICommand;
|
||||||
|
|
||||||
@@ -12,5 +12,6 @@ public interface ICommand {
|
|||||||
|
|
||||||
public CommandAPICommand command();
|
public CommandAPICommand command();
|
||||||
|
|
||||||
public Optional<Class<ICommand>> parentCommand();
|
@Nullable
|
||||||
|
public Class<? extends ICommand> parentCommand();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user