Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Add AbstractCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Apr 24, 2020
1 parent a27c2a1 commit 96dcea9
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,26 @@ interface Command {
suspend fun onCommand(sender: CommandSender, args: List<String>): Boolean
}

abstract class AbstractCommand(
override val name: String,
override val alias: List<String>,
override val description: String,
override val usage: String
) : Command

/**
* 注册这个指令
*/
inline fun Command.register(commandOwner: CommandOwner) = CommandManager.register(commandOwner,this)
inline fun Command.register(commandOwner: CommandOwner) = CommandManager.register(commandOwner, this)

internal inline fun registerConsoleCommands(builder: CommandBuilder.() -> Unit):Command{
internal inline fun registerConsoleCommands(builder: CommandBuilder.() -> Unit): Command {
return CommandBuilder().apply(builder).register(ConsoleCommandOwner)
}

inline fun PluginBase.registerCommand(builder: CommandBuilder.() -> Unit):Command{
/**
* 构造并注册一个指令
*/
inline fun PluginBase.registerCommand(builder: CommandBuilder.() -> Unit): Command {
return CommandBuilder().apply(builder).register(this.asCommandOwner())
}

Expand Down

0 comments on commit 96dcea9

Please sign in to comment.