Get Shooter Snowball PlayerDeathEvent

Discussion in 'Plugin Development' started by Hugi21, Aug 30, 2015.

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

    Hugi21

    Hello today I need help right now I'm developing a plugin "PaintBall" and ammunition are snowballs. The problem is that I made a kill of meter by one team but I can not pick the player with the launch snowballs in a PlayerDeathEvent. Thank you in advance, truthfully yours Hugi21
     
  2. Offline

    mine-care

    @Hugi21 Can we see the launch of snowbals part? are you setting the snowbal shooter to the player?
     
  3. Offline

    Hugi21

    @mine-care I do not understand what you say but here one of manners I use to retrieve the shooter snowball (I 'm French)
    Code:
     if(e.getEntity().getKiller() instanceof Snowball){
                Snowball projectile = (Snowball)e.getEntity().getKiller();
              Player shoot  =  (Player ) projectile.getShooter();
    
                if(shoot.getScoreboard().getPlayerTeam(shoot).equals(sbt.blue)){
      
                    sbt.blueKill++;
                }
    
                if(shoot.getScoreboard().getPlayerTeam(shoot).equals(sbt.red)){
                    sbt.redKill++;
                }
    
    and so obviously this way to recover the player does not work
     
  4. Offline

    blackpoiso

    So this is in a PlayerDeathEvent? For a paintball plugin, wouldn't it be better to do EntityDamagedByEntityEvent? Then check if the damager is a snowball, then check for the shooter?
     
  5. Offline

    Zombie_Striker

    So what you're saying is that this line does not work?

    You can do one of two things, add a if statement to check if the shooter is an instanceof player, or add a map that contains snowballs as the key, and players as the value. All you would have to do is put in the key (HasMap.put(Snowball,player)), and you can get the player (Player p = HashMap.get(Snowball))
     
  6. Offline

    Hugi21

    @Zombie_Striker I see pretty much what you want to say but can you put in code to make it more explicit for me thank you anyway for your help

    @blackpoiso No I use PlayerDeathEvent because I want do a Kill Count in Scoreboard and so I must be recovered the shooter of snowball to add to his team kill

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Aug 31, 2015
Thread Status:
Not open for further replies.

Share This Page