mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Simplify on_command arguments
This commit is contained in:
@@ -67,19 +67,19 @@ class KotlinMessageHandler<T : Message>(val world: World, val context: PluginCon
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinCommandListener(val level: PrivilegeLevel, val function: (Player, Command) -> Unit) : CommandListener(level) {
|
class KotlinCommandListener(val level: PrivilegeLevel, val function: Command.(Player) -> Unit) : CommandListener(level) {
|
||||||
|
|
||||||
override fun execute(player: Player, command: Command) {
|
override fun execute(player: Player, command: Command) {
|
||||||
function.invoke(player, command)
|
function.invoke(command, player)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinCommandHandler(val world : World, val command: String, val privileges: PrivilegeLevel) {
|
class KotlinCommandHandler(val world : World, val command: String, val privileges: PrivilegeLevel) {
|
||||||
|
|
||||||
var function: (Player, Command) -> Unit = { _, _ -> }
|
var function: Command.(Player) -> Unit = { _ -> }
|
||||||
|
|
||||||
fun then(function: (Player, Command) -> Unit) {
|
fun then(function: Command.(Player) -> Unit) {
|
||||||
this.function = function
|
this.function = function
|
||||||
world.commandDispatcher.register(command, KotlinCommandListener(privileges, function))
|
world.commandDispatcher.register(command, KotlinCommandListener(privileges, function))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ import org.apollo.game.model.entity.setting.PrivilegeLevel
|
|||||||
|
|
||||||
// Opens the player's bank if they are an administrator.
|
// Opens the player's bank if they are an administrator.
|
||||||
on_command("bank", PrivilegeLevel.ADMINISTRATOR)
|
on_command("bank", PrivilegeLevel.ADMINISTRATOR)
|
||||||
.then { player, _ -> player.openBank() }
|
.then { player -> player.openBank() }
|
||||||
Reference in New Issue
Block a user