Solved Command flags

Discussion in 'Spigot Plugin Development' started by joeleoli, May 15, 2016.

  1. I know how a command works and how to use the arguments but how would I go along as doing something like command flags?

    Example
    BanManagement (/ban {user} {time} -s) "-s" means silent

    I want the -s.
    I'm guessing it would be to check if an argument starts with "-" then that'll be a flag. Any other suggestions?
     
  2. check the command arguments for "-s", if contains "-s" { do whatever} sort of thing
     
  3. check args length. Check if args 2 is equal to "-s". And if it is, dont announce the ban.
     
  4. Already done. Thanks though. For anyone wondering, I used this:
    Code (Text):

    for(String arg : args) {
        if(arg.startsWith("-s")) {

        }
    }
     
    fixed* pasted wrong code
     
  5. Usually, commands flags are allowed to put anywhere in the command, but that's a bit more complex to code.
     
  6. Mark as solved