Get potion level on brew event

Discussion in 'Spigot Plugin Development' started by lolicon1224, Oct 9, 2016.

  1. 0. Brew potion finish (ex Speed 1)
    1. Get potion level (1)
    2. Add potion level (getLevel + 1)
    3. Apply (Speed 2)

    I want make in this way
    how can i do? (Shouldn't need brew event)
  2. Have you tried anything sofar?
  3. It took me some research, however what I've come across:

    Gets the contents of the Brewing Stand.
    Returns an instance of BrewerInventory, and in there, we can see:

    Get the current ingredient for brewing.
    Returns an instance of ItemStack, and there we can use from Potion:

    fromItemStack(ItemStack item)
    Returns an instance of Potion. Which is a static method that we can use from the returned ingredient. From there, we can use:


    Returns the level of this potion.

    Returns an int as the current potion level. Methods in this class that are deprecated can still be used.
  4. Usually when a method is deprecated, there is a non-deprecated potentially better way to do what the deprecated method did, right? If so, do you see a better way in the javadocs? (I don't have time to look right now)
  5. Most of the time there is one, but sometimes deprecated methods are the only option
    • Agree Agree x 2
  6. Bukkit methods usually have magic values, or other reasons why they're deprecated, however this one doesn't specify why at all. I assume it's due to the fact that they were going to implement a new system for something similar, but it never ended up updating.

    Don't be afraid in most of Bukkit's cases; they make no sense whatsoever. Even spawning a falling block is deprecated:

    FallingBlock spawnFallingBlock(Location location, int blockId, byte blockData)
    Magic value

    Again, another magic value that really means nothing at all. Like I said, feel free to use it, there's nothing wrong with it here.
  7. Ok, thanks for the info!
    • Friendly Friendly x 1
  8. No problem at all! Keep in mind however, that I haven't tested the code, and it may not work. Just let me know and I will try to get something else to work :)