Skip to content

Commit

Permalink
feat: add potion_has and potion_level (close #66)
Browse files Browse the repository at this point in the history
  • Loading branch information
iGabyTM committed Jun 18, 2023
1 parent 99f128f commit e9198ef
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,21 @@ public String onRequest(OfflinePlayer player, String identifier) {
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;
Expand Down

0 comments on commit e9198ef

Please sign in to comment.