Solved Length Of Arguments?

Discussion in 'Plugin Development' started by Rmarmorstein, Nov 29, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Rmarmorstein

    I am wondering if, and how, i can restrit the length of arguments. would it be something like

    Code:java
    1.  
    2. if (args[0].length() < 2)
    3. sender.sendMessage("Oops. Too Short")
    4. if (args[0].length() > 2)
    5. sender.sendMessafe("Oops. Too Long")
    6.  


    Also, i did that, but it still does not stop doing what the command was going to do, it just gets all messed up with the command. How could i Stop it from doing what is below it, or what the command does, if those are wrong.
     
  2. Offline

    NinjaW0lf

    add This if u want to stop code from being reached:
    Code:java
    1.  
    2. if (args[0].length() < 2) {
    3. return false;
    4. }else if (args[0].length() > 2)
    5. return false;
    6.  
     
  3. Offline

    Rmarmorstein

    Thanks
     
  4. Offline

    NinjaW0lf

  5. Offline

    xGhOsTkiLLeRx

    Since the onCommand() method is a boolean method (he said something about commands ;)), you need to use return true; or return false;
    (false will display the usage message defined in the plugin.yml)

    If you want to stop at a void method the keyword return; is of course right!
     
  6. Offline

    NinjaW0lf

    Ah yes, i wasnt paying attention, i saw stop going further, and thought of that.
    well. tehn he would prob use return false;
     
    xGhOsTkiLLeRx likes this.
Thread Status:
Not open for further replies.

Share This Page