/*
* 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 net.sf.l2j.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.text.TextBuilder;
import javolution.util.FastList;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.cache.HtmCache;
import net.sf.l2j.gameserver.clientpackets.Say2;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.script.DateRange;
import net.sf.l2j.gameserver.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
/**
* This class ...
*
* @version $Revision: 1.5.2.1.2.7 $ $Date: 2005/03/29 23:15:14 $
*/
public class Announcements
{
private static Logger _log = Logger.getLogger(Announcements.class.getName());
private static Announcements _instance;
private List _announcements = new FastList();
private List> _eventAnnouncements = new FastList>();
public Announcements()
{
loadAnnouncements();
}
public static Announcements getInstance()
{
if (_instance == null)
{
_instance = new Announcements();
}
return _instance;
}
public void loadAnnouncements()
{
_announcements.clear();
File file = new File(Config.DATAPACK_ROOT, "data/announcements.txt");
if (file.exists())
{
readFromDisk(file);
}
else
{
_log.config("data/announcements.txt doesn't exist");
}
}
public void showAnnouncements(L2PcInstance activeChar)
{
for (int i = 0; i < _announcements.size(); i++)
{
CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, activeChar.getName(), _announcements.get(i));
activeChar.sendPacket(cs);
}
for (int i = 0; i < _eventAnnouncements.size(); i++)
{
List