mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-21 00:28:23 +01:00
Added workaround for #WORLDGUARD-2299, java.lang.IllegalArgumentException: Instant potions cannot be extended.
This commit is contained in:
parent
8f409d47d9
commit
8dec32fa6a
@ -152,6 +152,17 @@ public static boolean isWaterPotion(ItemStack item) {
|
|||||||
return (item.getDurability() & 0x3F) == 0;
|
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.
|
* 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
|
* Blocks above the player will be iteratively tested until there is
|
||||||
|
@ -824,7 +824,7 @@ public void onBlockDispense(BlockDispenseEvent event) {
|
|||||||
if (wcfg.blockPotions.size() > 0) {
|
if (wcfg.blockPotions.size() > 0) {
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
if (item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
|
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()) {
|
for (PotionEffect effect : potion.getEffects()) {
|
||||||
if (potion.isSplash() && wcfg.blockPotions.contains(effect.getType())) {
|
if (potion.isSplash() && wcfg.blockPotions.contains(effect.getType())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -412,7 +412,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
|||||||
if (item != null && item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
|
if (item != null && item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
|
||||||
PotionEffect blockedEffect = null;
|
PotionEffect blockedEffect = null;
|
||||||
|
|
||||||
Potion potion = Potion.fromItemStack(item);
|
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
|
||||||
for (PotionEffect effect : potion.getEffects()) {
|
for (PotionEffect effect : potion.getEffects()) {
|
||||||
if (wcfg.blockPotions.contains(effect.getType())) {
|
if (wcfg.blockPotions.contains(effect.getType())) {
|
||||||
blockedEffect = effect;
|
blockedEffect = effect;
|
||||||
|
Loading…
Reference in New Issue
Block a user