Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ public void init(ProcessingEnvironment processingEnv) {
this.processingEnv = processingEnv;
var elements = processingEnv.getElementUtils();
var types = processingEnv.getTypeUtils();
EventTypes.inheritableEvent = elements.getTypeElement(InheritableEvent.class.getCanonicalName()).asType();
try {
EventTypes.inheritableEvent = elements.getTypeElement(InheritableEvent.class.getCanonicalName()).asType();
} catch (NullPointerException|NoClassDefFoundError e) {
initError(e);
}
EventTypes.recordEvent = elements.getTypeElement(RecordEvent.class.getCanonicalName()).asType();
EventTypes.mutableEvent = elements.getTypeElement(MutableEvent.class.getCanonicalName()).asType();
EventCharacteristics.cancellable = elements.getTypeElement(Cancellable.class.getCanonicalName()).asType();
Expand All @@ -84,4 +88,14 @@ public void init(ProcessingEnvironment processingEnv) {
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
return List.of();
}

private static void initError(Throwable e) {
throw new IllegalStateException("""
Failed to setup the EventBus validator annotation processor as unable to get the compiler type elements required for validating EventBus API usages.
Possible solutions:
- Ensure that EventBus is on the compile classpath/modulepath and that its version matches the validator version
- Remove the EventBus validator annotation processor if you are not using EventBus in your project
- Add `requires net.minecraftforge.eventbus` to your module-info.java if you are using Java modules
""", e);
}
}