Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

MC-XiaoHei
Copy link
Contributor

@MC-XiaoHei MC-XiaoHei commented Nov 14, 2024

Implemented the feature in #529 with Kotlin DSL support and changed the method name to 'thenNested' as suggested in Discord

Usage:

Java:
new CommandTree("example")
    .thenNested(
        new LiteralArgument("arg1"),
        new StringArgument("arg2"),
        new StringArgument("arg3"),
        new DoubleArgument("arg4", 0),
        new StringArgument("arg5")
            .executes(...)
    ) 
Kotlin:
CommandTree("example")
    .thenNested(
        LiteralArgument("arg1"),
        StringArgument("arg2"),
        StringArgument("arg3"),
        DoubleArgument("arg4", 0),
        StringArgument("arg5")
            .executes { ... }
    )
Kotlin DSL
commandTree("example") {
    nested {
        literalArgument("arg1")
        stringArgument("arg2")
        stringArgument("arg3")
        doubleArgument("arg4", 0.0)
        stringArgument("arg5") {
            anyExecutor { ... }
        }
    }
}
// or
commandTree("example") {
    nestedArguments(
        LiteralArgument("arg1"),
        StringArgument("arg2"),
        StringArgument("arg3"),
        DoubleArgument("arg4", 0.0),
        StringArgument("arg5")
    ) {
        anyExecutor { ... }
    }
}

@MC-XiaoHei
Copy link
Contributor Author

By the way, I'm not quite sure how to write javadoc for 'thenNested', can someone help me?

@MC-XiaoHei
Copy link
Contributor Author

Oh I found that I modified one space and used unnecessary parentheses in two places, I'll fix it

@MC-XiaoHei
Copy link
Contributor Author

MC-XiaoHei commented Nov 15, 2024

I've used some black magic for the implementation of the nested { } function, and I'm not sure if it meets the spec.
anyway it works

@MC-XiaoHei MC-XiaoHei marked this pull request as ready for review November 15, 2024 09:04
@MC-XiaoHei MC-XiaoHei requested a review from JorelAli November 15, 2024 09:04
@MC-XiaoHei
Copy link
Contributor Author

Thank you for your help! Hopefully there are no other issues xD

@DerEchtePilz
Copy link
Member

I'd really like to run some manual tests with this before merging but generally looks good.

MC-XiaoHei and others added 2 commits November 20, 2024 07:32
…commandapi-bukkit-kotlin-test/src/test/kotlin/dev/jorel/commandapi/test/dsltests/CommandTreeTests.kt

Co-authored-by: willkroboth <[email protected]>
@MC-XiaoHei
Copy link
Contributor Author

thanks for your help again!
I make so much mistakes xD

@JorelAli
Copy link
Member

This looks good, thanks!

@JorelAli JorelAli merged commit 27b9360 into CommandAPI:dev/dev Nov 20, 2024
3 checks passed
@JorelAli JorelAli mentioned this pull request Nov 20, 2024
@MC-XiaoHei MC-XiaoHei deleted the dev/dev branch November 21, 2024 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants