Solved onEntityDamageByEntity Error With (Unknown Source)

Discussion in 'Plugin Development' started by Tenetri, Oct 8, 2012.

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


    I've been getting a reallllly weird errror in my plugin.

    2012-10-09 01:31:29 [SEVERE] Could not pass event EntityDamageByEntityEvent to ZombieEscape
        at org.bukkit.plugin.RegisteredListener.callEvent(
        at org.bukkit.plugin.SimplePluginManager.fireEvent(
        at org.bukkit.plugin.SimplePluginManager.callEvent(
        at org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(
        at org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDamageEvent(
        at org.bukkit.craftbukkit.event.CraftEventFactory.handleEntityDamageEvent(
        at net.minecraft.server.EntityLiving.damageEntity(
        at net.minecraft.server.EntityHuman.damageEntity(
        at net.minecraft.server.EntityPlayer.damageEntity(
        at net.minecraft.server.EntitySmallFireball.a(
        at net.minecraft.server.EntityFireball.h_(
        at net.minecraft.server.World.entityJoinedWorld(
        at net.minecraft.server.WorldServer.entityJoinedWorld(
        at net.minecraft.server.World.playerJoinedWorld(
        at net.minecraft.server.World.tickEntities(
        at net.minecraft.server.WorldServer.tickEntities(
        at net.minecraft.server.MinecraftServer.q(
        at net.minecraft.server.DedicatedServer.q(
        at net.minecraft.server.MinecraftServer.p(
    Caused by: java.lang.NullPointerException
        at me.Tenetri.zombieescape.ZombieEscape.onEntityDamageByEntity(
        at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        ... 21 more
    Line 1892 is

    Player player = (Player) event.getEntity();
    and the code around it is this...

        public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
    Entity Damager = event.getDamager();
                if (event.getEntity() instanceof Player && Damager instanceof Projectile)
                    Player player = (Player) event.getEntity();
    I'm not sure why this is happening, its really bothering me. Any help is greatly appreciated!
  2. Offline


    Well, I can't be sure of it, but maybe, JUST MAYBE, before you check if the damaged entity is a player, you have to cast it to be a damaged entity. I doubt this is it. :p

    Entity damaged = event.getEntity();
    Entity damager = event.getDamager();
    if(damaged instanceof Player && damager instanceof Projectile)
        Player harmed = (Player) damaged;
        Projectile proj = (Projectile) damager;
    Tenetri likes this.
  3. Offline


    Excellent! Thank you so much! <3 Fixed the error right up!

    Not sure what was causing it, but its gone now. It was coming up like crazy.

    Thankyou, i'm gunna edit the title to solved

    I guess I can't edit the title. I must just not know how.

    If anyone can edit the title, something better would be

    '[Solved] onEntityDamageByEntity Error With (Unknown Source)'

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  4. Offline


    To edit thread title, go to plugin development forum, on under the title of your post on the list of posts, there's an edit button. Click prefix > solved
  5. Offline


  6. Offline


    You were trying to cast the Entity as a player prematurely. I bet that was it.
Thread Status:
Not open for further replies.

Share This Page