To reiterate,
You have given us a snippet of code,
.arguments (
GenericArguments.string(Text.of(“itemname”)),
GenericArguments.integer(Text.of(“quantity”)))
.executor((src, args) -> {
game.getCommandManager().process(game.getServer().getConsole(), “give @a " + itemname +” "+ quantity);
The variables in bold are not defined anywhere in your snippet, so we are unable to determine the type of the variable.
Generally speaking, any object can be added to a string, as all objects in java at least inherit the default toString() method, so your above example should work, assuming that itemname and quantity are defined somewhere.
With the assumption that you are trying to access the generic arguments defined above, by that name, you need to get the argument from the context and assign it first.
in your lambda
(src, args) -> {
game.getCommandManager().process(game.getServer().getConsole(), “give @a " + itemname +” "+ quantity)
}
src represents the CommandSource sending the command, args represents the CommandContext which contains the arguments of the command among other things.
This lambda is essentially (but not technically) equivalent to having a class defined that implements CommandExecutor and overrides execute.
So you need to get the arguments out of the args context, validate them, and cast them to the required type before using.
Note that checking to see if the optionalString is there is the first and most basic level of validation, and for most arguments can be omitted if you know elsewhere that it will never be absent.
If you are using String arguments, instead of using either a provided ItemType argument, a choices argument populated by all ItemTypes, or a custom argument that contains all ItemTypes, then further validation will be required to make sure that the item type sent by the user is a valid itemtype.
Additionally if you want nice tab completion, you will need to use a different argument type then GenericArguments.String