set last damager

Discussion in 'Plugin Development' started by Mr. Sandwich, May 27, 2016.

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

    Mr. Sandwich

    Hey so I am trying to blow up an entity but I need the server to know that the player is the cause of this explosion (I also dont know how to play an explosion particle so help with that will be great too)
    Code:
    pp.playSound(e.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 10, 10);
    ((Damageable) en).damage(5);
    .
    .
    .
                              if (runningTime.get(e.getPlayer()) > 10) { //I need a way for the server to know that who did the explosion is this player(that's getting the strength effect also this is in PlayerMoveEvent)
                                    e.getPlayer().removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
                                    e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,19,5));
                                }
    
     
  2. Offline

    Zombie_Striker

    @Mr. Sandwich
    Why can't you just use World#createExplosion()? This will play the sound and create the particles. If you don't want it to damage the terrain, set the power to 0.
     
  3. Offline

    Mr. Sandwich

    Okay but that still doesnt solve my problem..

    EDIT: Also I dont want the explosion to destroy item frames so I prefer using what I have
    Code:
                                          e.getPlayer().getWorld().playEffect(e.getPlayer().getLocation(),Effect.EXPLOSION_HUGE,1);
                                            pp.playSound(e.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 10, 10);
                                          ((Damageable) en).damage(5);
    
     
    Last edited: May 27, 2016
  4. Offline

    Mr. Sandwich

  5. Offline

    Mr. Sandwich

  6. Offline

    Mr. Sandwich

    bump.....
     
  7. Offline

    flash110

    You can save the player and the "explosion" in a hashmap and if the explosion kills a player it uses the explosion as a key and gets the value of the player. I'm on my phone right now, but I will try this out when I get home. And can you tell me what kind of explosion it will be, like how the explosion will occur.
     
  8. Offline

    Mr. Sandwich

    " if the explosion kills a player" I don't know how to get it to know if it killed a player and the explosion occurs when a player is sprinting into an entity
     
Thread Status:
Not open for further replies.

Share This Page