Give splash potion and potion

Discussion in 'Plugin Development' started by Kenda, Aug 29, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    Kenda

    Hi guys,

    I would create 2 methods for create my potion.
    Actuallay, I use ItemBuilder class -> https://www.spigotmc.org/threads/util-itembuilder-manage-items-easily.48397/

    But I can't create potion with this method.
    I create 2 method for 2 potion type (splash or not), but with the splash potion I can't choose the time for duration.

    Code:
    /Can use the duration
        public ItemBuilder setPotion(PotionEffectType effect, int level, int duration) {
            PotionMeta meta = (PotionMeta) is.getItemMeta();
            meta.addCustomEffect(new PotionEffect(effect, (duration * 20), (level - 1)), true);
            is.setItemMeta(meta);
            return this;
        }
    
        //Not here
        public static ItemStack setPotion(PotionType effectPotion, int level){
            Potion splash = new Potion(effectPotion, level);
            splash.setSplash(true);
    
            ItemStack potion = splash.toItemStack(1);
            ItemMeta meta = potion.getItemMeta();
            potion.setItemMeta(meta);
            return potion;
        }
    Can you help me ?
     
  2. Offline

    Kenda

    up ?
     
Thread Status:
Not open for further replies.

Share This Page