diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index adf8f9b..12ef189 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -21,13 +21,13 @@ dependencies { testRuntimeOnly("org.junit.platform:junit-platform-launcher") implementation(libs.log4j) - + implementation(libs.geantyref) } // Apply a specific Java toolchain to ease working on different environments. java { toolchain { - languageVersion = JavaLanguageVersion.of(21) + languageVersion = JavaLanguageVersion.of(23) } } diff --git a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java index 59a643e..370419e 100644 --- a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java +++ b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionCheckRegistry.java @@ -1,11 +1,12 @@ package net.tomatentum.marinara.registry; -import java.lang.annotation.Annotation; -import java.lang.reflect.TypeVariable; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import io.leangen.geantyref.GenericTypeReflector; import net.tomatentum.marinara.checks.InteractionCheck; public class InteractionCheckRegistry { @@ -20,10 +21,11 @@ public class InteractionCheckRegistry { checks.add(check); } - public Optional> getCheckFromAnnotation(Class annotation) { + public Optional> getCheckFromAnnotation(Type annotation) { for (InteractionCheck interactionCheck : checks) { - TypeVariable type = interactionCheck.getClass().getTypeParameters()[0]; - if (type.getClass().equals(annotation.getClass())) + ParameterizedType type = (ParameterizedType) GenericTypeReflector.getExactSuperType(interactionCheck.getClass(), InteractionCheck.class); + Type typeParam = type.getActualTypeArguments()[0]; + if (typeParam.equals(annotation)) return Optional.of(interactionCheck); } return Optional.empty(); diff --git a/wrapper/javacord/build.gradle.kts b/wrapper/javacord/build.gradle.kts index 9ec7322..2d1e7c7 100644 --- a/wrapper/javacord/build.gradle.kts +++ b/wrapper/javacord/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { // Apply a specific Java toolchain to ease working on different environments. java { toolchain { - languageVersion = JavaLanguageVersion.of(21) + languageVersion = JavaLanguageVersion.of(23) } }