From 48a3e72018d1f98381309ea7a75d90c2d6058f3a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 2 Jul 2013 23:08:55 -0500 Subject: [PATCH] Fix scaling for player health. Fixes BUKKIT-4431 By: Wesley Wolfe --- .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 583b99c980..977adff6e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -61,6 +61,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private final Set channels = new HashSet(); private final Map hiddenPlayers = new MapMaker().softValues().makeMap(); private int hash = 0; + private boolean scaledHealth; public CraftPlayer(CraftServer server, EntityPlayer entity) { super(server, entity); @@ -997,4 +998,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { this.server.getScoreboardManager().setPlayerBoard(this, scoreboard); } + + public float getScaledHealth() { + return (float) (this.scaledHealth ? getHealth() / getMaxHealth() * 20.0D : getHealth()); + } + + public void setScaleHealth(boolean scale) { + this.scaledHealth = scale; + } + + public boolean isScaledHealth() { + return this.scaledHealth; + } }