Solved Custom Potions in Spigot 1.13.2

Discussion in 'Plugin Development' started by iChameleon, Dec 26, 2018.

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

    iChameleon

    I'm trying to create potions with combinations of effects, like speed and strength. This is possible through give commands, and I know I can do it by using the PlayerConsumeEvent and just giving them the effect, but I'd like to create an ItemStack potion with certain effects for certain durations. Anyone have any idea of how this is done now that the Potion object is deprecated?
     
  2. Offline

    Escad

    Use PotionMeta. It's a subinterface of ItemMeta.
     
  3. Offline

    iChameleon

    Thanks! I didn't think about casting PotionMeta over ItemMeta. Here's the code I got to work in case anybody else is wondering.


    Code:
    ItemStack potion = new ItemStack(Material.POTION);
    PotionMeta meta = (PotionMeta) potion.getItemMeta();
    meta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 600, 2), true);
    potion.setItemMeta(meta);
     
Thread Status:
Not open for further replies.

Share This Page