Storing user input into a double?

Discussion in 'Plugin Development' started by Eliteninja42, Jul 28, 2013.

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

    Eliteninja42

    Hello, I was wondering how you would store a number from a user into a double, such as /setcooldown <number here> and storing the "<number here> into double x. Would you use a scanner for this, or does bukkit have a different way to do this?
     
  2. Offline

    Seadragon91

    Code:
    double d = Double.parseDouble("100.5");
     
  3. Offline

    CubieX

    Ha?
    If the player enters this within a command, just convert it to a double with
    Code:
    double number = Double.parseDouble(args[0])
    and intercept possible exceptions when doing this.
     
  4. Offline

    Henzz

    Eliteninja42

    First you would parse args[0] as a double and handle the NumberFormatException if a string was entered.
     
Thread Status:
Not open for further replies.

Share This Page