Solved Just Wondering...

Discussion in 'Plugin Development' started by Arjuncraft, Jul 21, 2015.

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

    Arjuncraft

    How exactly does Bukkit "label" someone as the killer of another. I looked through the source code, and all I found was the getKiller() method in the interface LivingEntity (which obviously didn't help since its just an interface). I'm just curious because I want to know whether a plugin I am working on (which incorporates its own PvP system) will still be able to accurately label a killer.

    Thanks!

    Edit: I figured out the solution by looking through the original net.minecraft.server source code. Here is an example below:

    Player killer;
    Player victim;
    EntityDamageSource d = new EntityDamageSource("player", killer);
    victim.damageEntity(DamageSource.d, Float.MAX_VALUE);
     
    Last edited: Jul 21, 2015
  2. Offline

    xTrollxDudex

    You need to look through the implementation (CraftBukkit, Spigot) source code. It is most likely in net.minecraft.server, but I am not precisely sure where.
     
  3. Offline

    Arjuncraft

    I looked through net.minecraft.server. I found that it labels killers by "Damage Source", which I am pretty sure means was whatever thing dealt the last strike, whether it be mob, anvil, etc. So to have someone kill something and be labeled, I figure you can do this:

    Player killer;
    Player victim;
    EntityDamageSource d = new EntityDamageSource("player", killer);
    victim.damageEntity(DamageSource.d, Float.MAX_VALUE);

    Guess that answers my own question..
     
  4. Offline

    Tecno_Wizard

    @Arjuncraft, not many people would be willing to dig through the server code to answer their own question. I applaud you for that.

    Please mark as solved.
     
Thread Status:
Not open for further replies.

Share This Page