Author SHA1 Message Date
iGabyTM ade2c78bfd feat: rename potion_level placeholder
Last edit, I promise 😬
2023-06-21 20:55:33 +03:00
iGabyTM dcfeec98ed fix: move potion placeholders outside the switch block
Because these placeholders requires an argument they need to be outside the switch block
2023-06-21 20:51:34 +03:00
iGabyTM 84d3df2321 feat: rename placeholder
As @BlitzOffline pointed out, `has_potion_effect` makes more sense than `potion_has`
2023-06-21 20:49:01 +03:00
iGabyTM e9198ef980 feat: add potion_has and potion_level (close #66) 2023-06-19 01:16:24 +03:00
@@ -448,6 +448,23 @@ public final class PlayerExpansion extends PlaceholderExpansion implements Confi
case "is_inside_vehicle":
return bool(p.isInsideVehicle());
}
if (identifier.startsWith("has_potion_effect_")) {
final PotionEffectType potion = PotionEffectType.getByName(identifier.replace("has_potion_effect_", ""));
return bool(potion != null && p.hasPotionEffect(potion));
}
if (identifier.startsWith("potion_effect_level_")) {
final PotionEffectType potion = PotionEffectType.getByName(identifier.replace("potion_effect_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;
}