From b2ad961e8d9d58aa1536a6102b757285b9784256 Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 24 Nov 2020 10:17:06 +0800 Subject: [PATCH] Check version on init for PluginDependency --- .../src/plugin/description/PluginDependency.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/mirai-console/src/plugin/description/PluginDependency.kt b/backend/mirai-console/src/plugin/description/PluginDependency.kt index 82b319c50..348b274fa 100644 --- a/backend/mirai-console/src/plugin/description/PluginDependency.kt +++ b/backend/mirai-console/src/plugin/description/PluginDependency.kt @@ -46,6 +46,7 @@ public data class PluginDependency @JvmOverloads constructor( init { kotlin.runCatching { PluginDescription.checkPluginId(id) + if (versionRequirement != null) SemVersion.parseRangeRequirement(versionRequirement) }.getOrElse { throw IllegalArgumentException(it) } @@ -63,7 +64,10 @@ public data class PluginDependency @JvmOverloads constructor( public override fun toString(): String = buildString { append(id) - versionRequirement?.let(::append) + versionRequirement?.let { + append(":") + append(it) + } if (isOptional) { append('?') }