java nullpointerexception in Player_Interact_Event

Discussion in 'Plugin Development' started by matter123, Apr 20, 2011.

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

    matter123

    when i right click i get this error
    Code:
    11:04:52 [SEVERE] Could not pass event PLAYER_INTERACT to Disposable_boats
    java.lang.NullPointerException
            at org.bukkit.plugin.java.JavaPluginLoader$9.execute(JavaPluginLoader.ja
    va:252)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:59)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:255)
            at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEven
    t(CraftEventFactory.java:162)
            at net.minecraft.server.ItemInWorldManager.a(ItemInWorldManager.java:208
    )
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:447)
            at net.minecraft.server.Packet15Place.a(SourceFile:57)
            at net.minecraft.server.NetworkManager.a(NetworkManager.java:198)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:72)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:368)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:283)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:375)
    my source is attached (note plugin.yml is not included in the source but it is included in the jar)
    how do i fix this error
     

    Attached Files:

    • src.zip
      File size:
      4.7 KB
      Views:
      6
  2. Offline

    Deathly

    @matter123

    When does that error occur? Right-click on any block? Only at signs? On all signs? Please include some details :)
     
  3. Offline

    nisovin

    You might check if event.getBlockClicked() is returning null.

    Also, this is unrelated, but comparing strings with == and != is not going to work how you expect it to. You need to use .equals().
     
  4. Offline

    Crash

    Don't use the plugin generators anymore some are outdated like this one.
    Get rid of the constructor in the main class and change the package name to get rid of the .bukkit
     
  5. Offline

    matter123

    right click on any block
    i don't have a constructor and my package name is com.matter123 what made you think there is a plug in generator
     
  6. Offline

    Crash

    Sorry firefox made me open the complete wrong rar because I had another rar in my downloads folder called src so it made me open that up.

    EDIT : Your problem is that you never set plistener to a new instance of dbplayerlistener.
     
  7. Offline

    matter123

    oh ok
    i changed my source around so it checks if getclickedblock!=null it still throws the same error on right click of any block
     

    Attached Files:

  8. Offline

    nisovin

    Did you read his edit? That's exactly your problem. When you register your event your listener is null.
     
  9. Offline

    matter123

    no he made his edit after i made the post
    but thank you for the solution
     
Thread Status:
Not open for further replies.

Share This Page