Skip to content

Commit 0e56f5d

Browse files
committed
[AutoReloadExtensionPluginsModule] Support PlugManX v3
1 parent 8163f15 commit 0e56f5d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

bukkit/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ dependencies {
7171
compileOnly("net.neoforged:AutoRenamingTool:2.0.13")
7272

7373
compileOnly("com.rylinaux:PlugManX:2.4.1")
74+
compileOnly("com.rylinaux:plugman-bukkit:3.0.2") {
75+
exclude("com.tcoded", "FoliaLib")
76+
}
7477

7578
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.6.1")
7679
compileOnly("io.lumine:Mythic-Dist:5.8.0")

bukkit/src/main/kotlin/io/github/rothes/esu/bukkit/module/AutoReloadExtensionPluginsModule.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.rothes.esu.bukkit.module
22

3+
import bukkit.com.rylinaux.plugman.PlugManBukkit
34
import com.rylinaux.plugman.PlugMan
45
import io.github.rothes.esu.bukkit.inventory.EsuInvHolder
56
import io.github.rothes.esu.bukkit.module.AutoReloadExtensionPluginsModule.ModuleConfig
@@ -46,7 +47,13 @@ object AutoReloadExtensionPluginsModule: BukkitModule<ModuleConfig, EmptyConfigu
4647

4748
for (pl in data.pluginsToLoad) {
4849
try {
49-
PlugMan.getInstance().pluginUtil.load(pl)
50+
try {
51+
// PlugMan v2
52+
PlugMan.getInstance().pluginUtil.load(pl)
53+
} catch (_: NoClassDefFoundError) {
54+
// PlugManX v3
55+
PlugManBukkit.getInstance().pluginManager.load(pl)
56+
}
5057
} catch (e: Throwable) {
5158
plugin.err("Failed to load plugin $pl :", e)
5259
}
@@ -72,7 +79,14 @@ object AutoReloadExtensionPluginsModule: BukkitModule<ModuleConfig, EmptyConfigu
7279
if (da.depend.contains(otherName) || da.softDepend.contains(otherName)) -1 else 1
7380
}
7481
plugins.forEach {
75-
PlugMan.getInstance().pluginUtil.unload(it)
82+
try {
83+
// PlugMan v2
84+
PlugMan.getInstance().pluginUtil.unload(it)
85+
} catch (_: NoClassDefFoundError) {
86+
// PlugManX v3
87+
val manager = PlugManBukkit.getInstance().pluginManager
88+
manager.unload(manager.getPluginByName(it.name))
89+
}
7690
data.pluginsToLoad.add(it.name)
7791
}
7892
data.pluginsToLoad.reverse()

0 commit comments

Comments
 (0)