onPlayerDeath

Discussion in 'Plugin Development' started by user-12202018, Feb 29, 2012.

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

    user-12202018

    Hey,
    can anyone tell me whats wrong with this:
    PHP:
    @EventHandler(priority EventPriority.NORMAL)
        public 
    void onEntityDeath(EntityDeathEvent event)
        {
            if(
    event.getEntity() instanceof Player)
            {
                
    mainClass.log.info("YES");
                
    Player player = (Playerevent.getEntity();
                
    mainClass.log.info("Name: " player.getDisplayName());
            }
        }
    I get this exception in the console:

    PHP:
    Could not pass event org.bukkit.event.entity.PlayerDeathEvent to vMod
    org
    .bukkit.event.EventException
     
  2. Offline

    Njol

    This is only the first line of the exception, which is basically saying that en exception occurred within a listener.
    Look at the end of the stack trace, there should be another exception which will be the one caused by your plugin.
     
  3. Offline

    wirher

    Full stack please.
     
  4. Offline

    user-12202018

    Copied directly from the console:

    PHP:
    07:16:04 [SCHWERWIEGENDCould not pass event org.bukkit.event.entity.PlayerDeat
    hEvent to vServerInfo
    org
    .bukkit.event.EventException
            at org
    .bukkit.plugin.java.JavaPluginLoader$103.execute(JavaPluginLoader.
    java:1026)
            
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a
    :61)
            
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava
    :460)
            
    at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerDeathEvent(C
    raftEventFactory
    .java:367)
            
    at net.minecraft.server.EntityPlayer.die(EntityPlayer.java:171)
            
    at net.minecraft.server.EntityLiving.damageEntity(EntityLiving.java:546)
     
            
    at net.minecraft.server.EntityHuman.damageEntity(EntityHuman.java:612)
            
    at net.minecraft.server.EntityPlayer.damageEntity(EntityPlayer.java:213)
     
            
    at net.minecraft.server.EntityLiving.b(EntityLiving.java:701)
            
    at net.minecraft.server.EntityHuman.b(EntityHuman.java:1178)
            
    at net.minecraft.server.Entity.a(Entity.java:686)
            
    at net.minecraft.server.EntityPlayer.b(EntityPlayer.java:448)
            
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:396)
            
    at net.minecraft.server.Packet10Flying.handle(SourceFile:126)
            
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
            
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:100)
            
    at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:7
    8
    )
            
    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:537)
            
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:435)
            
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
    Caused byjava.lang.reflect.InvocationTargetException
            at sun
    .reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            
    at java.lang.reflect.Method.invoke(Unknown Source)
            
    at org.bukkit.plugin.java.JavaPluginLoader$103.execute(JavaPluginLoader.
    java:1024)
            ... 
    19 more
    Caused by
    java.lang.NoSuchMethodErrororg.bukkit.event.entity.EntityDeathEvent
    .getEntity()Lorg/bukkit/entity/LivingEntity;
            
    at de.vanoq.vServerInfo.PlayerInfoListener.onEntityDeath(PlayerInfoListe
    ner
    .java:71)
            ... 
    24 more
    07
    :16:06 [INFORMATIONVanoq lost connectiondisconnect.quitting
     
  5. Offline

    stelar7

    NoSuchMethodError: org.bukkit.event.entity.EntityDeathEvent.getEntity()
    at de.vanoq.vServerInfo.PlayerInfoListener.onEntityDeath(PlayerInfoListener.java:71)
     
  6. Offline

    dockter

    Im getting a very similar error using this:

    Code:
    public void onEntityDeath(EntityDeathEvent event) {
            if (event.getEntity() instanceof Player) {
    Getting this error: java.lang.NoSuchMethodError: org.bukkit.event.entity.EntityDeathEvent.getEntity()Lorg/bukkit/entity/LivingEntity;
     
  7. Offline

    user-12202018

    Yea i already saw this but the functions exists in the java doc.
    Is there any other way of reacting to the death of a player?
     
  8. Offline

    dockter

  9. Offline

    Choltfo

    Hi, question, how do i deduce the name of the player who died? Thanks.
     
  10. Offline

    jis2507

    Using his above code: you would use:

    Code:
    String playerName = player.getName();
     
Thread Status:
Not open for further replies.

Share This Page