Very strange error

Discussion in 'Plugin Development' started by Laekh, Jan 7, 2013.

Thread Status:
Not open for further replies.
  1. Hello,

    I don't know what went wrong exactly,
    there are no errors in my code and the error doesn't seem to refer to anything specific in my code.
    It says that it's something with my config.yml (that it's a null), but I don't see anything wrong with it.

    The error:

    Show Spoiler

    19:41:37 [INFO] This server is running CraftBukkit version git-Bukkit-1.4.6-R0.3
    -5-g82c58b5-b2590jnks (MC: 1.4.6) (Implementing API version 1.4.6-R0.4-SNAPSHOT)

    19:41:37 [SEVERE] Could not load 'plugins\Lottery.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Fi
    le cannot be null
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:182)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:305)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:230)
    at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugins(CraftServer.jav
    a:239)
    at org.bukkit.craftbukkit.v1_4_6.CraftServer.<init>(CraftServer.java:217
    )
    at net.minecraft.server.v1_4_6.PlayerList.<init>(PlayerList.java:52)
    at net.minecraft.server.v1_4_6.DedicatedPlayerList.<init>(SourceFile:11)

    at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java
    :104)
    at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:
    399)
    at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:84
    9)
    Caused by: java.lang.IllegalArgumentException: File cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:203)
    at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(Yam
    lConfiguration.java:170)
    at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:117)
    at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:111)
    at com.cupcakes69.lottery.Lottery.<init>(Lottery.java:24)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:178)
    ... 9 more


    My config.yml

    Show Spoiler

    entry-price: 50
    currency: dollars
    auto-draw: off
    draw-amount: 100


    No tabs or anything there.

    The things loading the config

    Show Spoiler

    Code:
    String price = getConfig().getString("entry-price");
    String currency = getConfig().getString("currency");
    String autoDrawS = getConfig().getString("auto-draw");
    String autoDrawAmountS = getConfig().getString("draw-amount");
    


    I deal with the integers with a valueOf..

    further in my code there's
    Code:
    int autoDrawAmount = Integer.valueOf(autoDrawAmountS);
    
    I check if the config would return an int with a Integer.parseInt(i)
    but I don't think that's the problem.

    Does anyone know what is?

    Tell me if you need any more information.

    Thank you,
    Cupcakes.
     
  2. Offline

    evilmidget38

    Cupcakes69 In order to help you debug your code, we need to see your code.
     
  3. Offline

    evilmidget38

    Move your variable assignments from the declaration to onEnable().

    EDIT: Your config variable assignments. You can't use getConfig() before onEnable() has been called.
     
    Cupcakes69 likes this.
  4. Thank you very much,
    I moved the assignments to the inside of the methods it is used in, allowing it to enable the plugin without calling them yet :)
     
Thread Status:
Not open for further replies.

Share This Page