2013-10-22 06:46:31 +02:00
|
|
|
package mineplex.hub.modules;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
|
|
|
|
import mineplex.core.MiniPlugin;
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.UtilDisplay;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.common.util.UtilTime;
|
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import mineplex.hub.HubManager;
|
2013-12-21 10:05:42 +01:00
|
|
|
import mineplex.hub.mount.Mount;
|
|
|
|
import mineplex.hub.mount.types.Dragon;
|
2013-10-22 06:46:31 +02:00
|
|
|
|
|
|
|
public class NewsManager extends MiniPlugin
|
|
|
|
{
|
|
|
|
public HubManager Manager;
|
|
|
|
|
|
|
|
private String[] _news;
|
|
|
|
private int _newsIndex = 0;
|
|
|
|
private long _newsTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
private int _mineplexIndex = 0;
|
|
|
|
|
|
|
|
public NewsManager(HubManager manager)
|
|
|
|
{
|
|
|
|
super("News Manager", manager.GetPlugin());
|
2013-12-18 11:22:40 +01:00
|
|
|
|
2013-10-22 06:46:31 +02:00
|
|
|
Manager = manager;
|
|
|
|
|
|
|
|
_news = new String[]
|
|
|
|
{
|
2013-12-21 12:21:16 +01:00
|
|
|
"Europe Servers: " + C.cGreen + C.Bold + "BACK ONLINE" + ChatColor.RESET + "!",
|
2013-12-24 09:14:40 +01:00
|
|
|
"New SSM Kit: " + C.cYellow + C.Bold + "Magma Cube" + ChatColor.RESET + "!",
|
|
|
|
"New Rank: " + C.cPurple + C.Bold + "Hero Rank" + ChatColor.RESET + "!",
|
2013-10-22 06:46:31 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void FlightUpdate(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.FASTEST)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Mineplex Color
|
|
|
|
ChatColor col = ChatColor.RED;
|
|
|
|
if (_mineplexIndex == 1) col = ChatColor.GOLD;
|
|
|
|
else if (_mineplexIndex == 2) col = ChatColor.YELLOW;
|
|
|
|
else if (_mineplexIndex == 3) col = ChatColor.GREEN;
|
|
|
|
else if (_mineplexIndex == 4) col = ChatColor.AQUA;
|
|
|
|
else if (_mineplexIndex == 5) col = ChatColor.LIGHT_PURPLE;
|
|
|
|
_mineplexIndex = (_mineplexIndex + 1)%6;
|
|
|
|
|
|
|
|
//News Change
|
2013-10-25 10:20:14 +02:00
|
|
|
if (UtilTime.elapsed(_newsTime, 4500))
|
2013-10-22 06:46:31 +02:00
|
|
|
{
|
|
|
|
_newsIndex = (_newsIndex + 1)%_news.length;
|
|
|
|
_newsTime = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Text
|
|
|
|
String text = col + C.Bold + "MINEPLEX" + ChatColor.RESET + " - " + _news[_newsIndex];
|
|
|
|
if (text.length() > 64)
|
|
|
|
text = text.substring(0, 64);
|
|
|
|
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
UtilDisplay.displayTextBar(Manager.GetPlugin(), player, (double)_newsIndex/(double)(_news.length-1), text);
|
2013-12-21 10:05:42 +01:00
|
|
|
|
|
|
|
for (Mount mount : Manager.GetMount().getMounts())
|
|
|
|
{
|
|
|
|
if (mount instanceof Dragon)
|
|
|
|
{
|
|
|
|
((Dragon)mount).SetName(text);
|
|
|
|
}
|
|
|
|
}
|
2013-10-22 06:46:31 +02:00
|
|
|
}
|
|
|
|
}
|