org.bukkit.entity.EnderPearl Java Examples

The following examples show how to use org.bukkit.entity.EnderPearl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SlimefunBootsListener.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
public SlimefunBootsListener(SlimefunPlugin plugin) {
    plugin.getServer().getPluginManager().registerEvents(this, plugin);

    cancelledEvents.put("ENDER_BOOTS", e -> e instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) e).getDamager() instanceof EnderPearl);

    cancelledEvents.put("BOOTS_OF_THE_STOMPER", e -> {
        if (e.getCause() == DamageCause.FALL) {
            stomp(e);
            return true;
        }

        return false;
    });

    cancelledEvents.put("SLIME_BOOTS", e -> e.getCause() == DamageCause.FALL);

    cancelledEvents.put("SLIME_STEEL_BOOTS", e -> e.getCause() == DamageCause.FALL);
}
 
Example #2
Source File: ResetEnderPearlsKit.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void applyPostEvent(MatchPlayer player, boolean force, List<ItemStack> displacedItems) {
  Player bukkitPlayer = player.getBukkit();
  for (EnderPearl pearl : bukkitPlayer.getWorld().getEntitiesByClass(EnderPearl.class)) {
    if (pearl.getShooter() == bukkitPlayer) {
      pearl.setShooter(null);
    }
  }
}
 
Example #3
Source File: PGMListener.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void clearActiveEnderPearls(final PlayerDeathEvent event) {
  for (Entity entity : event.getEntity().getWorld().getEntitiesByClass(EnderPearl.class)) {
    if (((EnderPearl) entity).getShooter() == event.getEntity()) {
      entity.remove();
    }
  }
}
 
Example #4
Source File: ResetEnderPearlsKit.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void apply(MatchPlayer player, boolean force, ItemKitApplicator items) {
    Player bukkitPlayer = player.getBukkit();
    for(EnderPearl pearl : bukkitPlayer.getWorld().getEntitiesByClass(EnderPearl.class)) {
        if(pearl.getShooter() == bukkitPlayer) {
            pearl.setShooter(null);
        }
    }
}
 
Example #5
Source File: PGMListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void clearActiveEnderPearls(final PlayerDeathEvent event) {
    for(Entity entity : event.getEntity().getWorld().getEntitiesByClass(EnderPearl.class)) {
        if(((EnderPearl) entity).getShooter() == event.getEntity()) {
            entity.remove();
        }
    }
}
 
Example #6
Source File: MagicEyeOfEnder.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        e.cancel();

        Player p = e.getPlayer();

        if (hasArmor(p.getInventory())) {
            p.launchProjectile(EnderPearl.class);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
        }
    };
}
 
Example #7
Source File: CraftLivingEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
    net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle();
    net.minecraft.entity.Entity launch = null;

    if (Snowball.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntitySnowball(world, getHandle());
    } else if (Egg.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityEgg(world, getHandle());
    } else if (EnderPearl.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.item.EntityEnderPearl(world, getHandle());
    } else if (Arrow.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityArrow(world, getHandle(), 1);
    } else if (ThrownPotion.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1)));
    } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.item.EntityExpBottle(world, getHandle());
    } else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof net.minecraft.entity.player.EntityPlayer) {
        launch = new net.minecraft.entity.projectile.EntityFishHook(world, (net.minecraft.entity.player.EntityPlayer) getHandle());
    } else if (Fireball.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        Vector direction = location.getDirection().multiply(10);

        if (SmallFireball.class.isAssignableFrom(projectile)) {
            launch = new net.minecraft.entity.projectile.EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else if (WitherSkull.class.isAssignableFrom(projectile)) {
            launch = new net.minecraft.entity.projectile.EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else {
            launch = new net.minecraft.entity.projectile.EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        }

        ((net.minecraft.entity.projectile.EntityFireball) launch).projectileSource = this;
        launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    }

    Validate.notNull(launch, "Projectile not supported");

    if (velocity != null) {
        ((T) launch.getBukkitEntity()).setVelocity(velocity);
    }

    world.spawnEntityInWorld(launch);
    return (T) launch.getBukkitEntity();
}
 
Example #8
Source File: EnderBow.java    From NBTEditor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onShootBow(EntityShootBowEvent event, DelayedPlayerDetails details) {
	Entity perl = event.getEntity().launchProjectile(EnderPearl.class);
	perl.setVelocity(event.getProjectile().getVelocity());
	event.setProjectile(perl);
}