mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 18:47:44 +01:00
Worked around bug with water potions causing errors.
This commit is contained in:
parent
80a8ac9e98
commit
d18fe6ffa0
@ -31,9 +31,6 @@
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.Potion;
|
|
||||||
import org.bukkit.potion.PotionType;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BukkitUtil {
|
public class BukkitUtil {
|
||||||
@ -146,14 +143,13 @@ public static boolean isBlockWater(World world, int ox, int oy, int oz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given potion is a vial of water
|
* Checks if the given potion is a vial of water.
|
||||||
*
|
*
|
||||||
* @param potion
|
* @param item the item to check
|
||||||
* @return true if it's a water vial
|
* @return true if it's a water vial
|
||||||
*/
|
*/
|
||||||
public static boolean isWaterPotion(Potion potion) {
|
public static boolean isWaterPotion(ItemStack item) {
|
||||||
|
return (item.getDurability() & 0x3F) == 0;
|
||||||
return potion.getType() == PotionType.WATER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -823,9 +823,8 @@ 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) {
|
if (item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
|
||||||
Potion potion = Potion.fromItemStack(item);
|
Potion potion = Potion.fromItemStack(item);
|
||||||
if (!BukkitUtil.isWaterPotion(potion)) {
|
|
||||||
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);
|
||||||
@ -835,5 +834,4 @@ public void onBlockDispense(BlockDispenseEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -403,11 +403,10 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
|||||||
|
|
||||||
if (wcfg.blockPotions.size() > 0) {
|
if (wcfg.blockPotions.size() > 0) {
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
if (item != null && item.getType() == Material.POTION) {
|
if (item != null && item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
|
||||||
PotionEffect blockedEffect = null;
|
PotionEffect blockedEffect = null;
|
||||||
|
|
||||||
Potion potion = Potion.fromItemStack(item);
|
Potion potion = Potion.fromItemStack(item);
|
||||||
if (!BukkitUtil.isWaterPotion(potion)) {
|
|
||||||
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;
|
||||||
@ -436,7 +435,6 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player left clicks air.
|
* Called when a player left clicks air.
|
||||||
|
Loading…
Reference in New Issue
Block a user