@@ -4,7 +4,6 @@ package dev.fruxz.brigadikt
44
55import com.mojang.brigadier.Command
66import com.mojang.brigadier.context.CommandContext
7- import dev.fruxz.ascend.extension.forceCastOrNull
87import dev.fruxz.ascend.extension.isNotNull
98import dev.fruxz.ascend.extension.logging.getItsLogger
109import dev.fruxz.ascend.extension.switch
@@ -20,7 +19,6 @@ import net.kyori.adventure.text.Component
2019import net.kyori.adventure.text.ComponentLike
2120import org.bukkit.command.CommandSender
2221import org.bukkit.entity.Entity
23- import org.bukkit.entity.Player
2422
2523interface CommandAccess {
2624
@@ -42,7 +40,7 @@ data class CommandContext(
4240 val raw : CommandContext <CommandSourceStack >,
4341 val replyRenderer : ReplyChatRenderer ? ,
4442 override val path : List <String >,
45- val state : (state: Int , process: () -> Unit ) -> Unit ,
43+ val state : (state: Int ) -> Unit ,
4644): CommandAccess {
4745
4846 override val sender = raw.source.sender
@@ -74,14 +72,23 @@ data class CommandContext(
7472 }
7573
7674 // state modification
77- @BrigadiKtDSL fun state (state : Int , message : ComponentLike ) = this .state.invoke(state) { reply(message) }
75+ @BrigadiKtDSL fun state (state : Int , message : ComponentLike ) {
76+ this .state(state)
77+ reply(message)
78+ }
7879 @BrigadiKtDSL fun state (state : Int , @StyledString message : String ) = state(state, message.asStyledComponent)
7980
80- @BrigadiKtDSL fun fail (process : () -> Unit = { }) = state(0 , process)
81+ @BrigadiKtDSL inline fun fail (process : () -> Unit = { }) {
82+ state(0 )
83+ process()
84+ }
8185 @BrigadiKtDSL fun fail (message : ComponentLike ) = state(0 , message)
8286 @BrigadiKtDSL fun fail (@StyledString message : String ) = state(0 , message)
8387
84- @BrigadiKtDSL fun success (process : () -> Unit = { }) = state(Command .SINGLE_SUCCESS , process)
88+ @BrigadiKtDSL inline fun success (process : () -> Unit = { }) {
89+ state(Command .SINGLE_SUCCESS )
90+ process()
91+ }
8592 @BrigadiKtDSL fun success (message : ComponentLike ) = state(Command .SINGLE_SUCCESS , message)
8693 @BrigadiKtDSL fun success (@StyledString message : String ) = state(Command .SINGLE_SUCCESS , message)
8794
@@ -98,7 +105,7 @@ data class CommandContext(
98105 this .reply(component = message.asStyledComponent, sound = sound)
99106
100107 @BrigadiKtDSL
101- fun reply (sound : Sound ? = null, messageBuilder : StackedBuilder .() -> Unit ) =
108+ inline fun reply (sound : Sound ? = null, messageBuilder : StackedBuilder .() -> Unit ) =
102109 this .reply(Component .empty().toStackedBuilder().apply (messageBuilder), sound)
103110
104111 override fun CommandSender.hasPathPermission (logResult : Boolean ): Boolean =
0 commit comments