/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see .
*/
package com.l2jserver.gameserver;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.util.Date;
import java.util.List;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javolution.util.FastList;
import com.l2jserver.Config;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.clientpackets.Say2;
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.script.DateRange;
import com.l2jserver.gameserver.util.Broadcast;
import com.l2jserver.util.StringUtil;
public class Announcements
{
private static Logger _log = Logger.getLogger(Announcements.class.getName());
private final List _announcements = new FastList<>();
private final List _critAnnouncements = new FastList<>();
private final List> _eventAnnouncements = new FastList<>();
protected Announcements()
{
loadAnnouncements();
}
public static Announcements getInstance()
{
return SingletonHolder._instance;
}
public void loadAnnouncements()
{
_announcements.clear();
_critAnnouncements.clear();
readFromDisk("data/announcements.txt", _announcements);
readFromDisk("data/critannouncements.txt", _critAnnouncements);
if (Config.DEBUG)
{
_log.info("Announcements: Loaded " + (_announcements.size() + _critAnnouncements.size()) + " announcements.");
}
}
public void showAnnouncements(L2PcInstance activeChar)
{
for (String announce : _announcements)
{
CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, activeChar.getName(), announce);
activeChar.sendPacket(cs);
}
for (String critAnnounce : _critAnnouncements)
{
CreatureSay cs = new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, activeChar.getName(), critAnnounce);
activeChar.sendPacket(cs);
}
for (List