Russian 49 Опубликовано 5 августа, 2013 (изменено) Вот и четвёртая шара наработки для оверворлд package services; import org.mmocore.gameserver.Announcements; import org.mmocore.gameserver.Config; import org.mmocore.gameserver.ThreadPoolManager; import org.mmocore.gameserver.model.GameObjectsStorage; import org.mmocore.gameserver.model.Player; import org.mmocore.gameserver.scripts.ScriptFile; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Russian */ public class AnnounceOnlinePlayer implements ScriptFile { private static final Logger _log = LoggerFactory.getLogger(AnnounceOnlinePlayer.class); private int online; private class Parse implements Runnable { @Override public void run() { refresh(); for(Player player : GameObjectsStorage.getAllPlayersForIterate()) player.sendPacket(); Announcements.getInstance().announceToAll("Текущий онлайн " + online + " игроков"); } } public void refresh() { online = (int) Math.floor(GameObjectsStorage.getAllPlayersCount() * Config.MultiplierOnline); } @Override public void onLoad() { if (!Config.ALLOW_ANNOUNCE_ONLINE) return; _log.info("AnnounceOnline: Loaded servise"); ThreadPoolManager.getInstance().scheduleAtFixedRate(new Parse(), Config.ANNOUNCE_ONLINE_DELAY, Config.ANNOUNCE_ONLINE_DELAY); } @Override public void onReload() { } @Override public void onShutdown() { } } Config.java: public static boolean ALLOW_ANNOUNCE_ONLINE; public static int ANNOUNCE_ONLINE_DELAY; public static double MultiplierOnline; ALLOW_ANNOUNCE_ONLINE = servicesSettings.getProperty("AllowAnnounceOnline", false); ANNOUNCE_ONLINE_DELAY = servicesSettings.getProperty("AnnounceOnlineDelay", 5) * 60000; MultiplierOnline = serverSettings.getProperty("MultiplierOnline", 1.0); Изменено 5 августа, 2013 пользователем Russian 3 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты