Avoid Bukkit error with water potions.
This commit is contained in:
parent
0d5fb204a6
commit
d4317583b6
@ -316,6 +316,17 @@ public class MUtil
|
|||||||
return item.getDurability() & 0x3F;
|
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)
|
public static List<PotionEffect> getPotionEffects(ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if (itemStack == null) return null;
|
if (itemStack == null) return null;
|
||||||
@ -323,6 +334,8 @@ public class MUtil
|
|||||||
|
|
||||||
List<PotionEffect> ret = new ArrayList<PotionEffect>();
|
List<PotionEffect> ret = new ArrayList<PotionEffect>();
|
||||||
|
|
||||||
|
if (isWaterPotion(itemStack)) return ret;
|
||||||
|
|
||||||
Potion potion = Potion.fromDamage(getPotionEffectBits(itemStack));
|
Potion potion = Potion.fromDamage(getPotionEffectBits(itemStack));
|
||||||
ret.addAll(potion.getEffects());
|
ret.addAll(potion.getEffects());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user