Skip to content

Commit 6540cbc

Browse files
authored
Merge pull request #1010 from lavalink-devs/dev
release 4.0.3
2 parents 3a20917 + fc80fd8 commit 6540cbc

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

LavalinkServer/src/main/java/lavalink/server/Launcher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ object Launcher {
143143
.properties(properties)
144144
.web(WebApplicationType.SERVLET)
145145
.bannerMode(Banner.Mode.OFF)
146-
.resourceLoader(DefaultResourceLoader(pluginManager::class.java.classLoader))
146+
.resourceLoader(DefaultResourceLoader(pluginManager.classLoader))
147147
.listeners(
148148
ApplicationListener { event: Any ->
149149
when (event) {

LavalinkServer/src/main/java/lavalink/server/bootstrap/PluginManager.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ class PluginManager(val config: PluginsConfig) {
2121

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

24+
var classLoader = javaClass.classLoader
25+
2426
init {
2527
manageDownloads()
28+
2629
pluginManifests.apply {
2730
addAll(readClasspathManifests())
2831
addAll(loadJars())
@@ -57,7 +60,9 @@ class PluginManager(val config: PluginsConfig) {
5760
}.distinctBy { "${it.group}:${it.name}" }
5861

5962
for (declaration in declarations) {
60-
val jars = pluginJars.filter { it.manifest.name == declaration.name }
63+
val jars = pluginJars.filter { it.manifest.name == declaration.name }.takeIf { it.isNotEmpty() }
64+
?: pluginJars.filter { matchName(it, declaration.name) }
65+
6166
var hasCurrentVersion = false
6267

6368
for (jar in jars) {
@@ -104,15 +109,15 @@ class PluginManager(val config: PluginsConfig) {
104109
?.takeIf { it.isNotEmpty() }
105110
?: return emptyList()
106111

107-
val classLoader = URLClassLoader.newInstance(
112+
classLoader = URLClassLoader.newInstance(
108113
jarsToLoad.map { URL("jar:file:${it.absolutePath}!/") }.toTypedArray(),
109114
javaClass.classLoader
110115
)
111116

112117
return jarsToLoad.flatMap { loadJar(it, classLoader) }
113118
}
114119

115-
private fun loadJar(file: File, cl: URLClassLoader): List<PluginManifest> {
120+
private fun loadJar(file: File, cl: ClassLoader): List<PluginManifest> {
116121
val jar = JarFile(file)
117122
val manifests = loadPluginManifests(jar)
118123
var classCount = 0
@@ -156,6 +161,18 @@ class PluginManager(val config: PluginsConfig) {
156161
return PluginManifest(name, path, version)
157162
}
158163

164+
private fun matchName(jar: PluginJar, name: String): Boolean {
165+
// removeSuffix removes names ending with "-v", such as -v1.0.0
166+
// and then the subsequent removeSuffix call removes trailing "-", which
167+
// usually precedes a version number, such as my-plugin-1.0.0.
168+
// We strip these to produce the name of the jar's file.
169+
val jarName = jar.file.nameWithoutExtension.takeWhile { !it.isDigit() }
170+
.removeSuffix("-v")
171+
.removeSuffix("-")
172+
173+
return name == jarName
174+
}
175+
159176
private data class PluginJar(val manifest: PluginManifest, val file: File)
160177
private data class Declaration(val group: String, val name: String, val version: String, val repository: String) {
161178
val canonicalJarName = "$name-$version.jar"

docs/plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ for instructions.
1818
| [LavaSrc plugin](https://github.com/topi314/LavaSrc) | Spotify, Apple Music & Deezer(native play) support |
1919
| [LavaSearch plugin](https://github.com/topi314/LavaSearch) | Advanced search functionality including playlists, albums, artists, tracks & terms |
2020
| [DuncteBot plugin](https://github.com/DuncteBot/skybot-lavalink-plugin) | Additional source managers that are not widely used |
21-
| [Extra Filter plugin](https://github.com/rohank05/lavalink-filter-plugin) | Additional audio filters for lavalink |
2221
| [XM plugin](https://github.com/esmBot/lava-xm-plugin) | Support for various [music tracker module](https://en.wikipedia.org/wiki/Module_file) formats |
2322
| [Lyrics.kt plugin](https://github.com/DRSchlaubi/lyrics.kt) | Plugin that fetches timestamped lyrics from YouTube |
2423
| [Java Timed Lyrics](https://github.com/DuncteBot/java-timed-lyrics) | Timestamped lyrics from YouTube with Genius fallback, supports IP-rotation |
24+
| [LavaDSPX Audio Filters](https://github.com/Devoxin/LavaDSPX-Plugin) | Additional audio filters for Lavalink |
2525

2626
If you want to make your own plugin see [here](api/plugins.md)

0 commit comments

Comments
 (0)