Command Arguments

Discussion in 'Plugin Development' started by Pink__Slime, Jun 7, 2013.

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

    Pink__Slime

    Ok I'm trying to get a little better with commands since all I've done is just basic stuff.

    So what I'm trying to do is something like what CoreProtect does, how /co rollback u:USER t:TIME etc.

    I understand it's something along the lines of "if(args[0].startsWith("u:"))" but I don't understand how to get whatever is after that. E.g. I use /command u:pink__Slime. How do I get just "Pink__Slime"?

    ALSO, this is something I want to know.
    If I wanted to have 2 arguments, args[0] and args[1]. How would I allow args[1] to be more than one word.
    The ban command is a good example,
    /ban USER REASON. The reason can be multiple words but how do you do that? I haven't tried "args" because I figured that would get args[0] as well.
     
  2. Offline

    _Waffles_

    args[0].split(":")[1] should get you the pink slime ;)
     
    Pink__Slime likes this.
  3. Offline

    Pink__Slime

    _Waffles_
    Thanks!
    Any ideas for the second one?
     
  4. Offline

    _Waffles_

    int x = 0;
    String name = "";
    String reason = ""
    for(String s : args)
    {
    if(x == 0)
    name += s;
    else
    reason += s;
    x++;
    }
     
Thread Status:
Not open for further replies.

Share This Page