mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Fix description checking
This commit is contained in:
parent
3b9414dc50
commit
9b3e96e3d3
@ -115,7 +115,7 @@ public interface PluginDescription {
|
|||||||
*
|
*
|
||||||
* @see PluginDescription.id
|
* @see PluginDescription.id
|
||||||
*/
|
*/
|
||||||
public val ID_REGEX: Regex = Regex("""([a-zA-Z]+[a-zA-Z0-9]*)\.([a-zA-Z]+[a-zA-Z0-9]*)""")
|
public val ID_REGEX: Regex = Regex("""([a-zA-Z]+(?:\.[a-zA-Z0-9]+)*)\.([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)""")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在 [PluginDescription.id] 和 [PluginDescription.name] 中禁止用的完全匹配名称列表.
|
* 在 [PluginDescription.id] 和 [PluginDescription.name] 中禁止用的完全匹配名称列表.
|
||||||
@ -137,7 +137,7 @@ public interface PluginDescription {
|
|||||||
checkDependencies(instance.id, instance.dependencies)
|
checkDependencies(instance.id, instance.dependencies)
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
throw IllegalPluginDescriptionException(
|
throw IllegalPluginDescriptionException(
|
||||||
"Illegal description. Plugin ${instance.name} (${instance.id})",
|
"Illegal PluginDescription. Plugin ${instance.name} (${instance.id})",
|
||||||
it
|
it
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ public interface PluginDescription {
|
|||||||
public fun checkPluginName(name: String) {
|
public fun checkPluginName(name: String) {
|
||||||
if (name.isBlank()) throw IllegalPluginDescriptionException("Plugin name cannot be blank")
|
if (name.isBlank()) throw IllegalPluginDescriptionException("Plugin name cannot be blank")
|
||||||
val lowercaseName = name.toLowerCase()
|
val lowercaseName = name.toLowerCase()
|
||||||
FORBIDDEN_ID_NAMES.firstOrNull { it in lowercaseName }?.let { illegal ->
|
FORBIDDEN_ID_NAMES.firstOrNull { it == lowercaseName }?.let { illegal ->
|
||||||
throw IllegalPluginDescriptionException("Plugin name is illegal: '$illegal'.")
|
throw IllegalPluginDescriptionException("Plugin name is illegal: '$illegal'.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
object Versions {
|
object Versions {
|
||||||
const val core = "1.2.3"
|
const val core = "1.2.3"
|
||||||
const val console = "1.0-M4-dev-8"
|
const val console = "1.0-M4-dev-10"
|
||||||
const val consoleGraphical = "0.0.7"
|
const val consoleGraphical = "0.0.7"
|
||||||
const val consoleTerminal = "0.1.0"
|
const val consoleTerminal = "0.1.0"
|
||||||
const val consolePure = console
|
const val consolePure = console
|
||||||
|
Loading…
Reference in New Issue
Block a user