1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-04-14 23:20:49 +08:00

feat: check in load plugin

This commit is contained in:
cssxsh 2023-06-21 15:52:30 +08:00 committed by Karlatemp
parent eab15f9125
commit fb3b56da82
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59

View File

@ -287,7 +287,7 @@ internal class BuiltInJvmPluginLoaderImpl(
return filePlugins.toSet().map { it.second }
}
private val loadedPlugins = ConcurrentHashMap<JvmPlugin, Unit>()
private val loadedPlugins = ConcurrentHashMap<String, JvmPlugin>()
private fun Path.moveNameFolder(plugin: JvmPlugin) {
val nameFolder = this.resolve(plugin.description.name).toFile()
@ -324,8 +324,8 @@ internal class BuiltInJvmPluginLoaderImpl(
override fun load(plugin: JvmPlugin) {
ensureActive()
if (loadedPlugins.put(plugin, Unit) != null) {
error("Plugin '${plugin.name}' is already loaded and cannot be reloaded.")
if (loadedPlugins.put(plugin.id, plugin) != null) {
error("Plugin '${plugin.id}' is already loaded and cannot be reloaded.")
}
logger.verbose { "Loading plugin ${plugin.description.smartToString()}" }
runCatching {