Skip to content

Support of default value for parameter in Kotlin #357

@Distractic

Description

@Distractic

Current Behavior

When we use the annotations to set argument, the default value from kotlin declaration is not supported.

With the current system, the command bellow cannot be executed when the player doesn't define the values for args :

@CommandMethod("test [x] [y] [z]")
@CommandDescription("Test command")
suspend fun testCmd(
        player: Player,
        @Argument("x") x: Double = player.location.x,
        @Argument("y") y: Double = player.location.y,
        @Argument("z") z: Double = player.location.z
) {
 println("parameters : $x $y $z")
}

If the user doesn't add an argument, a null value will be used to set the arguments.

Effectively, in the @Argument, there is a String to define the default value, but in the most cases, it's not enough.

Expected Behavior

The command defined above can be used if the user writes :
/test
/test 1
/test 1 2
/test 1 2 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions