Solved Adding More Potion Effects to a Potion ITEM

Discussion in 'Plugin Development' started by Dupstal, Jan 23, 2015.

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

    Dupstal

    Hey Everyone!

    The title explains itself, I want to create a (Splash) Potion that has like Speed III and Damage Resistance V and Jump I. etc.

    The point is that it needs to be on ONE potion.

    Here is my code so far:

    Code:
                        Potion potion = new Potion(PotionType.REGEN, 1);
                        potion.setType(PotionType.INSTANT_HEAL);
                     
                     
    
                        potion.setSplash(true);
                      
                        ItemStack potionitem = new ItemStack(Material.POTION);
                        potion.apply(potionitem);
                     
                        ItemMeta Meta = potionitem.getItemMeta();
                        ArrayList<String> List = new ArrayList<String>();                         
                        Meta.setDisplayName("§e§lPotion Name");
                                         
                        Meta.setLore(List);
                        potionitem.setItemMeta(Meta);
                     
                        p.getWorld().dropItem(b.getLocation(), potionitem);

    EDIT: FINALLY FIGURED OUT:

    Code:
                        ItemStack potion = new ItemStack(Material.POTION);
                        PotionMeta meta = (PotionMeta) potion.getItemMeta();
                        meta.addCustomEffect(new PotionEffect(PotionEffectType.BLINDNESS, 50, 1), true);
                        meta.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 50, 1), true);
                        potion.setItemMeta(meta);
                        p.getInventory().addItem(potion);
     
    Last edited: Jan 27, 2015
  2. Offline

    PreFiXAUT

    @Dupstal Well, that's now how it works ;) You would need to create the Effects by you own (adding the extra stuff to the Player).

    You can either track the Potion all the Time (with a special Name - insecure because Players could change it - or with a Lore. Maybe also an complety different Way, but that's just the basic Stuff) and check when the Potion is used/thrown. Then apply all extra Effects to all People who came in touch with it. I think the "PotionSplashEvent" is the most usefull for this.

    The other way is, to have a unique Potion for a certain use. Then check if a Player has this special Effect on him (Example: Slowness 1 -> Remove Slowness 1 from him and give him Strength and Regen instead). With that way you should be fine. Also here I would suggest using the "PotionSplashEvent".
     
    Dupstal likes this.
  3. Offline

    Dupstal

    @PreFiXAUT

    I will use the PotionSplashEvent for this. Thanks for the answer :3
     
Thread Status:
Not open for further replies.

Share This Page