got command functionality working

This commit is contained in:
Samuel Pizette
2022-12-10 16:08:01 -05:00
parent 8cccc67b0d
commit 4c2a8585cc
8 changed files with 75 additions and 34 deletions

View File

@@ -160,18 +160,18 @@ public interface Eco {
EcoPlugin getEcoPlugin();
@NotNull
PluginCommandBase createPluginCommand(@NotNull EcoPlugin plugin,
PluginCommandBase createPluginCommand(@NotNull CommandBase parentDelegate,
@NotNull EcoPlugin plugin,
@NotNull String name,
@NotNull String permission,
boolean playersOnly
);
boolean playersOnly);
@NotNull
CommandBase createSubCommand(@NotNull EcoPlugin plugin,
CommandBase createSubCommand(@NotNull CommandBase parentDelegate,
@NotNull EcoPlugin plugin,
@NotNull String name,
@NotNull String permission,
boolean playersOnly
);
boolean playersOnly);
/**
* Updatable config.

View File

@@ -50,6 +50,8 @@ public interface CommandBase {
@NotNull List<CommandBase> getSubcommands();
@NotNull CommandBase getWrapped();
/**
* Handle command execution.
*
@@ -59,6 +61,7 @@ public interface CommandBase {
default void onExecute(@NotNull CommandSender sender,
@NotNull List<String> args) throws NotificationException {
// Do nothing.
Bukkit.getLogger().info("Did this happen?");
}
/**

View File

@@ -37,7 +37,7 @@ public abstract class PluginCommand implements PluginCommandBase {
@NotNull final String name,
@NotNull final String permission,
final boolean playersOnly) {
this.delegate = Eco.get().createPluginCommand(plugin, name, permission, playersOnly);
this.delegate = Eco.get().createPluginCommand(this, plugin, name, permission, playersOnly);
}
@Override
@@ -65,6 +65,11 @@ public abstract class PluginCommand implements PluginCommandBase {
return delegate.getSubcommands();
}
@Override
public @NotNull CommandBase getWrapped() {
return this;
}
@Override
public void register() {
delegate.register();

View File

@@ -26,7 +26,7 @@ public abstract class Subcommand implements CommandBase {
@NotNull final String name,
@NotNull final String permission,
final boolean playersOnly) {
this.delegate = Eco.get().createSubCommand(plugin, name, permission, playersOnly);
this.delegate = Eco.get().createSubCommand(this, plugin, name, permission, playersOnly);
}
/**
@@ -67,6 +67,11 @@ public abstract class Subcommand implements CommandBase {
return delegate.getSubcommands();
}
@Override
public @NotNull CommandBase getWrapped() {
return this;
}
@Override
public EcoPlugin getPlugin() {
return delegate.getPlugin();