mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-16 16:20:04 +00:00
Fix bug where ExtensionFinder ignores disabled plugins
This commit is contained in:
@@ -12,7 +12,7 @@ interface GameCoverProps {
|
|||||||
export function GameCover({game, size = 300, radius = "sm", hover = false}: GameCoverProps) {
|
export function GameCover({game, size = 300, radius = "sm", hover = false}: GameCoverProps) {
|
||||||
return (
|
return (
|
||||||
Number.isInteger(game.coverId) ? (
|
Number.isInteger(game.coverId) ? (
|
||||||
<div className={`rounded-md ${hover ? "scale-95 hover:scale-100 shine transition-all" : ""}`}>
|
<div className={`${hover ? "rounded-md scale-95 hover:scale-100 shine transition-all" : ""}`}>
|
||||||
<Image
|
<Image
|
||||||
alt={game.title}
|
alt={game.title}
|
||||||
className="z-0 w-full h-full object-cover aspect-[12/17]"
|
className="z-0 w-full h-full object-cover aspect-[12/17]"
|
||||||
|
|||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
package de.grimsi.gameyfin.core.plugins.management
|
||||||
|
|
||||||
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||||
|
import org.pf4j.ExtensionDescriptor
|
||||||
|
import org.pf4j.ExtensionWrapper
|
||||||
|
import org.pf4j.LegacyExtensionFinder
|
||||||
|
import org.pf4j.PluginManager
|
||||||
|
|
||||||
|
class GameyfinExtensionFinder(pluginManager: PluginManager) : LegacyExtensionFinder(pluginManager) {
|
||||||
|
companion object {
|
||||||
|
private val log = KotlinLogging.logger { }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun find(pluginId: String?): MutableList<ExtensionWrapper<*>?> {
|
||||||
|
log.debug { "Finding extensions from plugin '$pluginId'" }
|
||||||
|
val result: MutableList<ExtensionWrapper<*>?> = ArrayList()
|
||||||
|
|
||||||
|
val classNames = findClassNames(pluginId)
|
||||||
|
if (classNames.isEmpty()) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pluginId != null) {
|
||||||
|
log.trace { "Checking extensions from plugin '$pluginId'" }
|
||||||
|
} else {
|
||||||
|
log.trace { "Checking extensions from classpath" }
|
||||||
|
}
|
||||||
|
|
||||||
|
val classLoader =
|
||||||
|
if (pluginId != null) pluginManager.getPluginClassLoader(pluginId) else javaClass.getClassLoader()
|
||||||
|
|
||||||
|
for (className in classNames) {
|
||||||
|
try {
|
||||||
|
log.debug { "Loading class '$className' using class loader '$classLoader'" }
|
||||||
|
val extensionClass = classLoader.loadClass(className)
|
||||||
|
|
||||||
|
val extensionWrapper: ExtensionWrapper<*> = createExtensionWrapper(extensionClass)
|
||||||
|
result.add(extensionWrapper)
|
||||||
|
log.debug { "Added extension '$className' with ordinal ${extensionWrapper.ordinal}" }
|
||||||
|
} catch (e: ClassNotFoundException) {
|
||||||
|
log.error(e) { e.message }
|
||||||
|
} catch (e: NoClassDefFoundError) {
|
||||||
|
log.error(e) { e.message }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.isEmpty()) {
|
||||||
|
log.debug { "No extensions found for plugin '$pluginId'" }
|
||||||
|
} else {
|
||||||
|
log.debug { "Found ${result.size} extensions for plugin '$pluginId'" }
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createExtensionWrapper(extensionClass: Class<*>): ExtensionWrapper<*> {
|
||||||
|
val extensionAnnotation = findExtensionAnnotation(extensionClass)
|
||||||
|
val ordinal = extensionAnnotation?.ordinal ?: 0
|
||||||
|
val descriptor = ExtensionDescriptor(ordinal, extensionClass)
|
||||||
|
|
||||||
|
return ExtensionWrapper<Any?>(descriptor, pluginManager.extensionFactory)
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -66,6 +66,12 @@ class GameyfinPluginManager(
|
|||||||
return GameyfinManifestPluginDescriptorFinder()
|
return GameyfinManifestPluginDescriptorFinder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun createExtensionFinder(): ExtensionFinder? {
|
||||||
|
val extensionFinder = GameyfinExtensionFinder(this)
|
||||||
|
addPluginStateListener(extensionFinder)
|
||||||
|
return extensionFinder
|
||||||
|
}
|
||||||
|
|
||||||
override fun loadPluginFromPath(pluginPath: Path?): PluginWrapper? {
|
override fun loadPluginFromPath(pluginPath: Path?): PluginWrapper? {
|
||||||
val pluginWrapper = try {
|
val pluginWrapper = try {
|
||||||
super.loadPluginFromPath(pluginPath)
|
super.loadPluginFromPath(pluginPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user