Skip to content

Commit

Permalink
fix: actually registering plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Feb 6, 2024
1 parent c81107a commit 2f010c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LavalinkServer/src/main/java/lavalink/server/Launcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ object Launcher {
.properties(properties)
.web(WebApplicationType.SERVLET)
.bannerMode(Banner.Mode.OFF)
.resourceLoader(DefaultResourceLoader(pluginManager::class.java.classLoader))
.resourceLoader(DefaultResourceLoader(pluginManager.classLoader))
.listeners(
ApplicationListener { event: Any ->
when (event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ class PluginManager(val config: PluginsConfig) {

final val pluginManifests: MutableList<PluginManifest> = mutableListOf()

var classLoader = javaClass.classLoader

init {
manageDownloads()

pluginManifests.apply {
addAll(readClasspathManifests())
addAll(loadJars())
}

println(pluginManifests)
}

private fun manageDownloads() {
Expand Down Expand Up @@ -104,12 +109,12 @@ class PluginManager(val config: PluginsConfig) {
?.takeIf { it.isNotEmpty() }
?: return emptyList()

val classLoader = URLClassLoader.newInstance(
classLoader = URLClassLoader.newInstance(
jarsToLoad.map { URL("jar:file:${it.absolutePath}!/") }.toTypedArray(),
javaClass.classLoader
)

return jarsToLoad.flatMap { loadJar(it, classLoader) }
return jarsToLoad.flatMap { loadJar(it, classLoader as URLClassLoader) }
}

private fun loadJar(file: File, cl: URLClassLoader): List<PluginManifest> {
Expand Down

0 comments on commit 2f010c5

Please sign in to comment.