feat: add potion_has and potion_level (close #66)

This commit is contained in:
iGabyTM committed 2023-06-19 01:16:24 +03:00
1 parent 99f128fa66
commit e9198ef980
1 file changed
+15
@@ -447,6 +447,21 @@ public final class PlayerExpansion extends PlaceholderExpansion implements Confi
return bool(p.isLeashed());
case "is_inside_vehicle":
return bool(p.isInsideVehicle());
case "potion_has": {
final PotionEffectType potion = PotionEffectType.getByName(identifier.replace("potion_has_", ""));
return bool(potion != null && p.hasPotionEffect(potion));
}
case "potion_level": {
final PotionEffectType potion = PotionEffectType.getByName(identifier.replace("potion_level_", ""));
if (potion == null || !p.hasPotionEffect(potion)) {
return "0";
}
//noinspection DataFlowIssue
return String.valueOf(p.getPotionEffect(potion).getAmplifier());
}
}
// return null for unknown placeholders
return null;