feat: made ICommand an abstract class instead of an interface

- ICommand now is BaseCommand
This commit is contained in:
AXOLOTsh
2026-08-18 03:55:20 +03:00
parent 6e49b2a0e5
commit 38f08fd0be
3 changed files with 14 additions and 12 deletions

View File

@@ -8,7 +8,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.axolotsh.pluginutils.dependency_injection.entities.ICommand;
import org.axolotsh.pluginutils.dependency_injection.entities.BaseCommand;
import org.axolotsh.pluginutils.dependency_injection.entities.IConfiguration;
import org.axolotsh.pluginutils.dependency_injection.entities.ITask;
import org.bukkit.Server;
@@ -44,7 +44,7 @@ public abstract class BaseJavaPlugin extends JavaPlugin {
protected Set<Listener> listeners;
@Inject
protected Set<ICommand> commands;
protected Set<BaseCommand> commands;
@Inject
protected Set<IConfiguration> configurations;
@@ -93,14 +93,14 @@ public abstract class BaseJavaPlugin extends JavaPlugin {
}
}
private Map<ICommand, Collection<ICommand>> mapSubcommands() {
Map<Class<? extends ICommand>, ICommand> commandsByClazz = commands.stream()
private Map<BaseCommand, Collection<BaseCommand>> mapSubcommands() {
Map<Class<? extends BaseCommand>, BaseCommand> commandsByClazz = commands.stream()
.collect(Collectors.toMap(
x -> x.getClass(),
cmd -> cmd,
(existing, replacement) -> existing));
Map<ICommand, Collection<ICommand>> result = new HashMap<>();
Map<BaseCommand, Collection<BaseCommand>> result = new HashMap<>();
for (var command : commands)
result.put(command, new HashSet<>());

View File

@@ -1,6 +1,6 @@
package org.axolotsh.pluginutils.dependency_injection;
import org.axolotsh.pluginutils.dependency_injection.entities.ICommand;
import org.axolotsh.pluginutils.dependency_injection.entities.BaseCommand;
import org.axolotsh.pluginutils.dependency_injection.entities.IConfiguration;
import org.axolotsh.pluginutils.dependency_injection.entities.ITask;
import org.bukkit.event.Listener;
@@ -13,8 +13,8 @@ public abstract class PluginModule extends AbstractModule {
return Multibinder.newSetBinder(binder(), Listener.class);
}
protected Multibinder<ICommand> createCommandsMultibinder() {
return Multibinder.newSetBinder(binder(), ICommand.class);
protected Multibinder<BaseCommand> createCommandsMultibinder() {
return Multibinder.newSetBinder(binder(), BaseCommand.class);
}
protected Multibinder<IConfiguration> createConfigurationMultibinder() {

View File

@@ -7,11 +7,13 @@ import org.jetbrains.annotations.Nullable;
import dev.jorel.commandapi.CommandAPICommand;
public interface ICommand {
public Collection<Permission> permissions();
public abstract class BaseCommand {
public abstract Collection<Permission> permissions();
public CommandAPICommand command();
public abstract CommandAPICommand command();
@Nullable
public Class<? extends ICommand> parentCommand();
public Class<? extends BaseCommand> parentCommand() {
return null;
}
}