diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class index d73ab0a..37c0f0c 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class differ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class index 023caf5..1a30a25 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class differ diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class index 047182e..7b68878 100644 Binary files a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class and b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class differ diff --git a/plugin.yml b/plugin.yml index 4e7ef37..00e16ce 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: ActionHealth main: com.zeshanaslam.actionhealth.Main -version: 3.1.0 +version: 3.1.1 commands: Actionhealth: description: Actionhealth main command. \ No newline at end of file diff --git a/src/com/zeshanaslam/actionhealth/HealthListeners.java b/src/com/zeshanaslam/actionhealth/HealthListeners.java index 208c6dc..7236ccb 100644 --- a/src/com/zeshanaslam/actionhealth/HealthListeners.java +++ b/src/com/zeshanaslam/actionhealth/HealthListeners.java @@ -63,7 +63,7 @@ public class HealthListeners implements Listener { // Send health LivingEntity livingEntity = (LivingEntity) damaged; - plugin.healthUtil.sendHealth(player, (LivingEntity) damaged, livingEntity.getHealth() - event.getFinalDamage()); + plugin.healthUtil.sendHealth(player, (LivingEntity) damaged, (int) (livingEntity.getHealth() - event.getFinalDamage())); } } @@ -92,7 +92,7 @@ public class HealthListeners implements Listener { // Send health LivingEntity livingEntity = (LivingEntity) damaged; - plugin.healthUtil.sendHealth(player, (LivingEntity) damaged, livingEntity.getHealth() - event.getFinalDamage()); + plugin.healthUtil.sendHealth(player, (LivingEntity) damaged, (int) (livingEntity.getHealth() - event.getFinalDamage())); } } diff --git a/src/com/zeshanaslam/actionhealth/HealthUtil.java b/src/com/zeshanaslam/actionhealth/HealthUtil.java index 23720ba..7b8ee39 100644 --- a/src/com/zeshanaslam/actionhealth/HealthUtil.java +++ b/src/com/zeshanaslam/actionhealth/HealthUtil.java @@ -19,9 +19,24 @@ public class HealthUtil { this.plugin = plugin; } - public void sendHealth(Player player, LivingEntity entity, double health) { + public void sendHealth(Player player, LivingEntity entity, int health) { + if (plugin.settingsManager.delay) { + + new BukkitRunnable() { + public void run() { + sendActionBar(player, getOutput((int) entity.getHealth(), entity)); + } + }.runTaskLater(plugin, 1L); + } else { + sendActionBar(player, getOutput(Math.round(health), entity)); + } + } + + private String getOutput(int health, LivingEntity entity) { String name; - double maxHealth = entity.getMaxHealth(); + int maxHealth = (int) entity.getMaxHealth(); + + if (health < 0) health = 0; if (entity.getCustomName() == null) { name = entity.getName(); @@ -67,17 +82,7 @@ public class HealthUtil { output = output.replace("{usestyle}", style); } - if (plugin.settingsManager.delay) { - String finalOutput = output; - - new BukkitRunnable() { - public void run() { - sendActionBar(player, finalOutput); - } - }.runTaskLater(plugin, 1L); - } else { - sendActionBar(player, output); - } + return output; } private void sendActionBar(Player player, String message) {