Sign.getLine (String) to int?

Discussion in 'Plugin Development' started by TomTheDeveloper, Mar 23, 2013.

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

    TomTheDeveloper

    How can i get an int form a sign?
    On the third line on the sign will stand 3, and i need to check if the players explvl is more than three.

    So how can i get an int from a sign?
     
  2. You should use
    Code:
    Integer.parseInt(mystring);
    If the string does not look like a number. It will throw NumberFormatException.
    So you should add try-catch.
    Code:
    int myInt;
    try {
        myInt = Integer.parseInt(myString);
    }
    catch (NumberFormatException e) {
        // not a number
        myInt = 0;// so use default value
    }
     
    TomTheDeveloper likes this.
Thread Status:
Not open for further replies.

Share This Page