Fix annotation processor choking on event subscribers

This commit is contained in:
Andrew Steinborn
2021-05-15 08:15:25 -04:00
parent 07f8980f82
commit 348ea4cc23
2 changed files with 3 additions and 2 deletions

View File

@@ -22,4 +22,5 @@ class AnnotationProcessorConstants {
static final String PLUGIN_ANNOTATION_CLASS = "com.velocitypowered.api.plugin.Plugin";
static final String SUBSCRIBE_ANNOTATION_CLASS = "com.velocitypowered.api.event.Subscribe";
static final String EVENTTASK_CLASS = "com.velocitypowered.api.event.EventTask";
static final String EVENT_INTERFACE= "com.velocitypowered.api.event.Event";
}

View File

@@ -18,6 +18,7 @@
package com.velocitypowered.annotationprocessor;
import static com.velocitypowered.annotationprocessor.AnnotationProcessorConstants.EVENTTASK_CLASS;
import static com.velocitypowered.annotationprocessor.AnnotationProcessorConstants.EVENT_INTERFACE;
import static com.velocitypowered.annotationprocessor.AnnotationProcessorConstants.PLUGIN_ANNOTATION_CLASS;
import static com.velocitypowered.annotationprocessor.AnnotationProcessorConstants.SUBSCRIBE_ANNOTATION_CLASS;
@@ -33,7 +34,6 @@ import java.util.Set;
import javax.annotation.Nullable;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
@@ -99,7 +99,7 @@ public class ApiAnnotationProcessor extends AbstractProcessor {
}
final List<? extends VariableElement> parameters = method.getParameters();
if (parameters.isEmpty()
|| !this.isTypeSubclass(parameters.get(0), SUBSCRIBE_ANNOTATION_CLASS)) {
|| !this.isTypeSubclass(parameters.get(0), EVENT_INTERFACE)) {
msg.printMessage(Diagnostic.Kind.ERROR,
"method must have an Event as its first parameter", method);
}