How To Convert String to double (currentVer = Double.parseDouble(pdfFile.getVersion()))

Discussion in 'Plugin Development' started by edocsyl, Dec 14, 2011.

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

    edocsyl

    I wanna convert the pdfFile.getVersion() to a double like so:

    PHP:
    private double currentVer Double.parseDouble(pdfFile.getVersion());
    But the MC Server print me out:
    Code:
    2011-12-14 19:40:02 [SEVERE] Could not load 'plugins\DontHitMe.jar' in folder 'plugins':
    java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:175)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:215)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:151)
        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:127)
        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:52)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    Caused by: java.lang.NullPointerException
        at me.edocsyl.DontHitMe.DontHitMe.<init>(DontHitMe.java:35)
        ... 13 more
     
  2. Offline

    Brain

    First, the problem seems to be located in file DontHitMe.java at line 35. Whatever that is.
    Second, your double conversion might fail because pdfFile.getVersion() might return "9.0.1" or "9.0b" or another invalid value for a double. Well, whatever pdfFile is an instance of.

    For better help please supply more information or wait until my magical crystal ball has returned from the repair shop. ;)
     
  3. Offline

    nisovin

    You're trying to run this code in the constructor, but the PDF isn't available until onEnable().
     
  4. Offline

    edocsyl

    :confused:

    I See the problem... Is there any other way to get the version as Double from the plugin.yml file?
     
  5. Do it in onEnable :)
     
  6. Offline

    edocsyl

    I tryed this, but it doesn't work.
     
Thread Status:
Not open for further replies.

Share This Page