Getting int from command args[0]

Discussion in 'Plugin Development' started by Wolf7115, Dec 24, 2011.

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

    Wolf7115

    Is there a way to get an int from args in a command instead of a string? I cannot seem to find one on the intertubes. I would assume you have to convert it first, but I cannot figure that out. Thanks.
     
  2. Offline

    Sagacious_Zed Bukkit Docs

  3. Offline

    Razorcane

    Integer.parseInt(String). You should also throw this in a try/catch statement in case some idiot(and you know there will be idiots) who will try to type in something besides an integer.
     
  4. Offline

    Wolf7115

    @Sagacious_Zed I honestly Can't believe I didn't this of that. I should have known that. Thanks :D

    @Razorcane I will use your advice. Thanks.
     
  5. Offline

    Codex Arcanum

    @Wolf7115
    You may have already thought of this, but I forgot to do this just a few minutes so I figured I should post. Make sure to check whether there IS an args[0] with an if (args.length != 0)
     
  6. Offline

    scranner

    Code:
    int amountSold = Integer.parseInt(args[0]);
     
Thread Status:
Not open for further replies.

Share This Page