Help With NullPointerException

Discussion in 'Plugin Development' started by boysnnoco, Jan 19, 2014.

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

    boysnnoco

    So I am getting a null pointer on these lines of Code:
    Code:java
    1. Player player = (Player) proj.getShooter();

    Full Eventhandler:
    Code:
    @EventHandler
        public void onLaunch(ProjectileLaunchEvent event){
            if(event.getEntity() instanceof Arrow){
                Arrow proj = (Arrow) event.getEntity();
                if(proj.getShooter() instanceof Player){
                    if(proj.getVelocity().length() > 2.89){
                        Player player = (Player) proj.getShooter(); //Null Pointer Here I dont see why either.
                        plugin.fastbow.check(player);
                       
                    }
                }
            }
     
        }
    Stacktrace:
    Code:
    Could not pass event ProjectileLaunchEvent to AntiHax v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectileLaunchEvent(CraftEventFactory.java:597) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.World.addEntity(World.java:904) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.World.addEntity(World.java:871) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ItemBow.a(ItemBow.java:59) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ItemStack.b(ItemStack.java:319) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.EntityHuman.by(EntityHuman.java:103) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:498) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockDig.a(SourceFile:53) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockDig.handle(SourceFile:8) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.lang.NullPointerException
        at me.boysnnoco.FastBow.FastBowCheck.check(FastBowCheck.java:19) ~[?:?]
        at me.boysnnoco.FastBow.FastBowListener.onLaunch(FastBowListener.java:37) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_40]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_40]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_40]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_40]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
        ... 19 more
    
    I have no idea on why it is null any help would be appreciated thanks!

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    xTigerRebornx

    boysnnoco
    You should only bump every 24hrs :p
    Code:
    at me.boysnnoco.FastBow.FastBowCheck.check(FastBowCheck.java:19) ~[?:?]
        at me.boysnnoco.FastBow.FastBowListener.onLaunch(FastBowListener.java:37)
    What is on these two lines?
     
  3. Offline

    boysnnoco

    xTigerRebornx I fixed the problem, when I removed the static modifiers on my methods it messed them up a bit. But thanks for replying!
     
Thread Status:
Not open for further replies.

Share This Page