Added workaround for #WORLDGUARD-2299, java.lang.IllegalArgumentException: Instant potions cannot be extended.

This commit is contained in:
sk89q 2012-11-11 18:41:18 -08:00
parent 8f409d47d9
commit 8dec32fa6a
3 changed files with 13 additions and 2 deletions

View File

@ -152,6 +152,17 @@ public static boolean isWaterPotion(ItemStack item) {
return (item.getDurability() & 0x3F) == 0;
}
/**
* Get just the potion effect bits. This is to work around bugs with potion
* parsing.
*
* @param item item
* @return new bits
*/
public static int getPotionEffectBits(ItemStack item) {
return item.getDurability() & 0x3F;
}
/**
* Find a position for the player to stand that is not inside a block.
* Blocks above the player will be iteratively tested until there is

View File

@ -824,7 +824,7 @@ public void onBlockDispense(BlockDispenseEvent event) {
if (wcfg.blockPotions.size() > 0) {
ItemStack item = event.getItem();
if (item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
Potion potion = Potion.fromItemStack(item);
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
for (PotionEffect effect : potion.getEffects()) {
if (potion.isSplash() && wcfg.blockPotions.contains(effect.getType())) {
event.setCancelled(true);

View File

@ -412,7 +412,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
if (item != null && item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
PotionEffect blockedEffect = null;
Potion potion = Potion.fromItemStack(item);
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
for (PotionEffect effect : potion.getEffects()) {
if (wcfg.blockPotions.contains(effect.getType())) {
blockedEffect = effect;