Solved Make a player damage another

Discussion in 'Plugin Development' started by JoltTheBolt, Apr 14, 2022.

  1. Offline

    JoltTheBolt

    Is there a way to make a player damage another. I do not mean player#damage(amount) because that just damages. I mean damage in such a way that, for example, if a player dies the damager is returned on #getKiller.

    And if this isn't possible, is it possible to KILL completely another player by this player (instead of just damage)?

    One solution was to call a new entity damage event but I am not completely sure how that works.

    Thank you for any reply or help.

    NEVERMIND! It worked! I'm gonna keep this here for a future traveler.
    Code:
    Bukkit.getPluginManager().callEvent(new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,5));
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.

    EDIT: WOW, no one told me and I am so dumb!
    One can simply do
    Code:
    entity.damage(amount,source);
     
    Last edited: Apr 14, 2022

Share This Page