NullPointerException -.- But why?

Discussion in 'Plugin Development' started by se1by, Dec 6, 2011.

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

    se1by

    I have this snippet here:

    Code:java
    1. static YamlConfiguration purchrases = YamlConfiguration.loadConfiguration(new File("plugins/kcstore/purchrases.yml"));
    2. static YamlConfiguration config = YamlConfiguration.loadConfiguration(new File("plugins/kcstore/config.yml"));
    3. private kcstore plugin;
    4. public pJoin(kcstore kcstore) {
    5. this.plugin = kcstore;
    6. }
    7.  
    8. public void onPlayerJoin(PlayerJoinEvent event){
    9. Player p = event.getPlayer();
    10.  
    11. Set <String> myPurchrases = purchrases.getConfigurationSection(p.getName()).getKeys(false);
    12.  

    purchrases.yml looks like this:
    Code:
    Player:
      No=1322985132:
        Item: VIP
        TimeStamp: '1322985132'
        Used: false
    
    My problem:
    myPurchrases seems to be null when Player joins the server!
    But why?
     
  2. Maybe Bukkit can't find the file? Try and place the full path in the new File section and check if it works then.
     
  3. Offline

    halley

    I'm just checking that your YML has the name of the player for each section, right? You don't really use the actual word "Player" in your YML file?

    And by the way, the word is spelled "purchases" not "purchrases".
     
  4. Offline

    se1by

    @halley
    Yeah, I use the name of the player.
    I'm german, sry for the spelling mistake :eek:
    @dadaemon
    bukkit finds the file, I used a System.out.println(); to check it.
     
  5. Do you get anything with getKeys(true)?
     
  6. Offline

    se1by

  7. Offline

    Lolmewn

    Print the output of c.contains(p.getName()), if it's false, that's your problem.
     
  8. Offline

    se1by

    Works now, spelled the username worng -.- (a 1 instead óf a l).
    Thanks @dadaemon ,
    Thanks @halley
    Thanks @Lolmewn
     
  9. Offline

    Lolmewn

    No problem ;)
     
  10. Hahaha... If every problem was as easy as this! :rolleyes:
     
Thread Status:
Not open for further replies.

Share This Page