mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-17 04:41:31 +01:00
Fix manual --track in bossbar trait
This commit is contained in:
parent
47d9330a56
commit
eeea90ea05
@ -131,9 +131,10 @@ 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")) {
|
||||||
|
LivingEntity entity = (LivingEntity) npc.getEntity();
|
||||||
|
if (npc.getEntity() instanceof LivingEntity) {
|
||||||
double maxHealth = entity.getMaxHealth();
|
double maxHealth = entity.getMaxHealth();
|
||||||
if (SUPPORT_ATTRIBUTES) {
|
if (SUPPORT_ATTRIBUTES) {
|
||||||
try {
|
try {
|
||||||
@ -143,7 +144,8 @@ public class BossBarTrait extends Trait {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bar.setProgress(entity.getHealth() / maxHealth);
|
bar.setProgress(entity.getHealth() / maxHealth);
|
||||||
} else if (track != null && !track.isEmpty()) {
|
}
|
||||||
|
} else {
|
||||||
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