Skip to content

Commit a2cb6a9

Browse files
committed
1 parent 8cbde11 commit a2cb6a9

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/FairySoulsCommand.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ class FairySoulsCommand {
4141
reply("${DARK_PURPLE}Enabled fairy soul waypoints")
4242
FairySouls.getInstance().setShowFairySouls(true)
4343
}.withHelp("Show fairy soul waypoints")
44-
thenLiteral("on") { redirect(enable) }
44+
thenLiteral("on") { thenRedirect(enable) }
4545
val disable = thenLiteralExecute("disable") {
4646
FairySouls.getInstance().setShowFairySouls(false)
4747
reply("${DARK_PURPLE}Disabled fairy soul waypoints")
4848
}.withHelp("Hide fairy soul waypoints")
49-
thenLiteral("off") { redirect(disable) }
49+
thenLiteral("off") { thenRedirect(disable) }
5050
val clear = thenLiteralExecute("clear") {
5151
FairySouls.getInstance().markAllAsFound()
5252
// Reply handled by mark all as found
5353
}.withHelp("Mark all fairy souls in your current world as found")
54-
thenLiteral("markfound") { redirect(clear) }
54+
thenLiteral("markfound") { thenRedirect(clear) }
5555
val unclear = thenLiteralExecute("unclear") {
5656
FairySouls.getInstance().markAllAsMissing()
5757
// Reply handled by mark all as missing
5858
}.withHelp("Mark all fairy souls in your current world as not found")
59-
thenLiteral("marknotfound") { redirect(unclear) }
59+
thenLiteral("marknotfound") { thenRedirect(unclear) }
6060
}
6161
}
6262
}

src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt

+9
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ fun <T : ArgumentBuilder<DefaultSource, T>> T.thenLiteralExecute(
136136
thenExecute(block)
137137
}
138138

139+
fun <T : ArgumentBuilder<DefaultSource, T>> T.thenRedirect(node: CommandNode<DefaultSource>): T {
140+
node.children.forEach {
141+
this.then(it)
142+
}
143+
forward(node.redirect, node.redirectModifier, node.isFork)
144+
executes(node.command)
145+
return this
146+
}
147+
139148
fun <T : ArgumentBuilder<DefaultSource, T>, U : ArgumentBuilder<DefaultSource, U>> T.then(
140149
node: U,
141150
block: U.() -> Unit

0 commit comments

Comments
 (0)