Search in sources :

Example 91 with PotionEffect

use of org.bukkit.potion.PotionEffect in project Glowstone by GlowstoneMC.

the class BeaconEntity method applyPotionEffects.

private void applyPotionEffects() {
    Beacon beacon = (Beacon) getBlock().getState();
    beacon.getEntitiesInRange().forEach(livingEntity -> {
        for (BeaconEffectPriority priority : BeaconEffectPriority.values()) {
            PotionEffect effect = this.getEffect(priority);
            if (effect == null) {
                continue;
            }
            BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) livingEntity, priority == BeaconEffectPriority.PRIMARY);
            if (!EventFactory.getInstance().callEvent(event).isCancelled()) {
                livingEntity.addPotionEffect(event.getEffect(), true);
            }
        }
    });
}
Also used : BeaconEffectEvent(com.destroystokyo.paper.event.block.BeaconEffectEvent) PotionEffect(org.bukkit.potion.PotionEffect) Beacon(org.bukkit.block.Beacon) GlowBeacon(net.glowstone.block.entity.state.GlowBeacon)

Example 92 with PotionEffect

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

the class EnderDragonEndermiteBombardment method taskBehavior.

@Override
public void taskBehavior(EliteEntity eliteEntity) {
    try {
        Vector direction = eliteEntity.getLivingEntity().getLocation().getDirection();
        float rotation = (float) (Math.atan2(direction.getX(), direction.getZ()) * 180 / Math.PI);
        Vector direction1 = new Vector(1, -4, 0);
        Vector direction2 = new Vector(-1, -4, 0);
        direction1 = direction1.rotateAroundY(rotation);
        direction2 = direction2.rotateAroundY(rotation);
        CustomBossEntity customBossEntity1 = CustomBossEntity.createCustomBossEntity("binder_of_worlds_phase_1_endermite_reinforcement.yml");
        customBossEntity1.spawn(eliteEntity.getLivingEntity().getLocation().clone().add(direction1), false);
        customBossEntity1.getLivingEntity().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20 * 5, 0));
        eliteEntity.addReinforcement(customBossEntity1);
        CustomBossEntity customBossEntity2 = CustomBossEntity.createCustomBossEntity("binder_of_worlds_phase_1_endermite_reinforcement.yml");
        customBossEntity2.spawn(eliteEntity.getLivingEntity().getLocation().clone().add(direction2), false);
        customBossEntity2.getLivingEntity().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20 * 5, 0));
        eliteEntity.addReinforcement(customBossEntity2);
    } catch (Exception ex) {
        new WarningMessage("Failed to spawn binder of world's reinforcement endermite!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) PotionEffect(org.bukkit.potion.PotionEffect) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Vector(org.bukkit.util.Vector)

Example 93 with PotionEffect

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

the class AttackWeakness method attackWeakness.

@EventHandler
public void attackWeakness(PlayerDamagedByEliteMobEvent event) {
    if (event.isCancelled())
        return;
    AttackWeakness attackWeakness = (AttackWeakness) event.getEliteMobEntity().getPower(this);
    if (attackWeakness == null)
        return;
    if (attackWeakness.isInGlobalCooldown())
        return;
    attackWeakness.doGlobalCooldown(20 * 10);
    event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 20 * 3, 0));
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) EventHandler(org.bukkit.event.EventHandler)

Example 94 with PotionEffect

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

the class AttackWither method onHit.

@EventHandler
public void onHit(PlayerDamagedByEliteMobEvent event) {
    if (event.isCancelled())
        return;
    AttackWither attackWither = (AttackWither) event.getEliteMobEntity().getPower(this);
    if (attackWither == null)
        return;
    event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * 2, 1));
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) EventHandler(org.bukkit.event.EventHandler)

Example 95 with PotionEffect

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

the class AttackPoison method onHit.

@EventHandler
public void onHit(PlayerDamagedByEliteMobEvent event) {
    if (event.isCancelled())
        return;
    AttackPoison attackPoison = (AttackPoison) event.getEliteMobEntity().getPower(this);
    if (attackPoison == null)
        return;
    event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.POISON, 20 * 2, 3));
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) EventHandler(org.bukkit.event.EventHandler)

Aggregations

PotionEffect (org.bukkit.potion.PotionEffect)238 Player (org.bukkit.entity.Player)66 LivingEntity (org.bukkit.entity.LivingEntity)42 PotionEffectType (org.bukkit.potion.PotionEffectType)41 Location (org.bukkit.Location)40 EventHandler (org.bukkit.event.EventHandler)36 ItemStack (org.bukkit.inventory.ItemStack)34 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)25 PotionMeta (org.bukkit.inventory.meta.PotionMeta)17 Vector (org.bukkit.util.Vector)17 Random (java.util.Random)14 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)13 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)13 ItemMeta (org.bukkit.inventory.meta.ItemMeta)10 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)9 Material (org.bukkit.Material)7 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)6 Block (org.bukkit.block.Block)6 Enchantment (org.bukkit.enchantments.Enchantment)6