Hi, I’m using this code to execute a give command through the console. The itemname and quantity arguments are both set in the initialization command. Whenever I run my plugin, everything works fine except for this command. Any ideas on why it does not work???
um lol, ya I think I have been pretty stupid.
Whenever I assign them as variables they come up with an error message. Here is the full code, any ideas are greatly appreciated:
As I linked in nearly a duplicate thread (are you guys clones?), Java’s still Java. Local variables don’t appear out of thin air, no matter what function you call. In this case, the CommandContext object, which you have named args, is what you’re looking for here.
And by the way, if you’re literally looking for item names, instead of GenericArguments.string, try GenericArguments.catalogedElement with ItemType.class. Sponge will parse it, provide relevant auto completes, and you can then retrieve it with args.<ItemType>getOne("itemname").get().
Give this a read, either you two are working together on a problem and posting duplicate results, or are following the same flawed tutorial, or are deliberately wasting time.
I’d really appreciate knowing how you and the other thread are linked, because at this stage I’m starting to get suspicious.