mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
Fix manual --track in bossbar trait
This commit is contained in:
parent
47d9330a56
commit
eeea90ea05
@ -131,19 +131,21 @@ public class BossBarTrait extends Trait {
|
|||||||
if (bar == null)
|
if (bar == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (track != null && !track.isEmpty() && npc.getEntity() instanceof LivingEntity) {
|
if (track != null && !track.isEmpty()) {
|
||||||
LivingEntity entity = (LivingEntity) npc.getEntity();
|
|
||||||
if (track.equalsIgnoreCase("health")) {
|
if (track.equalsIgnoreCase("health")) {
|
||||||
double maxHealth = entity.getMaxHealth();
|
LivingEntity entity = (LivingEntity) npc.getEntity();
|
||||||
if (SUPPORT_ATTRIBUTES) {
|
if (npc.getEntity() instanceof LivingEntity) {
|
||||||
try {
|
double maxHealth = entity.getMaxHealth();
|
||||||
maxHealth = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
if (SUPPORT_ATTRIBUTES) {
|
||||||
} catch (Throwable t) {
|
try {
|
||||||
SUPPORT_ATTRIBUTES = false;
|
maxHealth = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
SUPPORT_ATTRIBUTES = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
bar.setProgress(entity.getHealth() / maxHealth);
|
||||||
}
|
}
|
||||||
bar.setProgress(entity.getHealth() / maxHealth);
|
} else {
|
||||||
} else if (track != null && !track.isEmpty()) {
|
|
||||||
String replaced = Placeholders.replace(track,
|
String replaced = Placeholders.replace(track,
|
||||||
npc.getEntity() instanceof Player ? (Player) npc.getEntity() : null);
|
npc.getEntity() instanceof Player ? (Player) npc.getEntity() : null);
|
||||||
Double number = Doubles.tryParse(replaced);
|
Double number = Doubles.tryParse(replaced);
|
||||||
@ -152,7 +154,7 @@ public class BossBarTrait extends Trait {
|
|||||||
if (number >= 1 && number <= 100) {
|
if (number >= 1 && number <= 100) {
|
||||||
number /= 100.0;
|
number /= 100.0;
|
||||||
}
|
}
|
||||||
bar.setProgress(Math.min(0, Math.max(1, number)));
|
bar.setProgress(Math.max(0, Math.min(1, number)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bar.setTitle(title);
|
bar.setTitle(title);
|
||||||
|
Loading…
Reference in New Issue
Block a user