feat: add potion_has and potion_level (close #66)
This commit is contained in:
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;
|
||||
|
||||
Reference in new issue
Block a user