Add missing retention policy to annotation classes

This commit is contained in:
Focusvity 2022-04-02 12:46:04 +11:00
parent 90cccb804a
commit 099680d068
No known key found for this signature in database
GPG Key ID: 85AD157561ABE94B
4 changed files with 14 additions and 6 deletions

View File

@ -1,5 +1,9 @@
package dev.plex.command.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface System
{
String value() default "";

View File

@ -21,10 +21,9 @@ public class CommandHandler extends PlexBase
{
try
{
System annotation = clazz.getDeclaredAnnotation(System.class);
// TODO: Annotations are always null?
if (annotation != null)
if (clazz.isAnnotationPresent(System.class))
{
System annotation = clazz.getDeclaredAnnotation(System.class);
PlexLog.debug(clazz.getName() + " has annotations");
if (annotation.value().equalsIgnoreCase(plugin.getSystem().toLowerCase()))
{
@ -41,7 +40,6 @@ public class CommandHandler extends PlexBase
else
{
commands.add(clazz.getConstructor().newInstance());
// PlexLog.debug("Adding command normally " + clazz.getName());
}
}
catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException ex)

View File

@ -21,12 +21,14 @@ public class ListenerHandler extends PlexBase
{
try
{
Toggleable annotation = clazz.getDeclaredAnnotation(Toggleable.class);
if (annotation != null)
if (clazz.isAnnotationPresent(Toggleable.class))
{
Toggleable annotation = clazz.getDeclaredAnnotation(Toggleable.class);
PlexLog.debug(clazz.getName() + " has annotations");
if (plugin.config.get(annotation.value()) != null && plugin.config.getBoolean(annotation.value()))
{
listeners.add(clazz.getConstructor().newInstance());
PlexLog.debug("Registering " + clazz.getName() + " as a listener");
}
}
else

View File

@ -1,5 +1,9 @@
package dev.plex.listener.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Toggleable
{
String value();