org.bukkit.entity.ThrownExpBottle Java Examples

The following examples show how to use org.bukkit.entity.ThrownExpBottle. 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: ExpCapListener.java    From NyaaUtils with MIT License 5 votes vote down vote up
@EventHandler
public void onExpCapThrown(ProjectileLaunchEvent event) {
    if (!cfg.expcap_thron_enabled) return;
    if (event.getEntity() instanceof ThrownExpBottle) {
        ProjectileSource shooter = event.getEntity().getShooter();
        if (shooter instanceof Player) {
            event.getEntity().setMetadata("nu_expcap_exp",
                    new FixedMetadataValue(plugin,
                            thrownExpMap.computeIfAbsent(((Player) shooter).getUniqueId(), uuid -> 0)
                    )
            );
        }
    }
}
 
Example #2
Source File: ExpBottleEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public ExpBottleEvent(final ThrownExpBottle bottle, final int exp) {
    super(bottle);
    this.exp = exp;
}
 
Example #3
Source File: ExpBottleEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ThrownExpBottle getEntity() {
    return (ThrownExpBottle) entity;
}
 
Example #4
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 #5
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static ExpBottleEvent callExpBottleEvent(net.minecraft.entity.Entity entity, int exp) {
    ThrownExpBottle bottle = (ThrownExpBottle) entity.getBukkitEntity();
    ExpBottleEvent event = new ExpBottleEvent(bottle, exp);
    Bukkit.getPluginManager().callEvent(event);
    return event;
}