Search in sources :

Example 21 with PotionEffect

use of org.bukkit.potion.PotionEffect in project EliteMobs by MagmaGuy.

the class MovementSpeed method applyPowers.

@Override
public void applyPowers(Entity entity) {
    entity.setMetadata(powerMetadata, new FixedMetadataValue(plugin, true));
    ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2));
    MinorPowerPowerStance minorPowerPowerStance = new MinorPowerPowerStance();
    minorPowerPowerStance.itemEffect(entity);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) PotionEffect(org.bukkit.potion.PotionEffect) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) MinorPowerPowerStance(com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)

Example 22 with PotionEffect

use of org.bukkit.potion.PotionEffect in project Essentials by drtshock.

the class Commandheal method healPlayer.

private void healPlayer(final User user) throws PlayerExemptException, QuietAbortException {
    final Player player = user.getBase();
    if (player.getHealth() == 0) {
        throw new PlayerExemptException(tl("healDead"));
    }
    final double amount = player.getMaxHealth() - player.getHealth();
    final EntityRegainHealthEvent erhe = new EntityRegainHealthEvent(player, amount, RegainReason.CUSTOM);
    ess.getServer().getPluginManager().callEvent(erhe);
    if (erhe.isCancelled()) {
        throw new QuietAbortException();
    }
    double newAmount = player.getHealth() + erhe.getAmount();
    if (newAmount > player.getMaxHealth()) {
        newAmount = player.getMaxHealth();
    }
    player.setHealth(newAmount);
    player.setFoodLevel(20);
    player.setFireTicks(0);
    user.sendMessage(tl("heal"));
    for (PotionEffect effect : player.getActivePotionEffects()) {
        player.removePotionEffect(effect.getType());
    }
}
Also used : Player(org.bukkit.entity.Player) EntityRegainHealthEvent(org.bukkit.event.entity.EntityRegainHealthEvent) PotionEffect(org.bukkit.potion.PotionEffect)

Example 23 with PotionEffect

use of org.bukkit.potion.PotionEffect in project InfernalMobs by NyaaCat.

the class AbilityPotions method onPlayerAttack.

@Override
public void onPlayerAttack(LivingEntity mobEntity, Mob mob, Player attacker, boolean isDirectAttack, EntityDamageByEntityEvent ev) {
    if (Helper.possibility(0.3))
        return;
    Vector velocity = attacker.getEyeLocation().toVector().subtract(mobEntity.getEyeLocation().toVector());
    velocity.multiply(1D / 15D);
    velocity.add(new Vector(0, 0.2, 0));
    ThrownPotion t = mobEntity.launchProjectile(ThrownPotion.class, velocity);
    ItemStack item = new ItemStack(Material.SPLASH_POTION);
    PotionMeta pm = (PotionMeta) item.getItemMeta();
    PotionEffect effect = Helper.randomItem(POTION_EFFECTS);
    pm.addCustomEffect(effect, false);
    pm.setColor(effect.getColor());
    item.setItemMeta(pm);
    t.setItem(item);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) ThrownPotion(org.bukkit.entity.ThrownPotion) PotionMeta(org.bukkit.inventory.meta.PotionMeta) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector)

Example 24 with PotionEffect

use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.

the class EntityMyPet method onLivingUpdate.

public void onLivingUpdate() {
    if (hasRider) {
        if (this.passenger == null || !(this.passenger instanceof EntityPlayer)) {
            hasRider = false;
            // climb height -> halfslab
            this.W = 0.5F;
            Location playerLoc = getOwner().getPlayer().getLocation();
            Location petLoc = getBukkitEntity().getLocation();
            petLoc.setYaw(playerLoc.getYaw());
            petLoc.setPitch(playerLoc.getPitch());
            getOwner().getPlayer().teleport(petLoc);
        }
    } else {
        if (this.passenger != null) {
            if (this.passenger instanceof EntityPlayer) {
                if (getOwner().equals(this.passenger)) {
                    hasRider = true;
                    // climb height -> 1 block
                    this.W = 1.0F;
                    petTargetSelector.finish();
                    petPathfinderSelector.finish();
                } else {
                    // just the owner can ride a pet
                    this.passenger.mount(null);
                }
            } else {
                this.passenger.mount(null);
            }
        }
    }
    if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
        MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "spell", 0F, 0F, 0F, 1F, 3, 32);
        sitCounter = 30;
    }
    Player p = myPet.getOwner().getPlayer();
    if (p != null && p.isOnline() && !p.isDead()) {
        if (p.isSneaking() != isSneaking()) {
            this.setSneaking(!isSneaking());
        }
        if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
            if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
                isInvisible = true;
                getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
            } else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
                getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
                isInvisible = false;
            }
        }
        if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
            donatorParticleCounter = 20 + getRandom().nextInt(10);
            MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
        }
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer) Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) PotionEffect(org.bukkit.potion.PotionEffect) Location(org.bukkit.Location)

Example 25 with PotionEffect

use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.

the class EntityMyPet method onLivingUpdate.

public void onLivingUpdate() {
    if (hasRider) {
        if (this.passenger == null || !(this.passenger instanceof EntityPlayer)) {
            hasRider = false;
            // climb height -> halfslab
            this.S = 0.5F;
            Location playerLoc = getOwner().getPlayer().getLocation();
            Location petLoc = getBukkitEntity().getLocation();
            petLoc.setYaw(playerLoc.getYaw());
            petLoc.setPitch(playerLoc.getPitch());
            getOwner().getPlayer().teleport(petLoc);
        }
    } else {
        if (this.passenger != null) {
            if (this.passenger instanceof EntityPlayer) {
                if (getOwner().equals(this.passenger)) {
                    hasRider = true;
                    // climb height -> 1 block
                    this.S = 1.0F;
                    petTargetSelector.finish();
                    petPathfinderSelector.finish();
                } else {
                    // just the owner can ride a pet
                    this.passenger.mount(null);
                }
            } else {
                this.passenger.mount(null);
            }
        }
    }
    if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
        MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "BARRIER", 0F, 0F, 0F, 5F, 1, 32);
        sitCounter = 60;
    }
    Player p = myPet.getOwner().getPlayer();
    if (p != null && p.isOnline() && !p.isDead()) {
        if (p.isSneaking() != isSneaking()) {
            this.setSneaking(!isSneaking());
        }
        if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
            if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
                isInvisible = true;
                getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
            } else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
                getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
                isInvisible = false;
            }
        }
        if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
            donatorParticleCounter = 20 + getRandom().nextInt(10);
            MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) PotionEffect(org.bukkit.potion.PotionEffect) Location(org.bukkit.Location)

Aggregations

PotionEffect (org.bukkit.potion.PotionEffect)224 Player (org.bukkit.entity.Player)61 PotionEffectType (org.bukkit.potion.PotionEffectType)39 Location (org.bukkit.Location)37 LivingEntity (org.bukkit.entity.LivingEntity)37 EventHandler (org.bukkit.event.EventHandler)36 ItemStack (org.bukkit.inventory.ItemStack)34 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)23 PotionMeta (org.bukkit.inventory.meta.PotionMeta)18 Vector (org.bukkit.util.Vector)16 Random (java.util.Random)14 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)11 ItemMeta (org.bukkit.inventory.meta.ItemMeta)10 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)9 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)9 Material (org.bukkit.Material)7 Enchantment (org.bukkit.enchantments.Enchantment)7 Projectile (org.bukkit.entity.Projectile)7 PotionData (org.bukkit.potion.PotionData)7