依赖版本重载
# 某某插件加载时报错,让我过来的
插件名的 adventure 相关库似乎出现了依赖冲突问题,请参考以下链接进行解决
https://plugins.mcio.dev/elopers/base/resolver-override
这个问题有可能会在低版本出现,简要解决方案如下:
- 创建配置文件:
plugins/插件名/.override-libraries.yml - 在下方 adventure x.x.x 章节选一份合适的配置,粘贴到上述配置中
- 重启服务器,使得插件加载并重新下载依赖
- 如果还是报错,换一份配置重试
- 如果配置都换完了还是报错,提供服务端信息、插件版本列表,向作者反馈相关问题
# 依赖版本重载
在这里存放用于 LibrariesResolver-Lite 的依赖版本重载配置,具体用法如下
// 在 resolver.doResolve() 之前读取并添加依赖位置重载配置
YamlConfiguration overrideLibraries = ConfigUtils.load(resolve("./.override-libraries.yml"));
for (String key : overrideLibraries.getKeys(false)) {
resolver.getStartsReplacer().put(key, overrideLibraries.getString(key));
}
resolver.addResolvedLibrary(BuildConstants.RESOLVED_LIBRARIES);
List<URL> libraries = resolver.doResolve();
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
因为有用户反馈,在特殊情况下,adventure 会跟其它插件冲突导致插件无法启用,但是我又无法复现这个问题。于是决定编写配置,允许用户修改依赖版本。
当出现依赖冲突时,从下面复制配置,添加到插件数据目录下的 .override-libraries.yml 中即可。
# 如何生成配置?
// build.gradle.kts
buildscript {
repositories.mavenCentral()
dependencies.classpath("top.mrxiaom:LibrariesResolver-Gradle:1.7.3")
}
val base = top.mrxiaom.gradle.LibraryHelper(project)
dependencies {
val adventure = "4.11.0" // adventure 版本
base.library("net.kyori:adventure-api:$adventure")
base.library("net.kyori:adventure-text-minimessage:$adventure")
// 最好要找一个适配当前 adventure 的 platform 支持
base.library("net.kyori:adventure-platform-bukkit:4.1.2")
// 下面还可以添加更多依赖
}
base.collectLibraries<String> { dep ->
val groupPath = dep.moduleGroup.replace('.', '/')
val key = "${groupPath}/${dep.moduleName}/"
val value = top.mrxiaom.gradle.LibraryHelper.defaultCollector().apply(dep)
if (value != null) "'$key': '$value'" else null
}.forEach(::println) // 打印到控制台,然后从控制台复制配置即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
请手动从结果中去除 annotations 等不必要依赖。
# adventure 4.11.0
'net/kyori/adventure-api/': 'net/kyori/adventure-api/4.11.0/adventure-api-4.11.0.jar'
'net/kyori/adventure-key/': 'net/kyori/adventure-key/4.11.0/adventure-key-4.11.0.jar'
'net/kyori/examination-string/': 'net/kyori/examination-string/1.3.0/examination-string-1.3.0.jar'
'net/kyori/examination-api/': 'net/kyori/examination-api/1.3.0/examination-api-1.3.0.jar'
'net/kyori/adventure-text-minimessage/': 'net/kyori/adventure-text-minimessage/4.11.0/adventure-text-minimessage-4.11.0.jar'
'net/kyori/adventure-text-serializer-gson-legacy-impl/': 'net/kyori/adventure-text-serializer-gson-legacy-impl/4.11.0/adventure-text-serializer-gson-legacy-impl-4.11.0.jar'
'net/kyori/adventure-text-serializer-bungeecord/': 'net/kyori/adventure-text-serializer-bungeecord/4.1.2/adventure-text-serializer-bungeecord-4.1.2.jar'
'net/kyori/adventure-text-serializer-gson/': 'net/kyori/adventure-text-serializer-gson/4.11.0/adventure-text-serializer-gson-4.11.0.jar'
'net/kyori/adventure-text-serializer-legacy/': 'net/kyori/adventure-text-serializer-legacy/4.11.0/adventure-text-serializer-legacy-4.11.0.jar'
'net/kyori/adventure-nbt/': 'net/kyori/adventure-nbt/4.11.0/adventure-nbt-4.11.0.jar'
'net/kyori/adventure-platform-api/': 'net/kyori/adventure-platform-api/4.1.2/adventure-platform-api-4.1.2.jar'
'net/kyori/adventure-platform-facet/': 'net/kyori/adventure-platform-facet/4.1.2/adventure-platform-facet-4.1.2.jar'
'net/kyori/adventure-platform-bukkit/': 'net/kyori/adventure-platform-bukkit/4.1.2/adventure-platform-bukkit-4.1.2.jar'
'net/kyori/adventure-platform-viaversion/': 'net/kyori/adventure-platform-viaversion/4.1.2/adventure-platform-viaversion-4.1.2.jar'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# adventure 4.17.0
'net/kyori/adventure-api/': 'net/kyori/adventure-api/4.17.0/adventure-api-4.17.0.jar'
'net/kyori/adventure-key/': 'net/kyori/adventure-key/4.17.0/adventure-key-4.17.0.jar'
'net/kyori/examination-string/': 'net/kyori/examination-string/1.3.0/examination-string-1.3.0.jar'
'net/kyori/examination-api/': 'net/kyori/examination-api/1.3.0/examination-api-1.3.0.jar'
'net/kyori/adventure-text-minimessage/': 'net/kyori/adventure-text-minimessage/4.17.0/adventure-text-minimessage-4.17.0.jar'
1
2
3
4
5
2
3
4
5
上次更新: 2026/01/24, 15:12:56