lgou2w/ldk

Some changes in the 0.1.6-rc version

Closed this issue · 0 comments

This issue is used for feature changes and enhanced tracking of the 0.1.6-rc version. See the develop-0.1.6-rc branch for more details.

ldk-bukkit-cmd

  • Wrong use val unmodifiable type.

  • Command executor string parameters can match online player features.

      @Command("add")
      fun addUser(sender: CommandSender,
        @Playername
        username: String
      ) {
        // If the server player `abc` online,
        // then the tab completion will contain the `abc` player name.
        // Can also enter the player name directly.
        println(username) // `abc` or other enter name.
      }
  • Extend standard command abstract class to provide convenience functions

    abstract class StandardCommand : Initializable {
      lateinit var command : RegisteredCommand
      override fun initialize(command: RegisteredCommand) {
          this.command = command
          this.initialize()
      }
      protected abstract fun initialize()
      fun CommandSender.send(message: String) {
          val prefix = command.rootParent?.prefix ?: command.prefix
          sendMessage(prefix + message.toColor())
      }
      fun CommandSender.send(message: Array<out String>) {
          val prefix = command.rootParent?.prefix ?: command.prefix
          sendMessage(message.toColor().map { msg -> prefix + msg }.toTypedArray())
      }
    }
    // Your command class
    @CommandRoot("your")
    class YourCommand : StandardCommand() {
      override fun initialize() {
        this.command.xxx // initialize your command
      }
      // Your command executor...
    }

More