Discussion in 'Spigot Plugin Development' started by forseth11, Mar 4, 2016.

  1. In the recent release of both minecraft 1.9 and Spigot for 1.9, there have been many bugs. Among these bugs, which spigot is hard at work to fix, is the Potion class. The problem with the Potion class is that it relies on item durability data to determine a potion type. Also, splash potions and lingering potions do not work with the potion class.

    Use this line of code to parse an ItemStack to Potion1_9:
    Code (Text):
    Potion1_9 potion = Potion1_9.fromItemStack(item);
    Here is the Potion1_9 class.

    Now lets get those 1.9 plugin update rolling out.

    If you have any questions or need help, feel free to ask.
    #1 forseth11, Mar 4, 2016
    Last edited: Mar 9, 2016
    • Like Like x 6
    • Useful Useful x 3
    • Winner Winner x 1
  2. type = PotionType.valueOf(tag.toUpperCase);


    Also you forgot to remove (what I imagine is a debug line)
    Bukkit.broadcastMessage("POTION TAG: " + tag)
    • Agree Agree x 1
  3. Can't believe I forgot to remove that.
    The PotionType.valueOf() method will not work for this as the NBT tags do not match the enum values. Also the tags include things like long_ and strong_. I haven't actually tested that, so I may be wrong. If what you wrote works, please let my know. Also this class finds other things for you like if the potion is strong, splash, lingering, or extended.
  4. Oh, was not aware of that, my bad. Nice class though, thanks for sharing it with us :)
  5. This is helpful. It would be good to have an apply method to do the reverse to an ItemStack. i.e., apply the tags to the itemstack based on the potion type.
  6. I didn't actually need it to do that, so I did not implement that. If I finish what I am working on today I might because to do that.
  7. I added a toItemStack method.
    • Winner Winner x 1
    • Like Like x 1
    • Useful Useful x 1
  8. Thanks for the class, really useful.
    • Like Like x 1
  9. Hey! Thanks for making this great system! But now:

    I am trying to implement your system to my potions but i cant, it keeps making that null image. I am having this code:

    Code (Text):
                    ItemStack Nightvision = new ItemStack(Material.POTION, 1,(short) 8262);
                    ItemMeta NightvisionMeta = Nightvision.getItemMeta();
                    ArrayList NightvisionLore = new ArrayList();
                    NightvisionLore.add("§7§o• Click to toggle nightvision");
    Could you please explain me how to make it compatible? Thanks for the work and help!
  10. This will no longer work:
    Code (Text):
    ItemStack Nightvision = new ItemStack(Material.POTION, 1,(short) 8262);
    You can not use durability for potions. Use my class to create the item rather than new ItemStack.
  11. Thank you! Thank you so much!
  12. Misaka


    fyi you should be able to deal with potions without using this class now. PotionMeta now has a setBasePotionData that takes a PotionData object and works and isn't deprecated.
  13. Yes but I don't understand it! How do I get the duration of a potion?
  14. Thanks for this class!
  15. I'm just wondering, what's wrong with PotionMeta?
  16. I don't know if it is fixed now, but when I made this, it only used potion durability.
  17. I've been using it so I guess it's fixed now.