You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And that's it! If you have multiple arguments, they will be required in that order. You may also customize some other
113
-
things, like the error message within `intArg { }`. You may even use mutable properties.
114
-
115
-
Default just means the argument may be omitted. It doesn't do much if a default argument is followed by a mandated one.
116
-
117
-
## Limiting argument visibility
118
-
119
-
The general rule is, if you have access to an argument, it will be required in that command. This means, while you may
120
-
share the same arguments between several subcommands, any commands below will also require that argument to be passed (
121
-
the only limitation is that there cannot be any root level arguments yet).
122
-
123
-
To fix this, a `commandGroup` block exists, which does nothing but limit argument visibility:
124
-
125
-
```kotlin
126
-
commandGroup {
127
-
val amount by intArg()
128
-
//both commands below will require the "amount" to be passed
129
-
"one" { ... }
130
-
"two" { ... }
131
-
}
132
-
//no arguments will be required here, because we can't access any in our code!
133
-
"noArgs" { ... }
134
-
```
135
-
136
-
## Conclusion
137
-
138
-
There are some more features sprinkled into the plugin, but many might disappear. I'm more confident the DSL will remain
139
-
more or less similar going into the future, but be warned that some refactors may happen, and some things may change.
140
-
141
-
## Future plans
142
-
143
-
The current system also doesn't build any structure at startup, so it's unaware of things like arguments of subcommands,
144
-
or subcommands of subcommands. Everything is evaluated on-the-go, except root level commands, since those need to be
145
-
registered upon startup (this is why we can't currently have root level arguments). The biggest thing stopping a
146
-
structure from being generated upon startup is arguments. While it is possible to get a reference to the object the
147
-
delegate is being called from (and thus have separate instances of each argument in a map), this does not work for
148
-
lambdas, which return null as the reference. Perhaps it is possible to sidestep this with `inline` functions, thought I
149
-
have not tried it yet.
100
+
Please be sure to look at the [ExampleCommands](https://github.com/MineInAbyss/Idofront/blob/master/examples/src/main/kotlin/com/mineinabyss/idofront/examples/commands/ExampleCommands.kt)
101
+
implementation for more tips around using Minecraft arguments, providing suggestions, and more!
0 commit comments