Revert "Check Command.owner, #216"

This reverts commit 595c9480
This commit is contained in:
Him188 2020-11-29 19:26:05 +08:00
parent 7bdeacf62a
commit dfc9957c24
2 changed files with 0 additions and 16 deletions

View File

@ -37,8 +37,6 @@ public abstract class AbstractCommand
init {
Command.checkCommandName(primaryName)
@Suppress("LeakingThis")
Command.checkCommandOwner(this)
secondaryNames.forEach(Command.Companion::checkCommandName)
}

View File

@ -117,19 +117,5 @@ public interface Command {
name.contains('.') -> throw IllegalArgumentException("'.' is forbidden in command name.")
}
}
/**
* 检查指令 [owner] 的合法性, 在非法时抛出 [IllegalArgumentException]
*/
@JvmStatic
@Throws(IllegalArgumentException::class)
public fun checkCommandOwner(command: Command) {
val owner = command.owner
if (owner is ConsoleCommandOwner) {
if (command.javaClass.enclosingClass != BuiltInCommands::class.java) {
throw IllegalArgumentException("ConsoleCommandOwner is not allowed")
}
}
}
}
}