Solved How to Detect the Player That Threw an Egg

Discussion in 'Plugin Development' started by Mr_Gibbles, Jan 21, 2014.

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

    Mr_Gibbles

    I have this code down, and it works but I want it so that if they're in the "bomber" ArrayList than it will only allow them to get the ability. I know that you use
    Code:java
    1. if (bomber.contains()) {
    2. }

    But Idk what to put in the contains brackets because if you use e.getEntity() than it will use the snowball. Anyways heres the code:
    Code:java
    1. @EventHandler
    2. public void onProjectileHit(ProjectileHitEvent e) {
    3. if (e.getEntity().getType() == EntityType.EGG) {
    4. Location l = e.getEntity().getLocation();
    5. e.getEntity().getWorld().createExplosion(l.getX(), l.getY(), l.getZ(), 2F, false, false);
    6. }
    7. }
     
  2. Offline

    Warreo

    Well what kind of ArrayList is it? That will determine what you need, what I'd recommend is using a String ArrayList and put the player's names in the ArrayList, when the egg hits, check if the entity is a player, if so check if the ArrayList contains the player's name. :)
     
  3. Offline

    xboxnolifes

    I'm not sure exactly how your plugin is setup, but try this.

    Code:java
    1.  
    2. e.getEntity().getShooter()
     
  4. Offline

    Mr_Gibbles

    Oh that worked, thanks
     
Thread Status:
Not open for further replies.

Share This Page