mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
!added health bar placeholder
This commit is contained in:
parent
0c20cd0b62
commit
e5b0f06a8f
@ -1,6 +1,5 @@
|
||||
package net.Indyuce.mmocore.comp.placeholder;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -62,11 +61,25 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
else if (identifier.equals("combat"))
|
||||
return String.valueOf(PlayerData.get(player).isInCombat());
|
||||
|
||||
else if (identifier.equals("health")) {
|
||||
Validate.isTrue(player.isOnline(), "Player must be online");
|
||||
else if (identifier.equals("health") && player.isOnline()) {
|
||||
return StatType.MAX_HEALTH.format(player.getPlayer().getHealth());
|
||||
}
|
||||
|
||||
else if (identifier.equals("max_health") && player.isOnline()) {
|
||||
return StatType.MAX_HEALTH.format(player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
}
|
||||
|
||||
else if(identifier.equals("health_bar") && player.isOnline()) {
|
||||
StringBuilder format = new StringBuilder();
|
||||
double ratio = 20 * player.getPlayer().getHealth()
|
||||
/ player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||
for (double j = 1; j < 20; j++)
|
||||
format.append((ratio >= j ? ChatColor.RED
|
||||
: ratio >= j - .5 ? ChatColor.DARK_RED : ChatColor.DARK_GRAY)
|
||||
+ AltChar.listSquare);
|
||||
return format.toString();
|
||||
}
|
||||
|
||||
else if (identifier.equals("class"))
|
||||
return PlayerData.get(player).getProfess().getName();
|
||||
|
||||
@ -89,11 +102,6 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
return "" + PlayerData.get(player).getCollectionSkills()
|
||||
.getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase());
|
||||
|
||||
else if (identifier.equals("max_health")) {
|
||||
Validate.isTrue(player.isOnline(), "Player must be online");
|
||||
return StatType.MAX_HEALTH.format(player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
}
|
||||
|
||||
else if (identifier.equals("experience"))
|
||||
return "" + PlayerData.get(player).getExperience();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user