Stop DragonMount from causing the news bar to flicker
This commit is contained in:
parent
f7f9d3e703
commit
0b942e5180
@ -247,14 +247,16 @@ public class NewsManager extends MiniPlugin
|
|||||||
if (text.length() > 64)
|
if (text.length() > 64)
|
||||||
text = text.substring(0, 64);
|
text = text.substring(0, 64);
|
||||||
|
|
||||||
|
double healthPercent = (double)_newsIndex/(double)(_news.length-1);
|
||||||
for (Player player : UtilServer.getPlayers())
|
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())
|
for (Mount mount : Manager.GetMount().getMounts())
|
||||||
{
|
{
|
||||||
if (mount instanceof Dragon)
|
if (mount instanceof Dragon)
|
||||||
{
|
{
|
||||||
((Dragon)mount).SetName(text);
|
((Dragon)mount).SetName(text);
|
||||||
|
((Dragon)mount).setHealthPercent(healthPercent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,10 @@ public class DragonMount extends Mount<DragonData>
|
|||||||
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
|
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
|
||||||
|
|
||||||
//Store
|
//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
|
@Override
|
||||||
|
@ -104,6 +104,17 @@ public class Dragon extends DragonMount
|
|||||||
dragon.Dragon.setCustomName(news);
|
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
|
@EventHandler
|
||||||
public void HeroOwner(PlayerJoinEvent event)
|
public void HeroOwner(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user