mirror of
https://github.com/zeshan321/ActionHealth.git
synced 2025-03-10 13:49:07 +01:00
Fixed incorrect health for delay option and health display values
Fixed: - Delay option not getting the right health - Showing negative health number when the entity dies - Showing decimals
This commit is contained in:
parent
3ca1dd0d27
commit
1d2fd01a4b
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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.
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user