Solved Problems with ProjectileHit

Discussion in 'Plugin Development' started by diamante0018, Sep 13, 2016.

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

    diamante0018

    Hi guys I have a problem with deleting the landing event of the Ender Pearl because I would like to cancel the landing event to prevent the player from getting damage and do other stuff after that.
    Here's what happens: I throw an Ender Pearl it lands somewhere it teleports me there and I take damage, I want to delete from the teleport part but still make the Ender Pearl land where it should go.
    Can you guys tell me why it doesn't work?

    Code:
    public class EnderPearlDelete extends JavaPlugin implements Listener
    {
        public void onEnable ()
        {
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
    
        @EventHandler
    
        public void onProjectileHit (ProjectileHitEvent event)
          {
            if (event.getEntity() instanceof EnderPearl)
              {
                event.getEntity().remove();
              }
          }
    
    }
     
    Last edited: Sep 13, 2016
  2. Offline

    ipodtouch0218

    You want the ender pearl to go where it should, but not teleport you?
    Use the PlayerTeleportEvent and check if the event.getCause() == TeleportCause.ENDER_PEARL
     
  3. Offline

    diamante0018

    Thanks it works now!
     
Thread Status:
Not open for further replies.

Share This Page