@Override
public void run() {
if ((loadUp ? health < 300 : health > 0)) {
DataWatcher watcher = getWatcher(text, health);
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
PacketHelper.sendPacket(player, metaPacket);
if (loadUp) {
health += healthAdd;
} else {
health -= healthAdd;
}
} else {
DataWatcher watcher = getWatcher(text, (loadUp ? 300 : 0));
PacketPlayOutEntityMetadata metaPacket = getMetadataPacket(watcher);
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();
PacketHelper.sendPacket(player, metaPacket);
PacketHelper.sendPacket(player, destroyEntityPacket);
hasHealthBar.put(player.getName(), false);
//Complete text
PacketPlayOutSpawnEntityLiving mobPacket = getMobPacket(completeText, player.getLocation(), 200);
PacketHelper.sendPacket(player, mobPacket);
hasHealthBar.put(player.getName(), true);
DataWatcher watcher2 = getWatcher(completeText, 300);
PacketPlayOutEntityMetadata metaPacket2 = getMetadataPacket(watcher2);
PacketHelper.sendPacket(player, metaPacket2);
new BukkitRunnable() {
@Override
public void run() {
PacketPlayOutEntityDestroy destroyEntityPacket = getDestroyEntityPacket();