Posted October 19, 20196 yr I am trying to find out if there is a way to have different requirements based off of one of the arguments in a command. for example: /testCommand string String /testCommand player Elrol_Arrowsend so the first one, would require a string, because the prior argument is string, and the second would need a PlayerEntity because the prior command is player. I saw something about forks and I am thinking that it might be what I am looking for, but I am not too sure, so I figured I would ask. Edited October 19, 20196 yr by Elrol_Arrowsend Solved
October 19, 20196 yr You need to create a literal argument (Commands.literal) for "string" and call requires/then/execute on that as necessary and do the same for "player". In your main command registration (where you call CommandDispatcher#register), create a literal argument for "testcommand" and call then on it with the result of each literal method chain. If string and player are more like separate commands than modes of the same command, you can move each sub-command into its own class with a static method that returns an ArgumentBuilder<CommandSource, ?> (the result of the literal method chain) and call these methods in the then calls of the main command registration. See ForgeCommand or my TestMod3Command for examples of this. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
October 19, 20196 yr Author Again, thanks for this info. This will make my commands much less of a headahce and far more organized.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.