Bukkit/CraftBukkit — pull request #1401 by LB-- (2014-07-28 03:22:57+00:00)
Title: [C] Check for custom potion effects before falling back on damage value. Fixes BUKKIT-3635

**The Issue:**
The collection of `PotionEffect`s returned by `CraftThrownPotion#getEffects()` only considered the damage value of the potion. There was a TODO comment above the implementation explaining that this was incorrect behavior. This PR fixes the implementation to have the intended behavior so that `CraftThrownPotion#getEffects()` returns the same collection of `PotionEffect`s that vanilla Minecraft actually applies to players.

**PR Breakdown:**
First, the new implementation takes the `ItemMeta` from the `ItemStack` returned by `CraftThrownPotion#getItem()`. If the returned value is not null and is an instance of `PotionMeta`, it grabs the collection of `PotionEffect`s returned by `PotionMeta#getCustomEffects()`. If this collection is non-empty, it is returned since Minecraft will ignore the data value. If, however, it *is* empty, it falls back on the previous implementation of using damage value to acquire the collection of `PotionEffect`s, since vanilla Minecraft will be using the damage value as well.

**Testing Results and Materials:**
I tested the old and new implementation with this test plugin:
https://github.com/LB--/TestPlugin/tree/BUKKIT-3635
Upon login, the plugin gives you a splash potion with damage value for slowness but custom effect of speed 2. It listens to `PotionSplashEvent` and displays to the thrower the contents of `ThrownPotion#getEffects()` as well as `PotionMeta#getCustomEffects()`. Before this commit, the former displayed only the slowness effect and the latter displayed only the speed 2 effect. After this commit, both the former and the latter display the speed 2 effect. In both cases, the effect applied to the player was the speed 2 effect.

**JIRA Ticket:**
BUKKIT-3635 - https://bukkit.atlassian.net/browse/BUKKIT-3635