Avoid Bukkit error with water potions.

This commit is contained in:
Olof Larsson 2013-08-07 08:03:08 +02:00
parent 0d5fb204a6
commit d4317583b6

View File

@ -316,6 +316,17 @@ public class MUtil
return item.getDurability() & 0x3F;
}
/**
* Checks if the given potion is a vial of water.
*
* @param item the item to check
* @return true if it's a water vial
*/
public static boolean isWaterPotion(ItemStack item)
{
return getPotionEffectBits(item) == 0;
}
public static List<PotionEffect> getPotionEffects(ItemStack itemStack)
{
if (itemStack == null) return null;
@ -323,6 +334,8 @@ public class MUtil
List<PotionEffect> ret = new ArrayList<PotionEffect>();
if (isWaterPotion(itemStack)) return ret;
Potion potion = Potion.fromDamage(getPotionEffectBits(itemStack));
ret.addAll(potion.getEffects());