Backstabbing Players

Discussion in 'Plugin Development' started by Eller, Feb 14, 2015.

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


    Hey guys, So I was making an Assassin kit for my KitPvP server.
    And I would like to make you insta-kill someone if you him him with shears in the back.
    This is my code currently:

    Thanks in advance!
  2. Offline


    I would do p.setHealth(0.0) personally, the rest looks good to me.
  3. Offline


    What your problem was, was that you were checking if the damagee had the shears.
    You want to check if damager had the shears so quick fix.

        public void onBackstab(EntityDamageByEntityEvent e) {
            if(e.getEntity() instanceof Player && e.getDamager() instanceof Player){
                Player d = (Player) e.getDamager();
                Player p = (Player) e.getEntity();
                    // this below was p.getItemInHand().getType() == Material.SHEARS
                    // need to be what it is now
                    if(d.getItemInHand().getType() == Material.SHEARS){
                        if(p.getLocation().getYaw() > d.getLocation().getYaw()-40 && p.getLocation().getYaw() < d.getLocation().getYaw()+40){
    If this solved your problem than don't forget to set this thread prefix to [Solved]

    If you think i helped then leave a like :D
    Last edited: Feb 14, 2015
    Eller likes this.
  4. Offline


    You should use the vectors of both players to see if they are pointing the same direction.
  5. Offline


    Already done that, the code works without errors
  6. Offline


    @Ruptur Thanks I'll try it out! I see what I have done wrongly ... Stupid me :p Thanks for the help ill leave a like
Thread Status:
Not open for further replies.

Share This Page