diff options
author | nea <nea@nea.moe> | 2023-04-14 21:12:27 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-04-14 21:12:27 +0200 |
commit | a2cb6a9d5c33a52912c43b0f1d677165c5e99ff2 (patch) | |
tree | 5207204379cc9e684bb264cda7dc6998a28bc441 /src/main | |
parent | 8cbde1123af4dc36e05a20bc795e4ea771182008 (diff) | |
download | NotEnoughUpdates-feat/npcexport.tar.gz NotEnoughUpdates-feat/npcexport.tar.bz2 NotEnoughUpdates-feat/npcexport.zip |
Fix https://github.com/Mojang/brigadier/issues/46feat/npcexport
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/FairySoulsCommand.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/dsl.kt | 9 |
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 |