Prevent all commands from being loaded

This commit is contained in:
Focusvity 2022-03-19 15:17:43 +11:00
parent 172080576c
commit d669da9f28
No known key found for this signature in database
GPG Key ID: 85AD157561ABE94B
3 changed files with 18 additions and 6 deletions

View File

@ -3,5 +3,7 @@ package dev.plex.command.annotation;
public @interface System
{
String value();
String value() default "";
boolean debug() default false;
}

View File

@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <redis-reset <player> | gamerules>")
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
@System("debug")
@System(debug = true)
public class DebugCMD extends PlexCommand
{
@Override

View File

@ -22,13 +22,23 @@ public class CommandHandler extends PlexBase
try
{
System annotation = clazz.getDeclaredAnnotation(System.class);
if (annotation != null && annotation.value().equalsIgnoreCase(plugin.getSystem()))
if (annotation != null)
{
if (annotation.value().equalsIgnoreCase(plugin.getSystem()))
{
commands.add(clazz.getConstructor().newInstance());
return;
}
if (plugin.config.getBoolean("debug") && annotation.debug())
{
commands.add(clazz.getConstructor().newInstance());
}
}
else
{
commands.add(clazz.getConstructor().newInstance());
return;
}
commands.add(clazz.getConstructor().newInstance());
}
catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException ex)
{