Null check base potion data, fixes #2302

This commit is contained in:
PikaMug 2024-10-20 01:25:51 -04:00
parent 318f8e565b
commit 85442a4760

View File

@ -149,14 +149,17 @@ public class BukkitItemUtil {
|| one.getType().equals(Material.SPLASH_POTION)) { || one.getType().equals(Material.SPLASH_POTION)) {
final PotionMeta pMeta1 = (PotionMeta) one.getItemMeta(); final PotionMeta pMeta1 = (PotionMeta) one.getItemMeta();
final PotionMeta pMeta2 = (PotionMeta) two.getItemMeta(); final PotionMeta pMeta2 = (PotionMeta) two.getItemMeta();
if (!pMeta1.getBasePotionData().getType().equals(pMeta2.getBasePotionData().getType())) { // Base potion data can return null on newer versions (likely 1.20.6+)
return -9; if (pMeta1.getBasePotionData() != null && pMeta2.getBasePotionData() != null) {
} if (!pMeta1.getBasePotionData().getType().equals(pMeta2.getBasePotionData().getType())) {
if (pMeta1.getBasePotionData().isExtended() != pMeta2.getBasePotionData().isExtended()) { return -9;
return -9; }
} if (pMeta1.getBasePotionData().isExtended() != pMeta2.getBasePotionData().isExtended()) {
if (pMeta1.getBasePotionData().isUpgraded() != pMeta2.getBasePotionData().isUpgraded()) { return -9;
return -9; }
if (pMeta1.getBasePotionData().isUpgraded() != pMeta2.getBasePotionData().isUpgraded()) {
return -9;
}
} }
} }
} }