Config Problem

Discussion in 'Plugin Development' started by HenoLima, Mar 29, 2014.

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

    HenoLima

    This gives me a NullPointerExepiton when i try to acces something from the config , i think it dosen't create the config in the first place and just gives me a wierd error ( and i have my config file in my project )
    Here is my main class onEnable :
    Code:java
    1. public void onEnable() {
    2.  
    3. this.saveDefaultConfig();
    4.  
    5.  
    6.  
    7.  
    8. getServer().getPluginManager().registerEvents(new LoginListener(this), this);
    9. getServer().getPluginManager().registerEvents(new TokenShop(this), this);
    10. this.getCommand("tokens").setExecutor(new Tokens(this));
    11.  
    12. log = getLogger();
    13. try {
    14. this.mysql.setupDB();
    15. } catch (SQLException e) {
    16. log.warning("Could not connect to database");
    17. log.warning("Error:" + e);
    18. this.logDB = false;
    19.  
    20. e.printStackTrace();
    21. }
    22. }
    23.  
    24. public void onDisable() {
    25. this.mysql.closeDB();
    26. saveConfig();
    27.  
    28. }
    29.  


    And here is my class where i get the error:
    Code:java
    1. public TokenShop(TokenPvp h) {
    2. TokenShop.main = h;
    3. }
    4.  
    5. public static Inventory tokenshop = Bukkit.createInventory(null, 27,
    6. ChatColor.BOLD + "Token Shop");
    7.  
    8. static {
    9.  
    10. TokenPvp.createDisplay(Material.BONE, tokenshop, 0, ChatColor.GREEN
    11. + "Wolf Pet", ChatColor.GRAY
    12. + "Get your wolf pet now and you won't regret it!"
    13. + ChatColor.GREEN + String.valueOf(main.getConfig().getInt("Wolf"))// ERROR right here
    14. + " TOKENS");
    15.  
    16. }


    Yeah and it gives me a nullpointer , maybe the config is not creating ? I don't know
    Trace
    [​IMG]
     
  2. Offline

    Glumpz

    NullPointerExceptions that are being caused by variables are generally thrown when some part of the .getConfig(); method is null.
     
Thread Status:
Not open for further replies.

Share This Page