Solved How to get the projectile shooter in Bukkit 1.7.2 and above?

Discussion in 'Plugin Development' started by Tim Visee, Feb 15, 2014.

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

    Tim Visee

    Hello,

    I just updated the API I was using in Safe Creeper to the newest available version (Bukkit-1.7.2-R0.3 to be specific) and I discovered the usage of the Projectile.getShooter(); method caused an error due to the fact the return type was changed in the latest Bukkit versions.

    I would like to get the shooter (as LivingEntity) from a projectile. Previously you could use the following method;

    Code:java
    1. Projectile p;
    2. LivingEntity le = p.getShooter();


    In a recent update of Bukkit (I think this was changed since the first 1.7.2 release) they changed the return type of the method;

    Code:java
    1. Projectile p;
    2. ProjectileSource le = p.getShooter();

    I can't seem to find any way to get the LivingEntity type from the ProjectileSource instance. So how should this be done with the new Bukkit versions, getting the LivingEntity shooter of a projectile.

    Thanks in advance,
    Tim Visée
     
  2. Offline

    Wolvereness Bukkit Team Member

    Dispensers aren't living. Just do an if-instanceof-cast.
     
  3. Offline

    Tim Visee

    I thought this wouldn't work because the ProjectileSource doesn't seem to extend the LivingEntity class, but will give it a try now though!

    Tim Visée
     
  4. Offline

    DarkBladee12

    Tim Visee The LivingEntity class does extend as ProjectileSource which can be seen here:

    [​IMG]

    But you can't see that in the JavaDocs because they're not up-to-date!
     
  5. Offline

    frymaster

  6. Offline

    Tim Visee

    Thank you very much guys, I wasn't able to find the proper Java docs indeed. That's why I assumed the classes didn't extend each other. So now since I know this, I'll be able to solve my issue. Thanks again guys.

    Tim Visée
     
Thread Status:
Not open for further replies.

Share This Page