Giving a player a potion

Discussion in 'Plugin Development' started by Chr0mosom3, Feb 12, 2019.

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

    Chr0mosom3

    I am making a plugin with kits. One of those kits has Regeneration 2 10sec and Speed 10sec. I want to know how to give a player a potion. I have looked at this thread which doesn't help but links to this doc which also doesn't help me, I already know how to create an item stack. I did some of the searchings on my own and found this doc which I don't understand a thing of!!! It tells me that the extensions of an effect are a boolean.

    I don't understand a single thing in all of these docs and I need some help, can someone give me a piece of code (I don't want the whole code) of how to do it with explanation of what the args mean, that would really help.
     
  2. Offline

    0-o

    Here's a snippet of code from one of my 1.8.8 plugins, Sabotage.

    PotionEffectType type = PotionEffectType.getByName(effect);
    Potion potion = new Potion(PotionType.getByEffect(type), pot.getPotency(), pot.getSplash() , pot.getExtended());
    result.add(potion.toItemStack(pot.getAmount()));

    Now here is the general format:

    Potion potion = new Potion(PotionType type, int potency, boolean spash, boolean extended);
    potion.toItemStack(int amount);

    potency - what level is it?
    splash - is it a splash potion?
    extended - does it last longer?

    I don't know what version you're working with, but if it happens to be 1.8.8, this code will work.
     
Thread Status:
Not open for further replies.

Share This Page