Search in sources :

Example 96 with PotionEffect

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

the class AttackConfusing method attackConfusing.

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

Example 97 with PotionEffect

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

the class ItemFishRaw method eat.

@Override
public boolean eat(GlowPlayer player, ItemStack item) {
    if (!super.eat(player, item)) {
        return false;
    }
    if (item.getData().getData() == 3) {
        player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, TickUtil.minutesToTicks(1), 3), true);
        player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, TickUtil.secondsToTicks(15), 2), true);
        player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, TickUtil.secondsToTicks(15), 1), true);
    }
    return true;
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect)

Example 98 with PotionEffect

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

the class ItemBowTest method testTippedArrow.

@Test
public void testTippedArrow() {
    ItemStack arrow = new ItemStack(Material.TIPPED_ARROW, 1);
    GlowMetaPotion potion = new GlowMetaPotion(arrow.getItemMeta());
    potion.setColor(Color.PURPLE);
    final PotionData potionData = new PotionData(PotionType.FIRE_RESISTANCE);
    potion.setBasePotionData(potionData);
    final PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 10, 1);
    potion.addCustomEffect(effect, false);
    assertTrue(arrow.setItemMeta(potion));
    inventory.addItem(arrow);
    // Should now be able to start shooting
    bow.startUse(player, bowItemStack);
    verify(player, times(1)).setUsageItem(bowItemStack);
    verify(player, times(1)).setUsageTime(anyInt());
    when(player.getUsageTime()).thenReturn(10);
    // Finish shooting
    bow.endUse(player, bowItemStack);
    verify(player, times(1)).launchProjectile(TippedArrow.class);
    verify(launchedTippedArrow, times(1)).setColor(Color.PURPLE);
    verify(launchedTippedArrow, times(1)).setBasePotionData(potionData);
    verify(launchedTippedArrow, times(1)).addCustomEffect(eq(effect), anyBoolean());
    verify(player, times(1)).setUsageItem(null);
    verify(player, times(1)).setUsageTime(0);
    checkInventory(inventory, 1, BOW_WITH_DAMAGE_1);
    checkInventory(inventory, 0, BOW_WITH_DAMAGE_NOT_1);
    checkInventory(inventory, 0, item -> ARROW_TYPES.contains(item.getType()));
}
Also used : PotionData(org.bukkit.potion.PotionData) GlowMetaPotion(net.glowstone.inventory.GlowMetaPotion) PotionEffect(org.bukkit.potion.PotionEffect) ItemStack(org.bukkit.inventory.ItemStack) Test(org.junit.jupiter.api.Test)

Example 99 with PotionEffect

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

the class GlowMetaPotion method copyFrom.

/**
 * Copies potion data from another instance
 *
 * @param source The object to copy from
 */
public void copyFrom(PotionMeta source) {
    setBasePotionData(source.getBasePotionData());
    setColor(source.getColor());
    for (PotionEffect effect : source.getCustomEffects()) {
        addCustomEffect(effect, true);
    }
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect)

Example 100 with PotionEffect

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

the class GlowMetaPotion method fromNbt.

/**
 * Reads a {@link PotionEffect} from an NBT compound tag.
 *
 * @param tag a potion effect NBT compound tag
 * @return {@code tag} as a {@link PotionEffect}
 */
public static PotionEffect fromNbt(CompoundTag tag) {
    PotionEffectType type = PotionEffectType.getById(tag.getByte("Id"));
    int duration = tag.getInt("Duration");
    int amplifier = tag.getByte("Amplifier");
    boolean ambient = tag.getBoolean("Ambient", false);
    boolean particles = tag.getBoolean("ShowParticles", true);
    return new PotionEffect(type, duration, amplifier, ambient, particles);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) PotionEffectType(org.bukkit.potion.PotionEffectType)

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