aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/FairySoulsCommand.kt8
-rw-r--r--src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt9
2 files changed, 13 insertions, 4 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/FairySoulsCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/FairySoulsCommand.kt
index 1d766646..a38ee8c9 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/FairySoulsCommand.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/FairySoulsCommand.kt
@@ -41,22 +41,22 @@ class FairySoulsCommand {
reply("${DARK_PURPLE}Enabled fairy soul waypoints")
FairySouls.getInstance().setShowFairySouls(true)
}.withHelp("Show fairy soul waypoints")
- thenLiteral("on") { redirect(enable) }
+ thenLiteral("on") { thenRedirect(enable) }
val disable = thenLiteralExecute("disable") {
FairySouls.getInstance().setShowFairySouls(false)
reply("${DARK_PURPLE}Disabled fairy soul waypoints")
}.withHelp("Hide fairy soul waypoints")
- thenLiteral("off") { redirect(disable) }
+ thenLiteral("off") { thenRedirect(disable) }
val clear = thenLiteralExecute("clear") {
FairySouls.getInstance().markAllAsFound()
// Reply handled by mark all as found
}.withHelp("Mark all fairy souls in your current world as found")
- thenLiteral("markfound") { redirect(clear) }
+ thenLiteral("markfound") { thenRedirect(clear) }
val unclear = thenLiteralExecute("unclear") {
FairySouls.getInstance().markAllAsMissing()
// Reply handled by mark all as missing
}.withHelp("Mark all fairy souls in your current world as not found")
- thenLiteral("marknotfound") { redirect(unclear) }
+ thenLiteral("marknotfound") { thenRedirect(unclear) }
}
}
}
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt
index 17203a4b..1ce00d99 100644
--- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt
+++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt
@@ -136,6 +136,15 @@ fun <T : ArgumentBuilder<DefaultSource, T>> T.thenLiteralExecute(
thenExecute(block)
}
+fun <T : ArgumentBuilder<DefaultSource, T>> T.thenRedirect(node: CommandNode<DefaultSource>): T {
+ node.children.forEach {
+ this.then(it)
+ }
+ forward(node.redirect, node.redirectModifier, node.isFork)
+ executes(node.command)
+ return this
+}
+
fun <T : ArgumentBuilder<DefaultSource, T>, U : ArgumentBuilder<DefaultSource, U>> T.then(
node: U,
block: U.() -> Unit