More API work for modules

This commit is contained in:
2026-05-19 21:23:56 -04:00
parent cf15f33496
commit 2543c7f19e
6 changed files with 416 additions and 0 deletions
@@ -4,6 +4,7 @@ import dev.plex.Plex;
import dev.plex.api.command.CommandApi;
import dev.plex.command.PlexCommand;
import dev.plex.util.PlexLog;
import java.util.List;
final class DefaultCommandApi implements CommandApi
{
@@ -14,6 +15,7 @@ final class DefaultCommandApi implements CommandApi
@Override
public void register(PlexCommand command)
{
command.bindApi(plugin.getApi());
if (plugin.getCommandHandler() == null)
{
plugin.getPendingCommands().add(command);
@@ -32,6 +34,16 @@ final class DefaultCommandApi implements CommandApi
}
}
@Override
public List<PlexCommand> registeredCommands()
{
if (plugin.getCommandHandler() == null)
{
return List.copyOf(plugin.getPendingCommands());
}
return plugin.getCommandHandler().getCommands();
}
@Override
public boolean requiresLifecycleReload()
{
@@ -50,6 +50,11 @@ public class CommandHandler
return lifecycleReloadRequired;
}
public List<PlexCommand> getCommands()
{
return List.copyOf(commands);
}
public @Nullable PlexCommand getCommand(String name)
{
String normalized = name.toLowerCase(Locale.ROOT);