Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 53f4c7f

Browse files
committed
Reflections Testing
1 parent b3ac35b commit 53f4c7f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/java/com/redmagic/undefinedapi/extension/JavaPluginExtensions.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ package com.redmagic.undefinedapi.extension
22

33
import org.bukkit.plugin.java.JavaPlugin
44
import org.reflections.Reflections
5+
import org.reflections.scanners.FieldAnnotationsScanner
6+
import org.reflections.scanners.MethodAnnotationsScanner
57
import org.reflections.scanners.ResourcesScanner
68
import org.reflections.scanners.SubTypesScanner
9+
import org.reflections.scanners.TypeAnnotationsScanner
710
import org.reflections.util.ConfigurationBuilder
811
import java.lang.reflect.Method
912

@@ -14,9 +17,8 @@ import java.lang.reflect.Method
1417
* @return a set of classes annotated with the given annotation
1518
*/
1619
fun JavaPlugin.findClasses(annotation: Class<out Annotation>): Set<Class<*>> = Reflections(
17-
ConfigurationBuilder()
18-
.forPackages(this::class.java.packageName)
19-
.setScanners(SubTypesScanner(false), ResourcesScanner())
20+
this::class.java.packageName,
21+
TypeAnnotationsScanner()
2022
).getTypesAnnotatedWith(annotation)
2123

2224
/**
@@ -26,7 +28,6 @@ fun JavaPlugin.findClasses(annotation: Class<out Annotation>): Set<Class<*>> = R
2628
* @return a mutable set of methods annotated with the specified annotation
2729
*/
2830
fun JavaPlugin.findMethods(annotation: Class<out Annotation>): MutableSet<Method> = Reflections(
29-
ConfigurationBuilder()
30-
.forPackages(this::class.java.packageName)
31-
.setScanners(SubTypesScanner(false), ResourcesScanner())
31+
this::class.java.packageName,
32+
MethodAnnotationsScanner()
3233
).getMethodsAnnotatedWith(annotation)

0 commit comments

Comments
 (0)