9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-21 16:09:24 +00:00

Added %health% placeholder to show entity health in name

This commit is contained in:
Auxilor
2021-03-19 19:45:50 +00:00
parent ffd841c77d
commit fcabc9f3e3
4 changed files with 14 additions and 3 deletions

View File

@@ -499,6 +499,16 @@ public class EcoBoss extends PluginDependent {
); );
} }
this.getPlugin().getRunnableFactory().create(runnable -> {
String name = entity.getCustomName();
assert name != null;
entity.setCustomName(name.replace("%health%", StringUtils.internalToString(entity.getHealth())));
if (entity.isDead()) {
runnable.cancel();
}
}).runTaskTimer(0, 1);
if (this.isBossbarEnabled()) { if (this.isBossbarEnabled()) {
createBossBar(entity); createBossBar(entity);
} }
@@ -529,6 +539,7 @@ public class EcoBoss extends PluginDependent {
this.getPlugin().getRunnableFactory().create(runnable -> { this.getPlugin().getRunnableFactory().create(runnable -> {
if (!entity.isDead()) { if (!entity.isDead()) {
bossBar.setTitle(entity.getCustomName());
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
} else { } else {
bossBar.getPlayers().forEach(bossBar::removePlayer); bossBar.getPlayers().forEach(bossBar::removePlayer);

View File

@@ -1,6 +1,6 @@
enabled: true enabled: true
name: "&9Illusioner" # Display name name: "&9Illusioner &7| &c%health%♥" # Display name
base-mob: custom_illusioner # Any existing mob - custom_illusioner is also accepted (like in the old Illusioner plugin) base-mob: custom_illusioner # Any existing mob - custom_illusioner is also accepted (like in the old Illusioner plugin)
bossbar: bossbar:

View File

@@ -1,6 +1,6 @@
enabled: true enabled: true
name: "&8Steel Golem" # Display name name: "&8Steel Golem &7| &c%health%♥" # Display name
base-mob: iron_golem # Any existing mob - custom_illusioner is also accepted (like in the old Illusioner plugin) base-mob: iron_golem # Any existing mob - custom_illusioner is also accepted (like in the old Illusioner plugin)
bossbar: bossbar:

View File

@@ -1,6 +1,6 @@
enabled: true enabled: true
name: "&4Tarantula" # Display name name: "&4Tarantula &7| &c%health%♥" # Display name
base-mob: cave_spider # Any existing mob - custom_illusioner is also accepted (like in the old Illusioner plugin) base-mob: cave_spider # Any existing mob - custom_illusioner is also accepted (like in the old Illusioner plugin)
bossbar: bossbar: