Support parsing self for PermissibleIdentifierArgumentParser

This commit is contained in:
Him188 2020-09-12 16:25:36 +08:00
parent f24042f31e
commit 8a01dcc556

View File

@ -320,7 +320,8 @@ public object PermissionIdArgumentParser : CommandArgumentParser<PermissionId> {
@ExperimentalPermission @ExperimentalPermission
public object PermissibleIdentifierArgumentParser : CommandArgumentParser<PermissibleIdentifier> { public object PermissibleIdentifierArgumentParser : CommandArgumentParser<PermissibleIdentifier> {
override fun parse(raw: String, sender: CommandSender): PermissibleIdentifier { override fun parse(raw: String, sender: CommandSender): PermissibleIdentifier {
return kotlin.runCatching { AbstractPermissibleIdentifier.parseFromString(raw) }.getOrElse { return if (raw == "~") sender.identifier
else kotlin.runCatching { AbstractPermissibleIdentifier.parseFromString(raw) }.getOrElse {
illegalArgument("无法解析 $raw 为 PermissibleIdentifier") illegalArgument("无法解析 $raw 为 PermissibleIdentifier")
} }
} }