Solved Getting things from Config

Discussion in 'Plugin Development' started by CevinWa, Dec 6, 2012.

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



    I have a custom config file and everything works untill i get a NPE when trying to get the owner of the consig file. But a wierd thing is that it sends me a message saying the exact name of the owner and it works when i get the player via string name from bukkit and sends him a message that way but it seems it cannot peform checks. Have tried unsuccsessfully in nearly 3 h now so i thought that i should post it here.


        String owner = NameLocation.getString("Owner");
        if(Bukkit.getPlayer(NameLocation.getString("Owner")) == player){
    Would love some help :D
  2. Offline

    Sagacious_Zed Bukkit Docs

    player cannot be resolved in code snippet.
  3. Offline


    I've tried with playernames like this if(player.getname == NameLocation.getString("Owner")){
    And such but it doesen't work.
  4. Offline

    Sagacious_Zed Bukkit Docs

    please be aware what happens when you use the equality operator with objects.
  5. Offline


    I googled it and it said that i should put them as int hashcodes and then compare them
    But i gave the same error

    int hash = playerName.hashCode();
    int hash2 = NameLocation.getString("Owner").hashCode();
    if(hash == hash2)

    Thanks for helping me.
  6. Offline

    Sagacious_Zed Bukkit Docs

    Calling any method on null will throw a NPE
  7. Offline


    Im feeling like such a noob but what in my code is giving an npe i can't really tell the whole system works just that the console is spammed.

    St1 = new String(NameLocation.getString("Owner"));
    st2 = new String(playerName);


    I have Public object st1; and st2;
    In the top.
  8. Offline

    Sagacious_Zed Bukkit Docs

    We are not the ones with the full stack trace nor the full source code.
  9. Offline


    Okey sorry i'l search around some more hours.
Thread Status:
Not open for further replies.

Share This Page