Closed hugeblank closed 2 years ago
Commands could benefit from being a builder rather single function + arg. Would allow for higher flexibility and easier way of using all functionality of brigardier (sugestions, arg types, etc). Also not sure prefixing with plugin id, it can rather limit what can you do
We could use the plugin id as the command name in game, and then have the first command argument be the specific command? so in the example above it would instead be /test help please?
We'd have to get creative with plugin names that match existing command names, though.
I think just overriding commands will be fine. We could also try adding it without namespace if it doesn't exist or with one otherwise (with way to force override it ofc)
I agree that the builder idea fits this better. The way you initially described doesn't have a good way to do argument type checking during command autocompletion.
Command api fully implemented as of ed0696096cfc6d59d3ae3921a7f780dda9a2bd60. Register a command using command.register
, and use the argument types provided by the game by indexing command.arguments.<argument-id>
. argument-id
is one of the ids in ArgumentTypes
, or one of the brigadier argument types, with brigadier:
cut off. An example of how it works can be found in the hangman example script as of f71db1c62af8cb89077a581942e9b79da6582cae.
Registers a command using a similar format to
allium.onEvent
:Would register a command that could get called as
/test:help please?
.player
would be the player that executed the command, ornil
if it was run by a server.arg1
would be "please?", andarg2
(and the rest of the arguments) would benil
.