Search in sources :

Example 1 with Potion

use of org.bukkit.potion.Potion in project PyrCore by PYRRH4.

the class Compat_1_7_10 method buildPotion.

@Override
public ItemStack buildPotion(PotionType type, int level, boolean extended, boolean splash) {
    Potion potion = new Potion(type, level, splash);
    potion.setHasExtendedDuration(extended);
    ItemStack item = potion.toItemStack(1);
    ;
    return item;
}
Also used : Potion(org.bukkit.potion.Potion) ItemStack(org.bukkit.inventory.ItemStack)

Example 2 with Potion

use of org.bukkit.potion.Potion in project PyrCore by PYRRH4.

the class Compat_1_7_9 method buildPotion.

@Override
public ItemStack buildPotion(PotionType type, int level, boolean extended, boolean splash) {
    Potion potion = new Potion(type, level, splash);
    potion.setHasExtendedDuration(extended);
    ItemStack item = potion.toItemStack(1);
    ;
    return item;
}
Also used : Potion(org.bukkit.potion.Potion) ItemStack(org.bukkit.inventory.ItemStack)

Example 3 with Potion

use of org.bukkit.potion.Potion in project PyrCore by PYRRH4.

the class Compat_1_8_8 method buildPotion.

@Override
public ItemStack buildPotion(PotionType type, int level, boolean extended, boolean splash) {
    Potion potion = new Potion(type, level, splash);
    potion.setHasExtendedDuration(extended);
    ItemStack item = potion.toItemStack(1);
    ;
    return item;
}
Also used : Potion(org.bukkit.potion.Potion) ItemStack(org.bukkit.inventory.ItemStack)

Example 4 with Potion

use of org.bukkit.potion.Potion in project MassiveCore by MassiveCraft.

the class PotionUtil method toPotionData.

public static PotionData toPotionData(int damage) {
    try {
        Potion potion = Potion.fromDamage(damage);
        PotionType type = potion.getType();
        boolean extended = potion.hasExtendedDuration();
        boolean upgraded = (potion.getLevel() >= 2);
        // If a potion was both upgraded and extended we keep the upgraded and remove the extended.
        if (type == null)
            return null;
        if (extended && !type.isExtendable())
            return null;
        if (upgraded && !type.isUpgradeable())
            return null;
        if (upgraded && extended)
            extended = false;
        return new PotionData(type, extended, upgraded);
    } catch (Exception e) {
        return null;
    }
}
Also used : PotionData(org.bukkit.potion.PotionData) Potion(org.bukkit.potion.Potion) PotionType(org.bukkit.potion.PotionType)

Example 5 with Potion

use of org.bukkit.potion.Potion in project MassiveCore by MassiveCraft.

the class MUtil method getPotionEffects.

@SuppressWarnings("deprecation")
public static List<PotionEffect> getPotionEffects(ItemStack itemStack) {
    if (itemStack == null)
        return null;
    if (itemStack.getType() != Material.POTION)
        return null;
    List<PotionEffect> ret = new ArrayList<>();
    if (isWaterPotion(itemStack))
        return ret;
    Potion potion = Potion.fromDamage(getPotionEffectBits(itemStack));
    ret.addAll(potion.getEffects());
    PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
    if (meta.hasCustomEffects()) {
        ret.addAll(meta.getCustomEffects());
    }
    return ret;
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) ThrownPotion(org.bukkit.entity.ThrownPotion) Potion(org.bukkit.potion.Potion) ArrayList(java.util.ArrayList) PotionMeta(org.bukkit.inventory.meta.PotionMeta)

Aggregations

Potion (org.bukkit.potion.Potion)36 PotionType (org.bukkit.potion.PotionType)19 Map (java.util.Map)13 ItemStack (org.bukkit.inventory.ItemStack)13 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)12 StringTag (com.wasteofplastic.org.jnbt.StringTag)12 Tag (com.wasteofplastic.org.jnbt.Tag)12 ListTag (com.wasteofplastic.org.jnbt.ListTag)10 PotionMeta (org.bukkit.inventory.meta.PotionMeta)7 IOException (java.io.IOException)6 Material (org.bukkit.Material)6 PotionData (org.bukkit.potion.PotionData)6 ArrayList (java.util.ArrayList)5 PotionEffect (org.bukkit.potion.PotionEffect)5 Enchantment (org.bukkit.enchantments.Enchantment)4 EntityType (org.bukkit.entity.EntityType)4 File (java.io.File)3 EventHandler (org.bukkit.event.EventHandler)3 ItemFlag (org.bukkit.inventory.ItemFlag)3 ItemMeta (org.bukkit.inventory.meta.ItemMeta)3