So i'm messing around with Reflections in my API for a plugin system and its all working but once i have 2 jars using the same API it seems to use the same packages as shown below
[DiamondBank] and [UpdateNotifier] are two separate jars
[14:36:38] [Server thread/INFO]: com.cube.notifier
[14:36:38] [Server thread/INFO]: [UpdateNotifier] Registered 3 Commands.
[14:36:38] [Server thread/INFO]: package com.cube.notifier.commands
[14:36:38] [Server thread/INFO]: package com.cube.notifier.commands
[14:36:38] [Server thread/INFO]: package com.cube.notifier.commands
[14:36:39] [Server thread/INFO]: [DiamondBank] Enabling DiamondBank v1.1
[14:36:39] [Server thread/INFO]: [DiamondBank] Starting DiamondBank
[14:36:39] [Server thread/INFO]: [DiamondBank] Registered 2 Events.
[14:36:39] [Server thread/INFO]: org.cube.diamondbank
[14:36:42] [Server thread/INFO]: [DiamondBank] Registered 3 Commands.
[14:36:42] [Server thread/INFO]: package com.cube.notifier.commands
[14:36:42] [Server thread/INFO]: package com.cube.notifier.commands
[14:36:42] [Server thread/INFO]: package com.cube.notifier.commands
Now i tried to hardcode the path per plugin using a string but i get the same result but it prints out the correct location as seen above
This is my method that loads the commands
val config = ConfigurationBuilder()
.addScanners(
SubTypesScanner(false),
TypeAnnotationsScanner(),
MethodAnnotationsScanner()
)
.addUrls(MinecraftCommand::class.java.getResource(""))
println(packageName)
val reflection = Reflections(ClasspathHelper.forPackage(packageName),MethodAnnotationsScanner())
val cds = reflection.getMethodsAnnotatedWith(MinecraftCommand::class.java)
if(cds.size != 0) {
plugin.logger.info { "Registered ${cds.size} Commands." }
cds.forEach {
println(it.declaringClass.`package`.toString())
}
}
Any help would be Amazing thank you so much.
Aucun commentaire:
Enregistrer un commentaire