Nullpointer Exception at a getString function

Discussion in 'Plugin Development' started by flymia, Aug 13, 2014.

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


    Hello Forums,

    I've got a problem with my plugin. I already wrote a command to teleport to the server lobby. This lobby is saved in the config file: [​IMG]

    At the /l command the teleport to the lobby works perfectly with this method:
    1. public static World getWorldFromConfig(){
    2. String lobbyStr = "tpoint.lobby.";
    3. World w = Bukkit.getWorld(plugin.getConfig().getString(lobbyStr + "world"));
    4. return w;
    5. }

    But If I do it in an event I get a nullpointer exception:
    What should It do?
    If I right click on a specific sign, it should teleport me to the lobby. Why I'm getting errors, when It works perfectly with the command?

    Please help!
  2. Offline


    flymia Do you set this.plugin of the listener to your main class? Whats on line 25 in
  3. Offline


    Line 25 is this:
    1. World w = Bukkit.getWorld(plugin.getConfig().getString(lobbyStr + "world"));

    But WHY do I get this error message. IT WORKS with the same method on the command?
  4. Offline


    flymia Are you sure that 'plugin' isn't null?
  5. How have you initialized plugin?
  6. Offline


    Well, it should. It works on the command with this:
    1. AppleCraft plugin;

    It's the same on the sign function.
  7. Offline


    yes you defined it. Have you initialized it as well?
    GameplayJDK likes this.
  8. Offline


    No. Because It works on the command the same. Let me try..

    Okay, this works now. Thank you! :)
Thread Status:
Not open for further replies.

Share This Page