aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-04-14 21:12:27 +0200
committernea <nea@nea.moe>2023-04-14 21:12:27 +0200
commita2cb6a9d5c33a52912c43b0f1d677165c5e99ff2 (patch)
tree5207204379cc9e684bb264cda7dc6998a28bc441
parent8cbde1123af4dc36e05a20bc795e4ea771182008 (diff)
downloadNotEnoughUpdates-feat/npcexport.tar.gz
NotEnoughUpdates-feat/npcexport.tar.bz2
NotEnoughUpdates-feat/npcexport.zip
Fix https://github.com/Mojang/brigadier/issues/46feat/npcexport
-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