2013-11-07 05:19:56 +01:00
|
|
|
package mineplex.bungee.motd;
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import net.md_5.bungee.api.event.ProxyPingEvent;
|
|
|
|
import net.md_5.bungee.api.plugin.Listener;
|
|
|
|
import net.md_5.bungee.api.plugin.Plugin;
|
|
|
|
import net.md_5.bungee.event.EventHandler;
|
|
|
|
|
|
|
|
public class MotdManager implements Listener, Runnable
|
|
|
|
{
|
|
|
|
private Plugin _plugin;
|
|
|
|
private MotdRepository _repository;
|
|
|
|
|
2014-05-26 01:42:39 +02:00
|
|
|
private String _motd = "§b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r §c§l§m§kZ§6§l§m§kZ§e§l§m§kZ§a§l§m§kZ§b§l§m§kZ§r §f§lPLAY NOW§r §b§l§m§kZ§a§l§m§kZ§e§l§m§kZ§6§l§m§kZ§c§l§m§kZ";
|
2013-11-07 05:19:56 +01:00
|
|
|
|
|
|
|
public MotdManager(Plugin plugin)
|
|
|
|
{
|
|
|
|
_plugin = plugin;
|
|
|
|
|
|
|
|
_plugin.getProxy().getScheduler().schedule(_plugin, this, 30L, 30L, TimeUnit.SECONDS);
|
|
|
|
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
|
|
|
|
|
|
|
_repository = new MotdRepository();
|
|
|
|
_repository.initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void ServerPing(ProxyPingEvent event)
|
|
|
|
{
|
|
|
|
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
|
|
|
|
|
2014-04-26 11:47:04 +02:00
|
|
|
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), _motd, serverPing.getFaviconObject()));
|
2013-11-07 05:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
_motd = _repository.retrieveMotd();
|
|
|
|
}
|
|
|
|
}
|