Null Pointers?!?!

Discussion in 'Plugin Development' started by waco001, Jul 22, 2013.

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

    waco001

    Hello Guys. I'm trying to access a Location object from another class and it's giving me some trouble.
    The error is:
    Code:
    2013-07-22 19:43:39 [INFO] [anvildrop] Disabling anvildrop v0.1
    2013-07-22 19:43:39 [INFO] [anvildrop] SAMPLE ANVIL DROP DISABLED
    2013-07-22 19:43:39 [INFO] [anvildrop] Loading anvildrop v0.1
    2013-07-22 19:43:39 [INFO] [anvildrop] Enabling anvildrop v0.1
    2013-07-22 19:43:39 [INFO] [anvildrop] SAMPLE ANVIL DROP ENABLED
    2013-07-22 19:43:39 [INFO] Server permissions file permissions.yml is empty, ignoring it
    2013-07-22 19:43:39 [INFO] CONSOLE: Reload complete.
    2013-07-22 19:43:43 [INFO] waco001 issued server command: /ad play
    2013-07-22 19:43:43 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'ad' in plugin anvildrop v0.1
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServer.java:523)
        at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerConnection.java:964)
        at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.java:882)
        at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java:839)
        at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)
        at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296)
        at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java:118)
        at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
        at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:590)
        at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
        at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
        at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
        at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    Caused by: java.lang.NullPointerException
        at me.waco001.anvildrop.sample.Game.play(Game.java:55)
        at me.waco001.anvildrop.sample.Main.onCommand(Main.java:56)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
        ... 15 more
    
    Game.java @ 55 is
    Code:java
    1. public void play(){
    2. //running = true;
    3. //levels = inLevels;
    4. //if(plugin.setup == false){
    5. // exit("Add Position To Config", player);
    6. //}
    7. //player.teleport(plugin.locationArena);
    8. plugin.getLogger().info("test");
    9. //loadinventory(player);
    10. //gameplay(player, levels);
    11.  
    12. }

    With the debugger msg. Basically anything other then the two variable changes can cause the error.
    In main @ 56
    Code:java
    1. game.play();


    To connect the two classes, in Main.java, I added:
    public Game game;
    and in onEnable,
    game = new Game(plugin);

    in game.java,


    private Main plugin;
    and
    public Game(Main instance){
    plugin = instance;
    init();
    }
    Please Help Me,
    waco001
     
  2. Offline

    1Rogue

    use

    game = new Game(this);

    in your onEnable
     
  3. Offline

    microgeek

    Something is null in Game.java on line 55. I don't see how that's all that complicated.
     
  4. Offline

    xTrollxDudex

    waco001
    Use this.
     
  5. Offline

    waco001

    Wow, that was stupid. Thanks for your help!
     
  6. Mark as Solved. :)
     
Thread Status:
Not open for further replies.

Share This Page