Stop Projectile Pickup

Discussion in 'Spigot Plugin Development' started by eli.musgrove9, May 5, 2015.

  1. I need to stop players from farming arrows. I am using the shootArrow() method in my plugin, and I want to stop players from picking up arrows that have been shot (kind of like how you can't pickup arrows show by an infinity bow from the ground).

    Does not work!
    Code (Text):
    ItemStack all = new ItemStack(e.getItem().getItemStack());
                if (all instanceof Projectile) {
  2. ItemStack is not a Projectile subclass.
  3. What should I use? How can I test if it is a projectile on the ground, not a dropped arrow?
  4. Anybody got any ideas??
  5. maybe this.

    Code (Text):
    public void onArrowPickup(PlayerPickupItemEvent event){
    Player player = event.getPlayer();
    if(event.getItem() == new ItemStack(Material.ARROW)){
    too lazy to test it out.
  6. This also blocks the dropped arrow (with q/clicked off inventory). I only want to stop the projectile shot into the ground to not be picked up. (Kinda confusing above)
  7. Anybody got any ideas? What type of object is an arrow when it is shot into the ground??
  8. If you don't want players picking up arrows, why not just delete the arrow when it hits the ground? This is great because if you have a lot of players, it could reduce a little lag. Also makes your world look cleaner.
  9. I tried this with the ItemDespawnEvent, but it only works on items. Do you know an event that works for arrows?
  10. Yeah, since an arrow is an entity and a projectile, use this:
    Code (Text):
        public void onArrowHit(ProjectileHitEvent e) {
    • Like Like x 1
  11. You saved my life. I didn't know what event to use!!!!!!!
  12. :D