Stop DragonMount from causing the news bar to flicker

This commit is contained in:
Shaun Bennett 2014-08-06 21:03:48 -05:00
parent f7f9d3e703
commit 0b942e5180
3 changed files with 20 additions and 4 deletions

View File

@ -246,15 +246,17 @@ public class NewsManager extends MiniPlugin
String text = col + C.Bold + "MINEPLEX" + ChatColor.RESET + " - " + _news[_newsIndex];
if (text.length() > 64)
text = text.substring(0, 64);
double healthPercent = (double)_newsIndex/(double)(_news.length-1);
for (Player player : UtilServer.getPlayers())
UtilDisplay.displayTextBar(Manager.GetPlugin(), player, (double)_newsIndex/(double)(_news.length-1), text);
UtilDisplay.displayTextBar(Manager.GetPlugin(), player, healthPercent, text);
for (Mount mount : Manager.GetMount().getMounts())
{
if (mount instanceof Dragon)
{
((Dragon)mount).SetName(text);
((Dragon)mount).setHealthPercent(healthPercent);
}
}
}

View File

@ -30,7 +30,10 @@ public class DragonMount extends Mount<DragonData>
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, new DragonData(this, player));
DragonData dragonData = new DragonData(this, player);
//Set max health to 1 so player doesn't see a bunch of mount hearts flashing when NewsManager changes the health
dragonData.Dragon.setMaxHealth(1.0);
_active.put(player, dragonData);
}
@Override

View File

@ -103,7 +103,18 @@ public class Dragon extends DragonMount
for (DragonData dragon : GetActive().values())
dragon.Dragon.setCustomName(news);
}
public void setHealthPercent(double healthPercent)
{
for (DragonData dragon : GetActive().values())
{
double health = healthPercent * dragon.Dragon.getMaxHealth();
if (health <= 0.0)
health = 0.001;
dragon.Dragon.setHealth(health);
}
}
@EventHandler
public void HeroOwner(PlayerJoinEvent event)
{