Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String hearts(float amount, boolean full) {
- StringBuilder builder = new StringBuilder();
- int hearts = Math.round(amount);
- if (!full) {
- if (hearts % 2 != 0) {
- hearts -= 1;
- }
- }
- while (hearts > 0) {
- builder.append(symbol(amount));
- hearts -= 2;
- }
- return builder.toString();
- }
- public static String tabHearts(int maxHealth, float currentHealth, float lostHealth) {
- String color = maxHealth == 16 ? DARK_AQUA + "" : formatting[(maxHealth / 2) - 1] + "";
- return color + hearts(currentHealth, true) + DARK_GRAY + hearts(lostHealth, false);
- }
- public static String signHearts(int amount) {
- return "{\"text\":\"" + hearts(amount, true) + "\",\"color\":\"" + formatting[(amount / 2) - 1].getName() + "\"}";
- }
- /** @param health determines whether character will return as a heart or a skull. */
- private static StringBuilder symbol(float health) {
- StringBuilder builder = new StringBuilder();
- if (health < 22) {
- return builder.append(new Character((char)10084));
- } else {
- return builder.append(new Character((char)9760));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement