From e54cc146f0c290384c08b0de97d9181cb59bf524 Mon Sep 17 00:00:00 2001 From: Zeshan Aslam Date: Thu, 25 Jun 2020 22:04:35 -0400 Subject: [PATCH] Added 'percenthealth' placeholder --- config.yml | 1 + src/com/zeshanaslam/actionhealth/utils/HealthUtil.java | 1 + 2 files changed, 2 insertions(+) diff --git a/config.yml b/config.yml index b3f6074..b816a85 100644 --- a/config.yml +++ b/config.yml @@ -5,6 +5,7 @@ # {usestyle} will use the defined chars. # {displayname} will use player/mob custom name. # {opponentlastdamage} the amount of damage the enemy last received. +# {percenthealth} displays the percentage of health left. # Has support for PlaceholderAPI and MVdWPlaceholderAPI. Health Message: '&7&l{name}: {usestyle}' diff --git a/src/com/zeshanaslam/actionhealth/utils/HealthUtil.java b/src/com/zeshanaslam/actionhealth/utils/HealthUtil.java index 49054b6..aa3fb45 100644 --- a/src/com/zeshanaslam/actionhealth/utils/HealthUtil.java +++ b/src/com/zeshanaslam/actionhealth/utils/HealthUtil.java @@ -122,6 +122,7 @@ public class HealthUtil { output = output.replace("{name}", name); output = output.replace("{health}", String.valueOf((int) health)); output = output.replace("{maxhealth}", String.valueOf((int) maxHealth)); + output = output.replace("{percenthealth}", String.valueOf((int) ((health / maxHealth) * 100.0))); output = output.replace("{opponentlastdamage}", String.valueOf((int) entity.getLastDamage())); if (output.contains("{usestyle}")) {