Moved announcements to SQL.
This commit is contained in:
@@ -35,13 +35,13 @@ import org.l2jmobius.commons.util.Util;
|
||||
import org.l2jmobius.gameserver.cache.CrestCache;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.HeroSkillTable;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.NobleSkillTable;
|
||||
import org.l2jmobius.gameserver.data.OfflineTradeTable;
|
||||
import org.l2jmobius.gameserver.data.SchemeBufferTable;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.data.sql.HelperBuffTable;
|
||||
@@ -72,7 +72,6 @@ import org.l2jmobius.gameserver.data.xml.WalkerRouteData;
|
||||
import org.l2jmobius.gameserver.data.xml.ZoneData;
|
||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import org.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import org.l2jmobius.gameserver.handler.AutoAnnouncementHandler;
|
||||
import org.l2jmobius.gameserver.handler.AutoChatHandler;
|
||||
import org.l2jmobius.gameserver.handler.ItemHandler;
|
||||
import org.l2jmobius.gameserver.handler.SkillHandler;
|
||||
@@ -197,8 +196,7 @@ public class GameServer
|
||||
Util.printSection("World");
|
||||
World.getInstance();
|
||||
MapRegionData.getInstance();
|
||||
Announcements.getInstance();
|
||||
AutoAnnouncementHandler.getInstance();
|
||||
AnnouncementsTable.getInstance();
|
||||
GlobalVariablesManager.getInstance();
|
||||
StaticObjectData.getInstance();
|
||||
TeleportLocationTable.getInstance();
|
||||
|
@@ -22,9 +22,9 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseBackup;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.OfflineTradeTable;
|
||||
import org.l2jmobius.gameserver.data.SchemeBufferTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
|
||||
@@ -45,6 +45,7 @@ import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerClose;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* This class provides the functions for shutting down and restarting the server.<br>
|
||||
@@ -174,7 +175,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
public void startShutdown(PlayerInstance player, int seconds, boolean restart)
|
||||
{
|
||||
final Announcements announcements = Announcements.getInstance();
|
||||
final AnnouncementsTable announcements = AnnouncementsTable.getInstance();
|
||||
|
||||
LOGGER.warning((player != null ? "GM: " + player.getName() + "(" + player.getObjectId() + ")" : "Server") + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
|
||||
@@ -219,7 +220,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
public void abort(PlayerInstance player)
|
||||
{
|
||||
final Announcements announcements = Announcements.getInstance();
|
||||
final AnnouncementsTable announcements = AnnouncementsTable.getInstance();
|
||||
|
||||
LOGGER.warning((player != null ? "GM: " + player.getName() + "(" + player.getObjectId() + ")" : "Server") + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
|
||||
@@ -269,7 +270,7 @@ public class Shutdown extends Thread
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.THE_SERVER_WILL_BE_COMING_DOWN_IN_S1_SECOND_S_PLEASE_FIND_A_SAFE_PLACE_TO_LOG_OUT);
|
||||
sm.addString(Integer.toString(seconds));
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -381,7 +382,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
private synchronized void saveData()
|
||||
{
|
||||
final Announcements _an = Announcements.getInstance();
|
||||
final AnnouncementsTable _an = AnnouncementsTable.getInstance();
|
||||
switch (_shutdownMode)
|
||||
{
|
||||
case SIGTERM:
|
||||
|
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.script.DateRange;
|
||||
|
||||
/**
|
||||
* @author ProGramMoS
|
||||
* @version 1.6
|
||||
*/
|
||||
public class Announcements
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(Announcements.class.getName());
|
||||
|
||||
private final List<String> _announcements = new ArrayList<>();
|
||||
private final List<List<Object>> _eventAnnouncements = new ArrayList<>();
|
||||
|
||||
public Announcements()
|
||||
{
|
||||
loadAnnouncements();
|
||||
}
|
||||
|
||||
public void loadAnnouncements()
|
||||
{
|
||||
_announcements.clear();
|
||||
final File file = new File(Config.DATAPACK_ROOT, "data/announcements.txt");
|
||||
if (file.exists())
|
||||
{
|
||||
readFromDisk(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warning("data/announcements.txt doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
public void showAnnouncements(PlayerInstance player)
|
||||
{
|
||||
for (String _announcement : _announcements)
|
||||
{
|
||||
player.sendPacket(new CreatureSay(0, ChatType.ANNOUNCEMENT, player.getName(), _announcement.replace("%name%", player.getName())));
|
||||
}
|
||||
|
||||
for (List<Object> entry : _eventAnnouncements)
|
||||
{
|
||||
final DateRange validDateRange = (DateRange) entry.get(0);
|
||||
final String[] msg = (String[]) entry.get(1);
|
||||
final Date currentDate = new Date();
|
||||
if (!validDateRange.isValid() || validDateRange.isWithinRange(currentDate))
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
|
||||
for (String element : msg)
|
||||
{
|
||||
sm.addString(element);
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addEventAnnouncement(DateRange validDateRange, String[] msg)
|
||||
{
|
||||
final List<Object> entry = new ArrayList<>();
|
||||
entry.add(validDateRange);
|
||||
entry.add(msg);
|
||||
_eventAnnouncements.add(entry);
|
||||
}
|
||||
|
||||
public void listAnnouncements(PlayerInstance player)
|
||||
{
|
||||
final String content = HtmCache.getInstance().getHtmForce("data/html/admin/announce.htm");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setHtml(content);
|
||||
final StringBuilder replyMSG = new StringBuilder("<br>");
|
||||
for (int i = 0; i < _announcements.size(); i++)
|
||||
{
|
||||
replyMSG.append("<table width=260><tr><td width=220>" + _announcements.get(i) + "</td><td width=40>");
|
||||
replyMSG.append("<button value=\"Delete\" action=\"bypass -h admin_del_announcement " + i + "\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>");
|
||||
}
|
||||
|
||||
adminReply.replace("%announces%", replyMSG.toString());
|
||||
player.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
public void addAnnouncement(String text)
|
||||
{
|
||||
_announcements.add(text);
|
||||
saveToDisk();
|
||||
}
|
||||
|
||||
public void delAnnouncement(int line)
|
||||
{
|
||||
_announcements.remove(line);
|
||||
saveToDisk();
|
||||
}
|
||||
|
||||
private void readFromDisk(File file)
|
||||
{
|
||||
LineNumberReader lnr = null;
|
||||
FileReader reader = null;
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
String line = null;
|
||||
reader = new FileReader(file);
|
||||
lnr = new LineNumberReader(reader);
|
||||
if (lnr.read() == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
while ((line = lnr.readLine()) != null)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(line, "\n\r");
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String announcement = st.nextToken();
|
||||
_announcements.add(announcement);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
LOGGER.info("Announcements: Loaded " + i + " Announcements.");
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
LOGGER.warning("Error reading announcements " + e1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lnr != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
lnr.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning(e1.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (reader != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning(e1.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToDisk()
|
||||
{
|
||||
final File file = new File("data/announcements.txt");
|
||||
FileWriter save = null;
|
||||
|
||||
try
|
||||
{
|
||||
save = new FileWriter(file);
|
||||
for (String _announcement : _announcements)
|
||||
{
|
||||
save.write(_announcement);
|
||||
save.write("\r\n");
|
||||
}
|
||||
save.flush();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning("saving the announcements file has failed: " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (save != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
save.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void announceToAll(String text)
|
||||
{
|
||||
final CreatureSay cs = new CreatureSay(0, ChatType.ANNOUNCEMENT, "", text);
|
||||
for (PlayerInstance player : World.getInstance().getAllPlayers())
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
|
||||
public void criticalAnnounceToAll(String text)
|
||||
{
|
||||
final CreatureSay cs = new CreatureSay(0, ChatType.CRITICAL_ANNOUNCE, null, text);
|
||||
for (PlayerInstance player : World.getInstance().getAllPlayers())
|
||||
{
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void announceToAll(SystemMessage sm)
|
||||
{
|
||||
for (PlayerInstance player : World.getInstance().getAllPlayers())
|
||||
{
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
// Method for handling announcements from admin
|
||||
public void handleAnnounce(String command, int lengthToTrim)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Announce string to everyone on server
|
||||
final String text = command.substring(lengthToTrim);
|
||||
getInstance().announceToAll(text);
|
||||
}
|
||||
// No body cares!
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static Announcements getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final Announcements INSTANCE = new Announcements();
|
||||
}
|
||||
}
|
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.data.sql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.announce.Announcement;
|
||||
import org.l2jmobius.gameserver.model.announce.AnnouncementType;
|
||||
import org.l2jmobius.gameserver.model.announce.AutoAnnouncement;
|
||||
import org.l2jmobius.gameserver.model.announce.IAnnouncement;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* Loads announcements from database.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AnnouncementsTable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AnnouncementsTable.class.getName());
|
||||
|
||||
private final Map<Integer, IAnnouncement> _announcements = new ConcurrentSkipListMap<>();
|
||||
|
||||
protected AnnouncementsTable()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
for (IAnnouncement announcement : _announcements.values())
|
||||
{
|
||||
if ((announcement.getType() == AnnouncementType.AUTO_CRITICAL) || (announcement.getType() == AnnouncementType.AUTO_NORMAL))
|
||||
{
|
||||
((AutoAnnouncement) announcement).stopTask();
|
||||
}
|
||||
}
|
||||
_announcements.clear();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement st = con.createStatement();
|
||||
ResultSet rset = st.executeQuery("SELECT * FROM announcements"))
|
||||
{
|
||||
while (rset.next())
|
||||
{
|
||||
final AnnouncementType type = AnnouncementType.findById(rset.getInt("type"));
|
||||
final Announcement announce;
|
||||
switch (type)
|
||||
{
|
||||
case NORMAL:
|
||||
case CRITICAL:
|
||||
{
|
||||
announce = new Announcement(rset);
|
||||
break;
|
||||
}
|
||||
case AUTO_NORMAL:
|
||||
case AUTO_CRITICAL:
|
||||
{
|
||||
announce = new AutoAnnouncement(rset);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_announcements.put(announce.getId(), announce);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "AnnouncementsTable: Failed loading announcements:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sending all announcements to the player
|
||||
* @param player
|
||||
*/
|
||||
public void showAnnouncements(PlayerInstance player)
|
||||
{
|
||||
sendAnnouncements(player, AnnouncementType.NORMAL);
|
||||
sendAnnouncements(player, AnnouncementType.CRITICAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends all announcements to the player by the specified type
|
||||
* @param player
|
||||
* @param type
|
||||
*/
|
||||
private void sendAnnouncements(PlayerInstance player, AnnouncementType type)
|
||||
{
|
||||
for (IAnnouncement announce : _announcements.values())
|
||||
{
|
||||
if (announce.isValid() && (announce.getType() == type))
|
||||
{
|
||||
player.sendPacket(new CreatureSay(0, type == AnnouncementType.CRITICAL ? ChatType.CRITICAL_ANNOUNCE : ChatType.ANNOUNCEMENT, "", announce.getContent()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends text as announcement to all players.
|
||||
* @param text
|
||||
*/
|
||||
public void announceToAll(String text)
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers(new CreatureSay(0, ChatType.ANNOUNCEMENT, "", text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends text as critical announcement to all players.
|
||||
* @param text
|
||||
*/
|
||||
public void criticalAnnounceToAll(String text)
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers(new CreatureSay(0, ChatType.CRITICAL_ANNOUNCE, "", text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds announcement
|
||||
* @param announce
|
||||
*/
|
||||
public void addAnnouncement(IAnnouncement announce)
|
||||
{
|
||||
addAnnouncement(announce, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds announcement
|
||||
* @param announce
|
||||
* @param store
|
||||
*/
|
||||
public void addAnnouncement(IAnnouncement announce, boolean store)
|
||||
{
|
||||
if (!store || announce.storeMe())
|
||||
{
|
||||
_announcements.put(announce.getId(), announce);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes announcement by id
|
||||
* @param id
|
||||
* @return {@code true} if announcement exists and was deleted successfully, {@code false} otherwise.
|
||||
*/
|
||||
public boolean deleteAnnouncement(int id)
|
||||
{
|
||||
final IAnnouncement announce = _announcements.remove(id);
|
||||
return (announce != null) && announce.deleteMe();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return {@link IAnnouncement} by id
|
||||
*/
|
||||
public IAnnouncement getAnnounce(int id)
|
||||
{
|
||||
return _announcements.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link Collection} containing all announcements
|
||||
*/
|
||||
public Map<Integer, IAnnouncement> getAllAnnouncements()
|
||||
{
|
||||
return _announcements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Single instance of {@link AnnouncementsTable}
|
||||
*/
|
||||
public static AnnouncementsTable getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AnnouncementsTable INSTANCE = new AnnouncementsTable();
|
||||
}
|
||||
}
|
@@ -1,448 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.handler;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* Auto Announcment Handler Automatically send announcment at a set time interval.
|
||||
* @author chief
|
||||
*/
|
||||
public class AutoAnnouncementHandler
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(AutoAnnouncementHandler.class.getName());
|
||||
|
||||
private static final long DEFAULT_ANNOUNCEMENT_DELAY = 180000; // 3 mins by default
|
||||
protected Map<Integer, AutoAnnouncementInstance> _registeredAnnouncements;
|
||||
|
||||
protected AutoAnnouncementHandler()
|
||||
{
|
||||
_registeredAnnouncements = new HashMap<>();
|
||||
restoreAnnouncementData();
|
||||
}
|
||||
|
||||
private void restoreAnnouncementData()
|
||||
{
|
||||
int numLoaded = 0;
|
||||
PreparedStatement statement = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
statement = con.prepareStatement("SELECT * FROM auto_announcements ORDER BY id");
|
||||
rs = statement.executeQuery();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
numLoaded++;
|
||||
registerGlobalAnnouncement(rs.getInt("id"), rs.getString("announcement"), rs.getLong("delay"));
|
||||
}
|
||||
|
||||
statement.close();
|
||||
rs.close();
|
||||
|
||||
LOGGER.info("GameServer: Loaded " + numLoaded + " Auto Announcements.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.info("Problem with AutoAnnouncementHandler: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
public void listAutoAnnouncements(PlayerInstance player)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
final StringBuilder replyMSG = new StringBuilder("<html><body>");
|
||||
replyMSG.append("<table width=260><tr>");
|
||||
replyMSG.append("<td width=40></td>");
|
||||
replyMSG.append("<button value=\"Main\" action=\"bypass -h admin_admin\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br>");
|
||||
replyMSG.append("<td width=180><center>Auto Announcement Menu</center></td>");
|
||||
replyMSG.append("<td width=40></td>");
|
||||
replyMSG.append("</tr></table>");
|
||||
replyMSG.append("<br><br>");
|
||||
replyMSG.append("<center>Add new auto announcement:</center>");
|
||||
replyMSG.append("<center><multiedit var=\"new_autoannouncement\" width=240 height=30></center><br>");
|
||||
replyMSG.append("<br><br>");
|
||||
replyMSG.append("<center>Delay: <edit var=\"delay\" width=70></center>");
|
||||
replyMSG.append("<center>Note: Time in Seconds 60s = 1 min.</center>");
|
||||
replyMSG.append("<center>Note2: Minimum Time is 30 Seconds.</center>");
|
||||
replyMSG.append("<br><br>");
|
||||
replyMSG.append("<center><table><tr><td>");
|
||||
replyMSG.append("<button value=\"Add\" action=\"bypass -h admin_add_autoannouncement $delay $new_autoannouncement\" width=60 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td>");
|
||||
replyMSG.append("</td></tr></table></center>");
|
||||
replyMSG.append("<br>");
|
||||
|
||||
for (AutoAnnouncementInstance announcementInst : getInstance().values())
|
||||
{
|
||||
replyMSG.append("<table width=260><tr><td width=220>[" + announcementInst.getDefaultDelay() + "s] " + announcementInst.getDefaultTexts() + "</td><td width=40>");
|
||||
replyMSG.append("<button value=\"Delete\" action=\"bypass -h admin_del_autoannouncement " + announcementInst.getDefaultId() + "\" width=60 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>");
|
||||
}
|
||||
|
||||
replyMSG.append("</body></html>");
|
||||
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
player.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return _registeredAnnouncements.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a globally active autoannouncement.<br>
|
||||
* Returns the associated auto announcement instance.
|
||||
* @param id
|
||||
* @param announcementTexts
|
||||
* @param announcementDelay announcementDelay (-1 = default delay)
|
||||
* @return AutoAnnouncementInstance announcementInst
|
||||
*/
|
||||
public AutoAnnouncementInstance registerGlobalAnnouncement(int id, String announcementTexts, long announcementDelay)
|
||||
{
|
||||
return registerAnnouncement(id, announcementTexts, announcementDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a NON globally-active auto announcement<br>
|
||||
* Returns the associated auto chat instance.
|
||||
* @param id
|
||||
* @param announcementTexts
|
||||
* @param announcementDelay announcementDelay (-1 = default delay)
|
||||
* @return AutoAnnouncementInstance announcementInst
|
||||
*/
|
||||
public AutoAnnouncementInstance registerAnnouncment(int id, String announcementTexts, long announcementDelay)
|
||||
{
|
||||
return registerAnnouncement(id, announcementTexts, announcementDelay);
|
||||
}
|
||||
|
||||
public AutoAnnouncementInstance registerAnnouncment(String announcementTexts, long announcementDelay)
|
||||
{
|
||||
final int nextId = nextAutoAnnouncmentId();
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
final PreparedStatement statement = con.prepareStatement("INSERT INTO auto_announcements (id,announcement,delay) VALUES (?,?,?)");
|
||||
statement.setInt(1, nextId);
|
||||
statement.setString(2, announcementTexts);
|
||||
statement.setLong(3, announcementDelay);
|
||||
statement.executeUpdate();
|
||||
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("System: Could Not Insert Auto Announcment into DataBase: Reason: Duplicate Id");
|
||||
}
|
||||
return registerAnnouncement(nextId, announcementTexts, announcementDelay);
|
||||
}
|
||||
|
||||
public int nextAutoAnnouncmentId()
|
||||
{
|
||||
int nextId = 0;
|
||||
PreparedStatement statement = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
statement = con.prepareStatement("SELECT id FROM auto_announcements ORDER BY id");
|
||||
rs = statement.executeQuery();
|
||||
|
||||
while (rs.next())
|
||||
{
|
||||
if (rs.getInt("id") > nextId)
|
||||
{
|
||||
nextId = rs.getInt("id");
|
||||
}
|
||||
}
|
||||
|
||||
statement.close();
|
||||
rs.close();
|
||||
|
||||
nextId++;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.info("Problem with AutoAnnouncementHandler: " + e.getMessage());
|
||||
}
|
||||
return nextId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param announcementTexts
|
||||
* @param chatDelay
|
||||
* @return
|
||||
*/
|
||||
private final AutoAnnouncementInstance registerAnnouncement(int id, String announcementTexts, long chatDelay)
|
||||
{
|
||||
AutoAnnouncementInstance announcementInst = null;
|
||||
if (_registeredAnnouncements.containsKey(id))
|
||||
{
|
||||
announcementInst = _registeredAnnouncements.get(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
announcementInst = new AutoAnnouncementInstance(id, announcementTexts, chatDelay < 0 ? DEFAULT_ANNOUNCEMENT_DELAY : chatDelay);
|
||||
}
|
||||
_registeredAnnouncements.put(id, announcementInst);
|
||||
return announcementInst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Collection<AutoAnnouncementInstance> values()
|
||||
{
|
||||
return _registeredAnnouncements.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and cancels ALL auto announcement for the given announcement id.
|
||||
* @param id
|
||||
* @return boolean removedSuccessfully
|
||||
*/
|
||||
public boolean removeAnnouncement(int id)
|
||||
{
|
||||
final AutoAnnouncementInstance announcementInst = _registeredAnnouncements.get(id);
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
final PreparedStatement statement = con.prepareStatement("DELETE FROM auto_announcements WHERE id=?");
|
||||
statement.setInt(1, announcementInst.getDefaultId());
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Could not Delete Auto Announcement in Database, Reason: " + e);
|
||||
}
|
||||
|
||||
return removeAnnouncement(announcementInst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and cancels ALL auto announcement for the given announcement instance.
|
||||
* @param announcementInst
|
||||
* @return boolean removedSuccessfully
|
||||
*/
|
||||
public boolean removeAnnouncement(AutoAnnouncementInstance announcementInst)
|
||||
{
|
||||
if (announcementInst == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_registeredAnnouncements.remove(announcementInst.getDefaultId());
|
||||
announcementInst.setActive(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the associated auto announcement instance either by the given announcement ID or object ID.
|
||||
* @param id
|
||||
* @return AutoAnnouncementInstance announcementInst
|
||||
*/
|
||||
public AutoAnnouncementInstance getAutoAnnouncementInstance(int id)
|
||||
{
|
||||
return _registeredAnnouncements.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active state of all auto announcement instances to that specified, and cancels the scheduled chat task if necessary.
|
||||
* @param isActive
|
||||
*/
|
||||
public void setAutoAnnouncementActive(boolean isActive)
|
||||
{
|
||||
for (AutoAnnouncementInstance announcementInst : _registeredAnnouncements.values())
|
||||
{
|
||||
announcementInst.setActive(isActive);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto Announcement Instance
|
||||
*/
|
||||
public class AutoAnnouncementInstance
|
||||
{
|
||||
private long _defaultDelay = DEFAULT_ANNOUNCEMENT_DELAY;
|
||||
private String _defaultTexts;
|
||||
private boolean _defaultRandom = false;
|
||||
private final Integer _defaultId;
|
||||
|
||||
private boolean _isActive;
|
||||
|
||||
public ScheduledFuture<?> _chatTask;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param announcementTexts
|
||||
* @param announcementDelay
|
||||
*/
|
||||
protected AutoAnnouncementInstance(int id, String announcementTexts, long announcementDelay)
|
||||
{
|
||||
_defaultId = id;
|
||||
_defaultTexts = announcementTexts;
|
||||
_defaultDelay = announcementDelay * 1000;
|
||||
setActive(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isActive()
|
||||
{
|
||||
return _isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isDefaultRandom()
|
||||
{
|
||||
return _defaultRandom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public long getDefaultDelay()
|
||||
{
|
||||
return _defaultDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultTexts()
|
||||
{
|
||||
return _defaultTexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Integer getDefaultId()
|
||||
{
|
||||
return _defaultId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param delayValue
|
||||
*/
|
||||
public void setDefaultChatDelay(long delayValue)
|
||||
{
|
||||
_defaultDelay = delayValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textsValue
|
||||
*/
|
||||
public void setDefaultChatTexts(String textsValue)
|
||||
{
|
||||
_defaultTexts = textsValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param randValue
|
||||
*/
|
||||
public void setDefaultRandom(boolean randValue)
|
||||
{
|
||||
_defaultRandom = randValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeValue
|
||||
*/
|
||||
public void setActive(boolean activeValue)
|
||||
{
|
||||
if (_isActive == activeValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isActive = activeValue;
|
||||
if (_isActive)
|
||||
{
|
||||
final AutoAnnouncementRunner acr = new AutoAnnouncementRunner(_defaultId);
|
||||
_chatTask = ThreadPool.scheduleAtFixedRate(acr, _defaultDelay, _defaultDelay);
|
||||
}
|
||||
else
|
||||
{
|
||||
_chatTask.cancel(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto Announcement Runner<br>
|
||||
* <br>
|
||||
* Represents the auto announcement scheduled task for each announcement instance.
|
||||
* @author chief
|
||||
*/
|
||||
private class AutoAnnouncementRunner implements Runnable
|
||||
{
|
||||
protected int id;
|
||||
|
||||
protected AutoAnnouncementRunner(int pId)
|
||||
{
|
||||
id = pId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void run()
|
||||
{
|
||||
final AutoAnnouncementInstance announcementInst = _registeredAnnouncements.get(id);
|
||||
String text;
|
||||
text = announcementInst.getDefaultTexts();
|
||||
if (text == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Announcements.getInstance().announceToAll(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AutoAnnouncementHandler getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AutoAnnouncementHandler INSTANCE = new AutoAnnouncementHandler();
|
||||
}
|
||||
}
|
@@ -16,16 +16,22 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.handler.admincommandhandlers;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.handler.AutoAnnouncementHandler;
|
||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.announce.Announcement;
|
||||
import org.l2jmobius.gameserver.model.announce.AnnouncementType;
|
||||
import org.l2jmobius.gameserver.model.announce.AutoAnnouncement;
|
||||
import org.l2jmobius.gameserver.model.announce.IAnnouncement;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.BuilderUtil;
|
||||
|
||||
@@ -69,13 +75,13 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
{
|
||||
case "admin_list_announcements":
|
||||
{
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
listAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
case "admin_reload_announcements":
|
||||
{
|
||||
Announcements.getInstance().loadAnnouncements();
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
AnnouncementsTable.getInstance().load();
|
||||
listAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
case "admin_announce_menu":
|
||||
@@ -87,18 +93,18 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
if (!text.equals(""))
|
||||
{
|
||||
Announcements.getInstance().announceToAll(text);
|
||||
AnnouncementsTable.getInstance().announceToAll(text);
|
||||
}
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
listAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
case "admin_announce_announcements":
|
||||
{
|
||||
for (PlayerInstance player : World.getInstance().getAllPlayers())
|
||||
{
|
||||
Announcements.getInstance().showAnnouncements(player);
|
||||
AnnouncementsTable.getInstance().showAnnouncements(player);
|
||||
}
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
listAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
case "admin_add_announcement":
|
||||
@@ -109,8 +115,8 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
if (!text.equals(""))
|
||||
{
|
||||
Announcements.getInstance().addAnnouncement(text);
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
AnnouncementsTable.getInstance().addAnnouncement(new Announcement(AnnouncementType.NORMAL, text, activeChar.getName()));
|
||||
listAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
BuilderUtil.sendSysMessage(activeChar, "You cannot announce Empty message");
|
||||
@@ -132,8 +138,8 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
if (index >= 0)
|
||||
{
|
||||
Announcements.getInstance().delAnnouncement(index);
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
AnnouncementsTable.getInstance().deleteAnnouncement(index);
|
||||
listAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //del_announcement <index> (number >=0)");
|
||||
@@ -141,7 +147,7 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
case "admin_announce":
|
||||
{
|
||||
Announcements.getInstance().handleAnnounce(Config.GM_ANNOUNCER_NAME ? command + " [ " + activeChar.getName() + " ]" : command, 15);
|
||||
AnnouncementsTable.getInstance().announceToAll((Config.GM_ANNOUNCER_NAME ? command + " [ " + activeChar.getName() + " ]" : command).substring(15));
|
||||
return true;
|
||||
}
|
||||
case "admin_critannounce":
|
||||
@@ -156,7 +162,7 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
case "admin_list_autoannouncements":
|
||||
{
|
||||
AutoAnnouncementHandler.getInstance().listAutoAnnouncements(activeChar);
|
||||
listAutoAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
case "admin_add_autoannouncement":
|
||||
@@ -175,15 +181,15 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
String autoAnnounce = st.nextToken();
|
||||
if (delay > 30)
|
||||
text = st.nextToken();
|
||||
if (delay >= 30)
|
||||
{
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
autoAnnounce = autoAnnounce + " " + st.nextToken();
|
||||
text = text + " " + st.nextToken();
|
||||
}
|
||||
AutoAnnouncementHandler.getInstance().registerAnnouncment(autoAnnounce, delay);
|
||||
AutoAnnouncementHandler.getInstance().listAutoAnnouncements(activeChar);
|
||||
AnnouncementsTable.getInstance().addAnnouncement(new AutoAnnouncement(AnnouncementType.AUTO_NORMAL, text, activeChar.getName(), 0, delay, delay));
|
||||
listAutoAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //add_autoannouncement <delay> (Seconds > 30) <Announcements>");
|
||||
@@ -210,8 +216,8 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
if (index >= 0)
|
||||
{
|
||||
AutoAnnouncementHandler.getInstance().removeAnnouncement(index);
|
||||
AutoAnnouncementHandler.getInstance().listAutoAnnouncements(activeChar);
|
||||
AnnouncementsTable.getInstance().deleteAnnouncement(index);
|
||||
listAutoAnnouncements(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -228,7 +234,7 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
}
|
||||
case "admin_autoannounce":
|
||||
{
|
||||
AutoAnnouncementHandler.getInstance().listAutoAnnouncements(activeChar);
|
||||
listAutoAnnouncements(activeChar);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -236,6 +242,44 @@ public class AdminAnnouncements implements IAdminCommandHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
private void listAnnouncements(PlayerInstance player)
|
||||
{
|
||||
final String content = HtmCache.getInstance().getHtmForce("data/html/admin/announce.htm");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setHtml(content);
|
||||
final StringBuilder replyMSG = new StringBuilder("<br>");
|
||||
for (Entry<Integer, IAnnouncement> entry : AnnouncementsTable.getInstance().getAllAnnouncements().entrySet())
|
||||
{
|
||||
final IAnnouncement announcement = entry.getValue();
|
||||
if ((announcement.getType() == AnnouncementType.CRITICAL) || (announcement.getType() == AnnouncementType.NORMAL))
|
||||
{
|
||||
replyMSG.append("<table width=260><tr><td width=220>[" + entry.getKey() + "] " + announcement.getContent() + "</td><td width=40>");
|
||||
replyMSG.append("<button value=\"Delete\" action=\"bypass -h admin_del_announcement " + entry.getKey() + "\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>");
|
||||
}
|
||||
}
|
||||
adminReply.replace("%announces%", replyMSG.toString());
|
||||
player.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
public void listAutoAnnouncements(PlayerInstance player)
|
||||
{
|
||||
final String content = HtmCache.getInstance().getHtmForce("data/html/admin/announce_auto.htm");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setHtml(content);
|
||||
final StringBuilder replyMSG = new StringBuilder("<br>");
|
||||
for (Entry<Integer, IAnnouncement> entry : AnnouncementsTable.getInstance().getAllAnnouncements().entrySet())
|
||||
{
|
||||
final IAnnouncement announcement = entry.getValue();
|
||||
if ((announcement.getType() == AnnouncementType.AUTO_CRITICAL) || (announcement.getType() == AnnouncementType.AUTO_NORMAL))
|
||||
{
|
||||
replyMSG.append("<table width=260><tr><td width=220>[" + entry.getKey() + " (" + ((AutoAnnouncement) announcement).getDelay() + ")] " + announcement.getContent() + "</td><td width=40>");
|
||||
replyMSG.append("<button value=\"Delete\" action=\"bypass -h admin_del_announcement " + entry.getKey() + "\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>");
|
||||
}
|
||||
}
|
||||
adminReply.replace("%announces%", replyMSG.toString());
|
||||
player.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package org.l2jmobius.gameserver.handler.admincommandhandlers;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.xml.MapRegionData;
|
||||
import org.l2jmobius.gameserver.data.xml.ZoneData;
|
||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
@@ -104,15 +104,15 @@ public class AdminTownWar implements IAdminCommandHandler
|
||||
// Announce for all towns
|
||||
if (Config.TW_ALL_TOWNS)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll("Town War Event!");
|
||||
Announcements.getInstance().criticalAnnounceToAll("All towns have been set to war zone by " + activeChar.getName() + ".");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("Town War Event!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("All towns have been set to war zone by " + activeChar.getName() + ".");
|
||||
}
|
||||
|
||||
// Announce for one town
|
||||
if (!Config.TW_ALL_TOWNS)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll("Town War Event!");
|
||||
Announcements.getInstance().criticalAnnounceToAll(MapRegionData.getInstance().getTown(Config.TW_TOWN_ID).getName() + " has been set to war zone by " + activeChar.getName() + ".");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("Town War Event!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(MapRegionData.getInstance().getTown(Config.TW_TOWN_ID).getName() + " has been set to war zone by " + activeChar.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,13 +179,13 @@ public class AdminTownWar implements IAdminCommandHandler
|
||||
// Announce for all towns
|
||||
if (Config.TW_ALL_TOWNS)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll("All towns have been set back to normal by " + activeChar.getName() + ".");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("All towns have been set back to normal by " + activeChar.getName() + ".");
|
||||
}
|
||||
|
||||
// Announce for one town
|
||||
if (!Config.TW_ALL_TOWNS)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(MapRegionData.getInstance().getTown(Config.TW_TOWN_ID).getName() + " has been set back to normal by " + activeChar.getName() + ".");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(MapRegionData.getInstance().getTown(Config.TW_TOWN_ID).getName() + " has been set back to normal by " + activeChar.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,8 +23,8 @@ import java.util.concurrent.Future;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
@@ -700,8 +700,8 @@ public class ChristmasManager
|
||||
{
|
||||
if (isManagerInit == 4)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Christmas Event has begun, have a Merry Christmas and a Happy New Year.");
|
||||
Announcements.getInstance().announceToAll("Christmas Event will end in 24 hours.");
|
||||
AnnouncementsTable.getInstance().announceToAll("Christmas Event has begun, have a Merry Christmas and a Happy New Year.");
|
||||
AnnouncementsTable.getInstance().announceToAll("Christmas Event will end in 24 hours.");
|
||||
LOGGER.info("ChristmasManager:Init ChristmasManager was started successfully, have a festive holiday.");
|
||||
|
||||
final EndEvent ee = new EndEvent();
|
||||
@@ -713,7 +713,7 @@ public class ChristmasManager
|
||||
|
||||
if (isManagerInit == 0)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Christmas Event has ended... Hope you enjoyed the festivities.");
|
||||
AnnouncementsTable.getInstance().announceToAll("Christmas Event has ended... Hope you enjoyed the festivities.");
|
||||
LOGGER.info("ChristmasManager:Terminated ChristmasManager.");
|
||||
isManagerInit = -1;
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
@@ -151,7 +151,7 @@ public class RaidBossSpawnManager
|
||||
AdminData.broadcastMessageToGMs("Spawning Raid Boss " + raidboss.getName() + ".");
|
||||
if (Config.ANNOUNCE_TO_ALL_SPAWN_RB)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Raid boss " + raidboss.getName() + " spawned in world.");
|
||||
AnnouncementsTable.getInstance().announceToAll("Raid boss " + raidboss.getName() + " spawned in world.");
|
||||
}
|
||||
_bosses.put(bossId, raidboss);
|
||||
}
|
||||
|
@@ -28,9 +28,9 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
@@ -741,16 +741,16 @@ public class CTF implements EventTask
|
||||
_inProgress = true;
|
||||
_joining = true;
|
||||
spawnEventNpc();
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Event " + _eventName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Event " + _eventName + "!");
|
||||
if (Config.CTF_ANNOUNCE_REWARD && (ItemTable.getInstance().getTemplate(_rewardId) != null))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
|
||||
}
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Recruiting levels: " + _minLevel + " to " + _maxLevel);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + ".");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Recruiting levels: " + _minLevel + " to " + _maxLevel);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + ".");
|
||||
if (Config.CTF_COMMAND)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Commands .ctfjoin .ctfleave .ctfinfo!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Commands .ctfjoin .ctfleave .ctfinfo!");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -777,7 +777,7 @@ public class CTF implements EventTask
|
||||
}
|
||||
else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size()))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _playersShuffle.size());
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _playersShuffle.size());
|
||||
if (Config.CTF_STATS_LOGGER)
|
||||
{
|
||||
LOGGER.info(_eventName + ":Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _playersShuffle.size());
|
||||
@@ -788,7 +788,7 @@ public class CTF implements EventTask
|
||||
}
|
||||
else if (!checkMinPlayers(_players.size()))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _players.size());
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _players.size());
|
||||
if (Config.CTF_STATS_LOGGER)
|
||||
{
|
||||
LOGGER.info(_eventName + ":Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _players.size());
|
||||
@@ -797,7 +797,7 @@ public class CTF implements EventTask
|
||||
}
|
||||
|
||||
_joining = false;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
|
||||
setUserData();
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
@@ -883,7 +883,7 @@ public class CTF implements EventTask
|
||||
|
||||
afterStartOperations();
|
||||
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Started. Go Capture the Flags!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Started. Go Capture the Flags!");
|
||||
_started = true;
|
||||
return true;
|
||||
}
|
||||
@@ -917,7 +917,7 @@ public class CTF implements EventTask
|
||||
_inProgress = false;
|
||||
_aborted = false;
|
||||
final long delay = _intervalBetweenMatches;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatches + " minute(s)!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatches + " minute(s)!");
|
||||
waiter(delay);
|
||||
|
||||
try
|
||||
@@ -928,7 +928,7 @@ public class CTF implements EventTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": next event aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": next event aborted!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -963,21 +963,21 @@ public class CTF implements EventTask
|
||||
|
||||
if (Config.CTF_ANNOUNCE_TEAM_STATS)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + " Team Statistics:");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + " Team Statistics:");
|
||||
for (String team : _teams)
|
||||
{
|
||||
final int _flags_ = teamPointsCount(team);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Team: " + team + " - Flags taken: " + _flags_);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Team: " + team + " - Flags taken: " + _flags_);
|
||||
}
|
||||
}
|
||||
|
||||
if (_topTeam != null)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Team " + _topTeam + " wins the match, with " + _topScore + " flags taken!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Team " + _topTeam + " wins the match, with " + _topScore + " flags taken!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: " + _topScore + " flags taken by each team!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: " + _topScore + " flags taken by each team!");
|
||||
}
|
||||
rewardTeam(_topTeam);
|
||||
|
||||
@@ -996,7 +996,7 @@ public class CTF implements EventTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: No team wins the match(nobody took flags)!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: No team wins the match(nobody took flags)!");
|
||||
if (Config.CTF_STATS_LOGGER)
|
||||
{
|
||||
LOGGER.info(_eventName + ": No team win the match(nobody took flags).");
|
||||
@@ -1037,7 +1037,7 @@ public class CTF implements EventTask
|
||||
cleanCTF();
|
||||
_joining = false;
|
||||
_inProgress = false;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
return;
|
||||
}
|
||||
_joining = false;
|
||||
@@ -1048,7 +1048,7 @@ public class CTF implements EventTask
|
||||
|
||||
afterFinish();
|
||||
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
teleportFinish();
|
||||
}
|
||||
|
||||
@@ -1066,7 +1066,7 @@ public class CTF implements EventTask
|
||||
public static void teleportFinish()
|
||||
{
|
||||
sit();
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
synchronized (_players)
|
||||
@@ -1228,12 +1228,12 @@ public class CTF implements EventTask
|
||||
removeOfflinePlayers();
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till registration close!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1248,12 +1248,12 @@ public class CTF implements EventTask
|
||||
{
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till registration close!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1270,15 +1270,15 @@ public class CTF implements EventTask
|
||||
{
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
|
||||
}
|
||||
else if (_teleport)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2589,7 +2589,7 @@ public class CTF implements EventTask
|
||||
{
|
||||
if (!_started && !_aborted)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Thank you For Participating At, " + _eventName + " Event.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Thank you For Participating At, " + _eventName + " Event.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2764,13 +2764,13 @@ public class CTF implements EventTask
|
||||
// logged off with a flag in his hands
|
||||
if (!player.isOnline() && player._haveFlagCTF)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + player.getName() + " logged off with a CTF flag!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + player.getName() + " logged off with a CTF flag!");
|
||||
player._haveFlagCTF = false;
|
||||
if ((_teams.indexOf(player._teamNameHaveFlagCTF) >= 0) && _flagsTaken.get(_teams.indexOf(player._teamNameHaveFlagCTF)))
|
||||
{
|
||||
_flagsTaken.set(_teams.indexOf(player._teamNameHaveFlagCTF), false);
|
||||
spawnFlag(player._teamNameHaveFlagCTF);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + player._teamNameHaveFlagCTF + " flag now returned to place.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + player._teamNameHaveFlagCTF + " flag now returned to place.");
|
||||
}
|
||||
removeFlagFromPlayer(player);
|
||||
player._teamNameHaveFlagCTF = null;
|
||||
@@ -2796,7 +2796,7 @@ public class CTF implements EventTask
|
||||
{
|
||||
_flagsTaken.set(index, false);
|
||||
spawnFlag(team);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + team + " flag returned due to player error.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + team + " flag returned due to player error.");
|
||||
}
|
||||
}
|
||||
// Check if a player ran away from the event holding a flag:
|
||||
@@ -2806,13 +2806,13 @@ public class CTF implements EventTask
|
||||
{
|
||||
if ((player != null) && player._haveFlagCTF && isOutsideCTFArea(player))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + player.getName() + " escaped from the event holding a flag!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + player.getName() + " escaped from the event holding a flag!");
|
||||
player._haveFlagCTF = false;
|
||||
if ((_teams.indexOf(player._teamNameHaveFlagCTF) >= 0) && _flagsTaken.get(_teams.indexOf(player._teamNameHaveFlagCTF)))
|
||||
{
|
||||
_flagsTaken.set(_teams.indexOf(player._teamNameHaveFlagCTF), false);
|
||||
spawnFlag(player._teamNameHaveFlagCTF);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + player._teamNameHaveFlagCTF + " flag now returned to place.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + player._teamNameHaveFlagCTF + " flag now returned to place.");
|
||||
}
|
||||
removeFlagFromPlayer(player);
|
||||
player._teamNameHaveFlagCTF = null;
|
||||
@@ -3090,7 +3090,7 @@ public class CTF implements EventTask
|
||||
player.broadcastUserInfo();
|
||||
removeFlagFromPlayer(player);
|
||||
_teamPointsCount.set(indexOwn, teamPointsCount(team) + 1);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + player.getName() + " scores for " + player._teamNameCTF + ".");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + player.getName() + " scores for " + player._teamNameCTF + ".");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3105,7 +3105,7 @@ public class CTF implements EventTask
|
||||
addFlagToPlayer(player);
|
||||
player.broadcastUserInfo();
|
||||
player._haveFlagCTF = true;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + team + " flag taken by " + player.getName() + "...");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + team + " flag taken by " + player.getName() + "...");
|
||||
pointTeamTo(player, team);
|
||||
break;
|
||||
}
|
||||
|
@@ -28,9 +28,9 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.enums.ClassId;
|
||||
@@ -701,19 +701,19 @@ public class DM implements EventTask
|
||||
_inProgress = true;
|
||||
_joining = true;
|
||||
spawnEventNpc();
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Event " + _eventName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Event " + _eventName + "!");
|
||||
if (Config.DM_ANNOUNCE_REWARD && (ItemTable.getInstance().getTemplate(_rewardId) != null))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
|
||||
}
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Recruiting levels: " + _minLevel + " to " + _maxLevel);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Recruiting levels: " + _minLevel + " to " + _maxLevel);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName);
|
||||
if (Config.DM_COMMAND)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Commands .dmjoin .dmleave .dminfo");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Commands .dmjoin .dmleave .dminfo");
|
||||
}
|
||||
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": FULL BUFF Event: be ready with your buffs, they won't be deleted!!!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": FULL BUFF Event: be ready with your buffs, they won't be deleted!!!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -737,7 +737,7 @@ public class DM implements EventTask
|
||||
final int size = _players.size();
|
||||
if (!checkMinPlayers(size))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + size);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + size);
|
||||
if (Config.DM_STATS_LOGGER)
|
||||
{
|
||||
LOGGER.info(_eventName + ":Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + size);
|
||||
@@ -749,7 +749,7 @@ public class DM implements EventTask
|
||||
}
|
||||
|
||||
_joining = false;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
|
||||
setUserData();
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
@@ -823,7 +823,7 @@ public class DM implements EventTask
|
||||
|
||||
afterStartOperations();
|
||||
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Started. Go to kill your enemies!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Started. Go to kill your enemies!");
|
||||
_started = true;
|
||||
return true;
|
||||
}
|
||||
@@ -864,7 +864,7 @@ public class DM implements EventTask
|
||||
_inProgress = false;
|
||||
_aborted = false;
|
||||
final long delay = _intervalBetweenMatches;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatches + " minute(s)!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatches + " minute(s)!");
|
||||
waiter(delay);
|
||||
|
||||
try
|
||||
@@ -875,7 +875,7 @@ public class DM implements EventTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": next event aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": next event aborted!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -915,7 +915,7 @@ public class DM implements EventTask
|
||||
{
|
||||
winners = winners + " " + winner.getName();
|
||||
}
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + winners + " win the match! " + _topKills + " kills.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + winners + " win the match! " + _topKills + " kills.");
|
||||
rewardPlayer();
|
||||
|
||||
if (Config.DM_STATS_LOGGER)
|
||||
@@ -926,7 +926,7 @@ public class DM implements EventTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": No players win the match(nobody killed).");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": No players win the match(nobody killed).");
|
||||
if (Config.DM_STATS_LOGGER)
|
||||
{
|
||||
LOGGER.info(_eventName + ": No players win the match(nobody killed).");
|
||||
@@ -960,7 +960,7 @@ public class DM implements EventTask
|
||||
cleanDM();
|
||||
_joining = false;
|
||||
_inProgress = false;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
return;
|
||||
}
|
||||
_joining = false;
|
||||
@@ -971,7 +971,7 @@ public class DM implements EventTask
|
||||
|
||||
afterFinish();
|
||||
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
teleportFinish();
|
||||
}
|
||||
|
||||
@@ -989,7 +989,7 @@ public class DM implements EventTask
|
||||
{
|
||||
sit();
|
||||
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
|
||||
removeUserData();
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
@@ -1141,12 +1141,12 @@ public class DM implements EventTask
|
||||
removeOfflinePlayers();
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till registration close!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1161,12 +1161,12 @@ public class DM implements EventTask
|
||||
{
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till registration close!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1183,15 +1183,15 @@ public class DM implements EventTask
|
||||
{
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
|
||||
}
|
||||
else if (_teleport)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2006,7 +2006,7 @@ public class DM implements EventTask
|
||||
{
|
||||
if (!_started && !_aborted)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Thank you For participating!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Thank you For participating!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,9 +28,9 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||
@@ -706,16 +706,16 @@ public class TvT implements EventTask
|
||||
_inProgress = true;
|
||||
_joining = true;
|
||||
spawnEventNpc();
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Event " + _eventName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Event " + _eventName + "!");
|
||||
if (Config.TVT_ANNOUNCE_REWARD && (ItemTable.getInstance().getTemplate(_rewardId) != null))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
|
||||
}
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Recruiting levels: " + _minLevel + " to " + _maxLevel);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + ".");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Recruiting levels: " + _minLevel + " to " + _maxLevel);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + ".");
|
||||
if (Config.TVT_COMMAND)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Commands .tvtjoin .tvtleave .tvtinfo");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Commands .tvtjoin .tvtleave .tvtinfo");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -740,7 +740,7 @@ public class TvT implements EventTask
|
||||
}
|
||||
else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size()))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _playersShuffle.size());
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _playersShuffle.size());
|
||||
if (Config.CTF_STATS_LOGGER)
|
||||
{
|
||||
LOGGER.info(_eventName + ":Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _playersShuffle.size());
|
||||
@@ -750,7 +750,7 @@ public class TvT implements EventTask
|
||||
}
|
||||
|
||||
_joining = false;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
|
||||
setUserData();
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
@@ -819,7 +819,7 @@ public class TvT implements EventTask
|
||||
closeAdenColosseumDoors();
|
||||
}
|
||||
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Started. Go to kill your enemies!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Started. Go to kill your enemies!");
|
||||
_started = true;
|
||||
return true;
|
||||
}
|
||||
@@ -835,7 +835,7 @@ public class TvT implements EventTask
|
||||
_inProgress = false;
|
||||
_aborted = false;
|
||||
final long delay = _intervalBetweenMatches;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatches + " minute(s)!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatches + " minute(s)!");
|
||||
waiter(delay);
|
||||
|
||||
try
|
||||
@@ -846,7 +846,7 @@ public class TvT implements EventTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": next event aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": next event aborted!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -884,30 +884,30 @@ public class TvT implements EventTask
|
||||
|
||||
if (Config.TVT_ANNOUNCE_TEAM_STATS)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + " Team Statistics:");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + " Team Statistics:");
|
||||
for (String team : _teams)
|
||||
{
|
||||
final int _kills = teamKillsCount(team);
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Team: " + team + " - Kills: " + _kills);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Team: " + team + " - Kills: " + _kills);
|
||||
}
|
||||
|
||||
if (bestKiller != null)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Top killer: " + bestKiller.getName() + " - Kills: " + bestKiller._countTvTkills);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Top killer: " + bestKiller.getName() + " - Kills: " + bestKiller._countTvTkills);
|
||||
}
|
||||
if ((looser != null) && (!looser.equals(bestKiller)))
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Top looser: " + looser.getName() + " - Dies: " + looser._countTvTdies);
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Top looser: " + looser.getName() + " - Dies: " + looser._countTvTdies);
|
||||
}
|
||||
}
|
||||
|
||||
if (_topTeam != null)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + _topTeam + "'s win the match! " + _topKills + " kills.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + _topTeam + "'s win the match! " + _topKills + " kills.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: " + _topKills + " kills by each team!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: " + _topKills + " kills by each team!");
|
||||
}
|
||||
rewardTeam(_topTeam, bestKiller, looser);
|
||||
if (Config.TVT_STATS_LOGGER)
|
||||
@@ -934,7 +934,7 @@ public class TvT implements EventTask
|
||||
}
|
||||
else
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: No team wins the match(nobody killed)!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: No team wins the match(nobody killed)!");
|
||||
if (Config.TVT_STATS_LOGGER)
|
||||
{
|
||||
LOGGER.info(_eventName + ": No team win the match(nobody killed).");
|
||||
@@ -984,7 +984,7 @@ public class TvT implements EventTask
|
||||
cleanTvT();
|
||||
_joining = false;
|
||||
_inProgress = false;
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
return;
|
||||
}
|
||||
_joining = false;
|
||||
@@ -992,7 +992,7 @@ public class TvT implements EventTask
|
||||
_started = false;
|
||||
_aborted = true;
|
||||
unspawnEventNpc();
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
|
||||
teleportFinish();
|
||||
}
|
||||
|
||||
@@ -1002,7 +1002,7 @@ public class TvT implements EventTask
|
||||
public static void teleportFinish()
|
||||
{
|
||||
sit();
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
synchronized (_players)
|
||||
@@ -1162,12 +1162,12 @@ public class TvT implements EventTask
|
||||
removeOfflinePlayers();
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till registration close!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1182,12 +1182,12 @@ public class TvT implements EventTask
|
||||
{
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till registration close!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1204,15 +1204,15 @@ public class TvT implements EventTask
|
||||
{
|
||||
if (_joining)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
|
||||
}
|
||||
else if (_teleport)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
|
||||
}
|
||||
else if (_started)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2477,7 +2477,7 @@ public class TvT implements EventTask
|
||||
{
|
||||
if (!_started && !_aborted)
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll(_eventName + ": Thank you For Participating At, " + _eventName + " Event.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Thank you For Participating At, " + _eventName + " Event.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,8 +27,8 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.enums.Race;
|
||||
@@ -342,7 +342,7 @@ public class VIP
|
||||
|
||||
_inProgress = true;
|
||||
_joining = true;
|
||||
Announcements.getInstance().criticalAnnounceToAll("Vip event has started.Use .vipjoin to join or .vipleave to leave.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("Vip event has started.Use .vipjoin to join or .vipleave to leave.");
|
||||
spawnJoinNPC();
|
||||
|
||||
ThreadPool.schedule(() ->
|
||||
@@ -355,21 +355,21 @@ public class VIP
|
||||
|
||||
public static void startEvent()
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll("Registration for the VIP event involving " + _teamName + " has ended.");
|
||||
Announcements.getInstance().criticalAnnounceToAll("Players will be teleported to their locations in 20 seconds.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("Registration for the VIP event involving " + _teamName + " has ended.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("Players will be teleported to their locations in 20 seconds.");
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
teleportPlayers();
|
||||
chooseVIP();
|
||||
setUserData();
|
||||
Announcements.getInstance().criticalAnnounceToAll("Players have been teleported for the VIP event.");
|
||||
Announcements.getInstance().criticalAnnounceToAll("VIP event will start in 20 seconds.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("Players have been teleported for the VIP event.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("VIP event will start in 20 seconds.");
|
||||
spawnEndNPC();
|
||||
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll("VIP event has started. " + _teamName + "'s VIP must get to the starter city and talk with " + getNPCName(_endNPC, null) + ". The opposing team must kill the VIP. All players except the VIP will respawn at their current locations.");
|
||||
Announcements.getInstance().criticalAnnounceToAll("VIP event will end if the " + _teamName + " team makes it to their town or when " + (_time / 1000 / 60) + " mins have elapsed.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("VIP event has started. " + _teamName + "'s VIP must get to the starter city and talk with " + getNPCName(_endNPC, null) + ". The opposing team must kill the VIP. All players except the VIP will respawn at their current locations.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("VIP event will end if the " + _teamName + " team makes it to their town or when " + (_time / 1000 / 60) + " mins have elapsed.");
|
||||
VIP.sit();
|
||||
|
||||
ThreadPool.schedule(VIP::endEventTime, _time);
|
||||
@@ -387,7 +387,7 @@ public class VIP
|
||||
|
||||
_started = false;
|
||||
unspawnEventNpcs();
|
||||
Announcements.getInstance().criticalAnnounceToAll("The VIP has died. The opposing team has won.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("The VIP has died. The opposing team has won.");
|
||||
rewardNotVIP();
|
||||
teleportFinish();
|
||||
}
|
||||
@@ -402,7 +402,7 @@ public class VIP
|
||||
|
||||
_started = false;
|
||||
unspawnEventNpcs();
|
||||
Announcements.getInstance().criticalAnnounceToAll("The time has run out and the " + _teamName + "'s have not made it to their goal. Everybody on the opposing team wins.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("The time has run out and the " + _teamName + "'s have not made it to their goal. Everybody on the opposing team wins.");
|
||||
rewardNotVIP();
|
||||
teleportFinish();
|
||||
}
|
||||
@@ -469,7 +469,7 @@ public class VIP
|
||||
|
||||
_started = false;
|
||||
unspawnEventNpcs();
|
||||
Announcements.getInstance().criticalAnnounceToAll("The VIP has made it to the goal. " + _teamName + " has won. Everybody on that team wins.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("The VIP has made it to the goal. " + _teamName + " has won. Everybody on that team wins.");
|
||||
rewardVIP();
|
||||
teleportFinish();
|
||||
}
|
||||
@@ -610,7 +610,7 @@ public class VIP
|
||||
|
||||
public static void teleportFinish()
|
||||
{
|
||||
Announcements.getInstance().criticalAnnounceToAll("Teleporting VIP players back to the Registration area in 20 seconds.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll("Teleporting VIP players back to the Registration area in 20 seconds.");
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
for (PlayerInstance player1 : _playersVIP)
|
||||
|
@@ -28,10 +28,11 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
public class Lottery
|
||||
{
|
||||
@@ -171,7 +172,7 @@ public class Lottery
|
||||
|
||||
_isSellingTickets = true;
|
||||
_isStarted = true;
|
||||
Announcements.getInstance().announceToAll("Lottery tickets are now available for Lucky Lottery #" + getId() + ".");
|
||||
AnnouncementsTable.getInstance().announceToAll("Lottery tickets are now available for Lucky Lottery #" + getId() + ".");
|
||||
final Calendar finishtime = Calendar.getInstance();
|
||||
finishtime.setTimeInMillis(_enddate);
|
||||
finishtime.set(Calendar.MINUTE, 0);
|
||||
@@ -220,7 +221,7 @@ public class Lottery
|
||||
public void run()
|
||||
{
|
||||
_isSellingTickets = false;
|
||||
Announcements.getInstance().announceToAll(new SystemMessage(SystemMessageId.LOTTERY_TICKET_SALES_HAVE_BEEN_TEMPORARILY_SUSPENDED));
|
||||
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.LOTTERY_TICKET_SALES_HAVE_BEEN_TEMPORARILY_SUSPENDED));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +362,7 @@ public class Lottery
|
||||
sm.addNumber(_number);
|
||||
sm.addNumber(_prize);
|
||||
sm.addNumber(count1);
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -369,7 +370,7 @@ public class Lottery
|
||||
sm = new SystemMessage(SystemMessageId.THE_PRIZE_AMOUNT_FOR_LUCKY_LOTTERY_S1_IS_S2_ADENA_THERE_WAS_NO_FIRST_PRIZE_WINNER_IN_THIS_DRAWING_THEREFORE_THE_JACKPOT_WILL_BE_ADDED_TO_THE_NEXT_DRAWING);
|
||||
sm.addNumber(_number);
|
||||
sm.addNumber(_prize);
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
|
@@ -50,11 +50,11 @@ import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.cache.WarehouseCacheManager;
|
||||
import org.l2jmobius.gameserver.communitybbs.BB.Forum;
|
||||
import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.HeroSkillTable;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.NobleSkillTable;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SkillTreeTable;
|
||||
@@ -5926,7 +5926,7 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
if (_isTheVIP && !pk._inEventVIP)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("VIP Killed by non-event character. VIP going back to initial spawn.");
|
||||
AnnouncementsTable.getInstance().announceToAll("VIP Killed by non-event character. VIP going back to initial spawn.");
|
||||
doRevive();
|
||||
teleToLocation(VIP._startX, VIP._startY, VIP._startZ);
|
||||
}
|
||||
@@ -6047,7 +6047,7 @@ public class PlayerInstance extends Playable
|
||||
CTF.removeFlagFromPlayer(this);
|
||||
broadcastUserInfo();
|
||||
_haveFlagCTF = false;
|
||||
Announcements.getInstance().criticalAnnounceToAll(CTF.getEventName() + "(CTF): " + _teamNameHaveFlagCTF + "'s flag returned.");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(CTF.getEventName() + "(CTF): " + _teamNameHaveFlagCTF + "'s flag returned.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6259,11 +6259,11 @@ public class PlayerInstance extends Playable
|
||||
increasePvpKills();
|
||||
if ((target instanceof PlayerInstance) && Config.ANNOUNCE_PVP_KILL)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Player " + getName() + " hunted Player " + target.getName());
|
||||
AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " hunted Player " + target.getName());
|
||||
}
|
||||
else if ((target instanceof PlayerInstance) && Config.ANNOUNCE_ALL_KILL)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Player " + getName() + " killed Player " + target.getName());
|
||||
AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " killed Player " + target.getName());
|
||||
}
|
||||
addItemReward(targetPlayer);
|
||||
return;
|
||||
@@ -6281,7 +6281,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
if ((target instanceof PlayerInstance) && Config.ANNOUNCE_PVP_KILL)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Player " + getName() + " hunted Player " + target.getName());
|
||||
AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " hunted Player " + target.getName());
|
||||
}
|
||||
}
|
||||
else if (targetPlayer.getPvpFlag() == 0) // Target player doesn't have karma
|
||||
@@ -6289,14 +6289,14 @@ public class PlayerInstance extends Playable
|
||||
increasePkKillsAndKarma(targetPlayer.getLevel());
|
||||
if ((target instanceof PlayerInstance) && Config.ANNOUNCE_PK_KILL)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Player " + getName() + " has assassinated Player " + target.getName());
|
||||
AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " has assassinated Player " + target.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((target instanceof PlayerInstance) && Config.ANNOUNCE_ALL_KILL)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Player " + getName() + " killed Player " + target.getName());
|
||||
AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " killed Player " + target.getName());
|
||||
}
|
||||
|
||||
if (_inEventDM && DM.hasStarted())
|
||||
@@ -6477,7 +6477,7 @@ public class PlayerInstance extends Playable
|
||||
if ((_heroConsecutiveKillCount == Config.KILLS_TO_GET_WAR_LEGEND_AURA) && Config.WAR_LEGEND_AURA)
|
||||
{
|
||||
setHeroAura(true);
|
||||
Announcements.getInstance().criticalAnnounceToAll(getName() + " becames War Legend with " + Config.KILLS_TO_GET_WAR_LEGEND_AURA + " PvP!!");
|
||||
AnnouncementsTable.getInstance().criticalAnnounceToAll(getName() + " becames War Legend with " + Config.KILLS_TO_GET_WAR_LEGEND_AURA + " PvP!!");
|
||||
}
|
||||
|
||||
if (Config.PVPEXPSP_SYSTEM)
|
||||
|
@@ -18,8 +18,8 @@ package org.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.CoupleManager;
|
||||
import org.l2jmobius.gameserver.model.Skill;
|
||||
import org.l2jmobius.gameserver.model.Wedding;
|
||||
@@ -202,7 +202,7 @@ public class WeddingManagerInstance extends NpcInstance
|
||||
|
||||
if (Config.ANNOUNCE_WEDDING)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Congratulations to " + player.getName() + " and " + ptarget.getName() + "! They have been married.");
|
||||
AnnouncementsTable.getInstance().announceToAll("Congratulations to " + player.getName() + " and " + ptarget.getName() + "! They have been married.");
|
||||
}
|
||||
|
||||
filename = "data/html/mods/Wedding_accepted.htm";
|
||||
|
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.announce;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Announcement implements IAnnouncement
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(Announcement.class.getName());
|
||||
|
||||
private static final String INSERT_QUERY = "INSERT INTO announcements (type, content, author) VALUES (?, ?, ?)";
|
||||
private static final String UPDATE_QUERY = "UPDATE announcements SET type = ?, content = ?, author = ? WHERE id = ?";
|
||||
private static final String DELETE_QUERY = "DELETE FROM announcements WHERE id = ?";
|
||||
|
||||
protected int _id;
|
||||
private AnnouncementType _type;
|
||||
private String _content;
|
||||
private String _author;
|
||||
|
||||
public Announcement(AnnouncementType type, String content, String author)
|
||||
{
|
||||
_type = type;
|
||||
_content = content;
|
||||
_author = author;
|
||||
}
|
||||
|
||||
public Announcement(ResultSet rset) throws SQLException
|
||||
{
|
||||
_id = rset.getInt("id");
|
||||
_type = AnnouncementType.findById(rset.getInt("type"));
|
||||
_content = rset.getString("content");
|
||||
_author = rset.getString("author");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnouncementType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(AnnouncementType type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent()
|
||||
{
|
||||
return _content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContent(String content)
|
||||
{
|
||||
_content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor()
|
||||
{
|
||||
return _author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
_author = author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storeMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
|
||||
{
|
||||
ps.setInt(1, _type.ordinal());
|
||||
ps.setString(2, _content);
|
||||
ps.setString(3, _author);
|
||||
ps.execute();
|
||||
try (ResultSet rset = ps.getGeneratedKeys())
|
||||
{
|
||||
if (rset.next())
|
||||
{
|
||||
_id = rset.getInt(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't store announcement: ", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
|
||||
{
|
||||
ps.setInt(1, _type.ordinal());
|
||||
ps.setString(2, _content);
|
||||
ps.setString(3, _author);
|
||||
ps.setInt(4, _id);
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't store announcement: ", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_QUERY))
|
||||
{
|
||||
ps.setInt(1, _id);
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't remove announcement: ", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.announce;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum AnnouncementType
|
||||
{
|
||||
NORMAL,
|
||||
CRITICAL,
|
||||
AUTO_NORMAL,
|
||||
AUTO_CRITICAL;
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(AnnouncementType.class.getName());
|
||||
|
||||
public static AnnouncementType findById(int id)
|
||||
{
|
||||
for (AnnouncementType type : values())
|
||||
{
|
||||
if (type.ordinal() == id)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
LOGGER.log(Level.WARNING, AnnouncementType.class.getSimpleName() + ": Unexistent id specified: " + id + "!", new IllegalStateException());
|
||||
return NORMAL;
|
||||
}
|
||||
|
||||
public static AnnouncementType findByName(String name)
|
||||
{
|
||||
for (AnnouncementType type : values())
|
||||
{
|
||||
if (type.name().equalsIgnoreCase(name))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
LOGGER.log(Level.WARNING, AnnouncementType.class.getSimpleName() + ": Unexistent name specified: " + name + "!", new IllegalStateException());
|
||||
return NORMAL;
|
||||
}
|
||||
}
|
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.announce;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AutoAnnouncement extends Announcement implements Runnable
|
||||
{
|
||||
private static final String INSERT_QUERY = "INSERT INTO announcements (`type`, `content`, `author`, `initial`, `delay`, `repeat`) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
private static final String UPDATE_QUERY = "UPDATE announcements SET `type` = ?, `content` = ?, `author` = ?, `initial` = ?, `delay` = ?, `repeat` = ? WHERE id = ?";
|
||||
|
||||
private long _initial;
|
||||
private long _delay;
|
||||
private int _repeat = -1;
|
||||
private int _currentState;
|
||||
private ScheduledFuture<?> _task;
|
||||
|
||||
public AutoAnnouncement(AnnouncementType type, String content, String author, long initial, long delay, int repeat)
|
||||
{
|
||||
super(type, content, author);
|
||||
_initial = initial;
|
||||
_delay = delay;
|
||||
_repeat = repeat;
|
||||
restartMe();
|
||||
}
|
||||
|
||||
public AutoAnnouncement(ResultSet rset) throws SQLException
|
||||
{
|
||||
super(rset);
|
||||
_initial = rset.getLong("initial");
|
||||
_delay = rset.getLong("delay");
|
||||
_repeat = rset.getInt("repeat");
|
||||
restartMe();
|
||||
}
|
||||
|
||||
public long getInitial()
|
||||
{
|
||||
return _initial;
|
||||
}
|
||||
|
||||
public void setInitial(long initial)
|
||||
{
|
||||
_initial = initial;
|
||||
}
|
||||
|
||||
public long getDelay()
|
||||
{
|
||||
return _delay;
|
||||
}
|
||||
|
||||
public void setDelay(long delay)
|
||||
{
|
||||
_delay = delay;
|
||||
}
|
||||
|
||||
public int getRepeat()
|
||||
{
|
||||
return _repeat;
|
||||
}
|
||||
|
||||
public void setRepeat(int repeat)
|
||||
{
|
||||
_repeat = repeat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storeMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
|
||||
{
|
||||
ps.setInt(1, getType().ordinal());
|
||||
ps.setString(2, getContent());
|
||||
ps.setString(3, getAuthor());
|
||||
ps.setLong(4, _initial);
|
||||
ps.setLong(5, _delay);
|
||||
ps.setInt(6, _repeat);
|
||||
ps.execute();
|
||||
try (ResultSet rset = ps.getGeneratedKeys())
|
||||
{
|
||||
if (rset.next())
|
||||
{
|
||||
_id = rset.getInt(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't store announcement: ", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
|
||||
{
|
||||
ps.setInt(1, getType().ordinal());
|
||||
ps.setString(2, getContent());
|
||||
ps.setString(3, getAuthor());
|
||||
ps.setLong(4, _initial);
|
||||
ps.setLong(5, _delay);
|
||||
ps.setLong(6, _repeat);
|
||||
ps.setLong(7, getId());
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't update announcement: ", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteMe()
|
||||
{
|
||||
if ((_task != null) && !_task.isCancelled())
|
||||
{
|
||||
_task.cancel(false);
|
||||
}
|
||||
return super.deleteMe();
|
||||
}
|
||||
|
||||
public void restartMe()
|
||||
{
|
||||
if ((_task != null) && !_task.isCancelled())
|
||||
{
|
||||
_task.cancel(false);
|
||||
}
|
||||
_currentState = _repeat;
|
||||
_task = ThreadPool.schedule(this, _initial * 1000);
|
||||
}
|
||||
|
||||
public void stopTask()
|
||||
{
|
||||
if ((_task != null) && !_task.isCancelled())
|
||||
{
|
||||
_task.cancel(true);
|
||||
_task = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if ((_currentState != -1) && (_currentState <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (String content : getContent().split(Config.EOL))
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers(new CreatureSay(0, getType() == AnnouncementType.AUTO_CRITICAL ? ChatType.CRITICAL_ANNOUNCE : ChatType.ANNOUNCEMENT, null, content));
|
||||
}
|
||||
if (_currentState != -1)
|
||||
{
|
||||
_currentState--;
|
||||
}
|
||||
_task = ThreadPool.schedule(this, _delay * 1000);
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.announce;
|
||||
|
||||
import org.l2jmobius.gameserver.model.interfaces.IDeletable;
|
||||
import org.l2jmobius.gameserver.model.interfaces.IStorable;
|
||||
import org.l2jmobius.gameserver.model.interfaces.IUpdatable;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public interface IAnnouncement extends IStorable, IUpdatable, IDeletable
|
||||
{
|
||||
int getId();
|
||||
|
||||
AnnouncementType getType();
|
||||
|
||||
void setType(AnnouncementType type);
|
||||
|
||||
boolean isValid();
|
||||
|
||||
String getContent();
|
||||
|
||||
void setContent(String content);
|
||||
|
||||
String getAuthor();
|
||||
|
||||
void setAuthor(String author);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.interfaces;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public interface IUpdatable
|
||||
{
|
||||
boolean updateMe();
|
||||
}
|
@@ -42,7 +42,7 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.OlympiadStadiaManager;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
@@ -51,6 +51,7 @@ import org.l2jmobius.gameserver.model.spawn.Spawn;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
public class Olympiad
|
||||
{
|
||||
@@ -413,8 +414,8 @@ public class Olympiad
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.PERIOD_S1_OF_THE_GRAND_OLYMPIAD_GAMES_HAS_NOW_ENDED);
|
||||
sm.addNumber(_currentCycle);
|
||||
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Announcements.getInstance().announceToAll("Olympiad Validation Period has began");
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
AnnouncementsTable.getInstance().announceToAll("Olympiad Validation Period has began");
|
||||
if (_scheduledWeeklyTask != null)
|
||||
{
|
||||
_scheduledWeeklyTask.cancel(true);
|
||||
@@ -441,7 +442,7 @@ public class Olympiad
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Olympiad Validation Period has ended");
|
||||
AnnouncementsTable.getInstance().announceToAll("Olympiad Validation Period has ended");
|
||||
_period = 0;
|
||||
_currentCycle++;
|
||||
deleteNobles();
|
||||
@@ -791,7 +792,7 @@ public class Olympiad
|
||||
|
||||
_inCompPeriod = true;
|
||||
final OlympiadManager om = OlympiadManager.getInstance();
|
||||
Announcements.getInstance().announceToAll(new SystemMessage(SystemMessageId.SHARPEN_YOUR_SWORDS_TIGHTEN_THE_STITCHINGS_IN_YOUR_ARMOR_AND_MAKE_HASTE_TO_A_GRAND_OLYMPIAD_MANAGER_BATTLES_IN_THE_GRAND_OLYMPIAD_GAMES_ARE_NOW_TAKING_PLACE));
|
||||
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.SHARPEN_YOUR_SWORDS_TIGHTEN_THE_STITCHINGS_IN_YOUR_ARMOR_AND_MAKE_HASTE_TO_A_GRAND_OLYMPIAD_MANAGER_BATTLES_IN_THE_GRAND_OLYMPIAD_GAMES_ARE_NOW_TAKING_PLACE));
|
||||
LOGGER.info("Olympiad System: Olympiad Game Started");
|
||||
|
||||
final Thread olyCycle = new Thread(om);
|
||||
@@ -800,7 +801,7 @@ public class Olympiad
|
||||
final long regEnd = getMillisToCompEnd() - 600000;
|
||||
if (regEnd > 0)
|
||||
{
|
||||
ThreadPool.schedule(() -> Announcements.getInstance().announceToAll(new SystemMessage(SystemMessageId.THE_GRAND_OLYMPIAD_REGISTRATION_PERIOD_HAS_ENDED)), regEnd);
|
||||
ThreadPool.schedule(() -> Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THE_GRAND_OLYMPIAD_REGISTRATION_PERIOD_HAS_ENDED)), regEnd);
|
||||
}
|
||||
|
||||
_scheduledCompEnd = ThreadPool.schedule(() ->
|
||||
@@ -810,7 +811,7 @@ public class Olympiad
|
||||
return;
|
||||
}
|
||||
_inCompPeriod = false;
|
||||
Announcements.getInstance().announceToAll(new SystemMessage(SystemMessageId.MUCH_CARNAGE_HAS_BEEN_LEFT_FOR_THE_CLEANUP_CREW_OF_THE_OLYMPIAD_STADIUM_BATTLES_IN_THE_GRAND_OLYMPIAD_GAMES_ARE_NOW_OVER));
|
||||
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.MUCH_CARNAGE_HAS_BEEN_LEFT_FOR_THE_CLEANUP_CREW_OF_THE_OLYMPIAD_STADIUM_BATTLES_IN_THE_GRAND_OLYMPIAD_GAMES_ARE_NOW_OVER));
|
||||
LOGGER.info("Olympiad System: Olympiad Game Ended");
|
||||
|
||||
while (OlympiadGame._battleStarted)
|
||||
@@ -871,7 +872,7 @@ public class Olympiad
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.PERIOD_S1_OF_THE_GRAND_OLYMPIAD_GAMES_HAS_STARTED);
|
||||
sm.addNumber(_currentCycle);
|
||||
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
|
||||
final Calendar currentTime = Calendar.getInstance();
|
||||
currentTime.add(Calendar.MONTH, 1);
|
||||
@@ -1622,7 +1623,7 @@ public class Olympiad
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.PERIOD_S1_OF_THE_GRAND_OLYMPIAD_GAMES_HAS_STARTED);
|
||||
sm.addNumber(_currentCycle);
|
||||
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
|
||||
final Calendar currentTime = Calendar.getInstance();
|
||||
currentTime.set(Calendar.AM_PM, Calendar.AM);
|
||||
|
@@ -29,7 +29,7 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||
import org.l2jmobius.gameserver.data.xml.ManorSeedData;
|
||||
@@ -332,7 +332,7 @@ public class Castle
|
||||
}
|
||||
}
|
||||
oldOwner.setHasCastle(0); // Unset has castle flag for old owner
|
||||
Announcements.getInstance().announceToAll(oldOwner.getName() + " has lost " + getName() + " castle!");
|
||||
AnnouncementsTable.getInstance().announceToAll(oldOwner.getName() + " has lost " + getName() + " castle!");
|
||||
|
||||
// remove crowns
|
||||
CrownManager.getInstance().checkCrowns(oldOwner);
|
||||
@@ -358,7 +358,7 @@ public class Castle
|
||||
|
||||
clan.setHasCastle(0);
|
||||
|
||||
Announcements.getInstance().announceToAll(clan.getName() + " has lost " + getName() + " castle");
|
||||
AnnouncementsTable.getInstance().announceToAll(clan.getName() + " has lost " + getName() + " castle");
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ public class Castle
|
||||
if (clan != null)
|
||||
{
|
||||
clan.setHasCastle(_castleId); // Set has castle flag for new owner
|
||||
Announcements.getInstance().announceToAll(clan.getName() + " has taken " + getName() + " castle!");
|
||||
AnnouncementsTable.getInstance().announceToAll(clan.getName() + " has taken " + getName() + " castle!");
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory"));
|
||||
// give crowns
|
||||
|
@@ -26,7 +26,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
@@ -193,7 +193,7 @@ public class Fort
|
||||
|
||||
// Unset has fort flag for old owner
|
||||
oldOwner.setHasFort(0);
|
||||
Announcements.getInstance().announceToAll(oldOwner.getName() + " has lost " + getName() + " fortress!");
|
||||
AnnouncementsTable.getInstance().announceToAll(oldOwner.getName() + " has lost " + getName() + " fortress!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class Fort
|
||||
{
|
||||
_formerOwner = clan;
|
||||
clan.setHasFort(0);
|
||||
Announcements.getInstance().announceToAll(clan.getName() + " has lost " + getName() + " fort");
|
||||
AnnouncementsTable.getInstance().announceToAll(clan.getName() + " has lost " + getName() + " fort");
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ public class Fort
|
||||
if (clan != null)
|
||||
{
|
||||
clan.setHasFort(_fortId); // Set has fort flag for new owner
|
||||
Announcements.getInstance().announceToAll(clan.getName() + " has taken " + getName() + " fort!");
|
||||
AnnouncementsTable.getInstance().announceToAll(clan.getName() + " has taken " + getName() + " fort!");
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory"));
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.enums.TeleportWhereType;
|
||||
@@ -50,6 +49,7 @@ import org.l2jmobius.gameserver.network.serverpackets.RelationChanged;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SiegeInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* The Class FortSiege.
|
||||
@@ -385,7 +385,7 @@ public class FortSiege
|
||||
}
|
||||
|
||||
sm.addString(getFort().getName());
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,6 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.ClanTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.enums.TeleportWhereType;
|
||||
@@ -58,6 +57,7 @@ import org.l2jmobius.gameserver.network.serverpackets.RelationChanged;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SiegeInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* The Class Siege.
|
||||
@@ -545,7 +545,7 @@ public class Siege
|
||||
}
|
||||
|
||||
sm.addString(getCastle().getName());
|
||||
Announcements.getInstance().announceToAll(sm);
|
||||
Broadcast.toAllOnlinePlayers(sm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||
@@ -239,7 +239,7 @@ public class DevastatedCastle
|
||||
|
||||
public void Announce(String message)
|
||||
{
|
||||
Announcements.getInstance().announceToAll(message);
|
||||
AnnouncementsTable.getInstance().announceToAll(message);
|
||||
}
|
||||
|
||||
protected class RunSiege implements Runnable
|
||||
|
@@ -30,7 +30,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||
@@ -282,7 +282,7 @@ public class FortressOfResistance
|
||||
|
||||
public void Announce(String message)
|
||||
{
|
||||
Announcements.getInstance().announceToAll(message);
|
||||
AnnouncementsTable.getInstance().announceToAll(message);
|
||||
}
|
||||
|
||||
public void CaptureFinish()
|
||||
|
@@ -36,7 +36,7 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.data.xml.MapRegionData;
|
||||
@@ -485,7 +485,7 @@ public class AutoSpawnHandler
|
||||
final String nearestTown = MapRegionData.getInstance().getClosestTownName(npcInst);
|
||||
if (spawnInst.isBroadcasting())
|
||||
{
|
||||
Announcements.getInstance().announceToAll("The " + npcInst.getName() + " has spawned near " + nearestTown + "!");
|
||||
AnnouncementsTable.getInstance().announceToAll("The " + npcInst.getName() + " has spawned near " + nearestTown + "!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,8 +29,8 @@ import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.gameserver.GameTimeController;
|
||||
import org.l2jmobius.gameserver.communitybbs.Manager.MailBBSManager;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.enums.TeleportWhereType;
|
||||
@@ -286,7 +286,7 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
player.sendPacket(SystemMessageId.WELCOME_TO_THE_WORLD_OF_LINEAGE_II);
|
||||
|
||||
SevenSigns.getInstance().sendCurrentPeriodMsg(player);
|
||||
Announcements.getInstance().showAnnouncements(player);
|
||||
AnnouncementsTable.getInstance().showAnnouncements(player);
|
||||
|
||||
if ((Config.SERVER_RESTART_SCHEDULE_ENABLED) && (Config.SERVER_RESTART_SCHEDULE_MESSAGE))
|
||||
{
|
||||
@@ -596,7 +596,7 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
|
||||
if (Config.SHOW_GM_LOGIN)
|
||||
{
|
||||
Announcements.getInstance().announceToAll("GM " + player.getName() + " has logged on.");
|
||||
AnnouncementsTable.getInstance().announceToAll("GM " + player.getName() + " has logged on.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -891,7 +891,7 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
final Castle castle = CastleManager.getInstance().getCastleById(clan.getCastleId());
|
||||
if ((castle != null) && (player.getObjectId() == clan.getLeaderId()))
|
||||
{
|
||||
Announcements.getInstance().announceToAll("Lord " + player.getName() + " Ruler Of " + castle.getName() + " Castle is now Online!");
|
||||
AnnouncementsTable.getInstance().announceToAll("Lord " + player.getName() + " Ruler Of " + castle.getName() + " Castle is now Online!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,14 +16,17 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.script.faenor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.model.DropCategory;
|
||||
import org.l2jmobius.gameserver.model.DropData;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
import org.l2jmobius.gameserver.model.announce.Announcement;
|
||||
import org.l2jmobius.gameserver.model.announce.AnnouncementType;
|
||||
import org.l2jmobius.gameserver.script.DateRange;
|
||||
import org.l2jmobius.gameserver.script.EngineInterface;
|
||||
import org.l2jmobius.gameserver.script.EventDroplist;
|
||||
@@ -141,7 +144,13 @@ public class FaenorInterface implements EngineInterface
|
||||
@Override
|
||||
public void onPlayerLogin(String[] message, DateRange validDateRange)
|
||||
{
|
||||
Announcements.getInstance().addEventAnnouncement(validDateRange, message);
|
||||
if (!validDateRange.isValid() || validDateRange.isWithinRange(new Date()))
|
||||
{
|
||||
for (String element : message)
|
||||
{
|
||||
AnnouncementsTable.getInstance().addAnnouncement(new Announcement(AnnouncementType.CRITICAL, element, ""), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
|
@@ -52,9 +52,9 @@ import org.l2jmobius.gameserver.GameTimeController;
|
||||
import org.l2jmobius.gameserver.LoginServerThread;
|
||||
import org.l2jmobius.gameserver.Shutdown;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.data.Announcements;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
|
||||
import org.l2jmobius.gameserver.data.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.data.sql.SpawnTable;
|
||||
import org.l2jmobius.gameserver.data.sql.TeleportLocationTable;
|
||||
@@ -311,7 +311,7 @@ public class GameStatusThread extends Thread
|
||||
try
|
||||
{
|
||||
usrCommand = usrCommand.substring(9);
|
||||
Announcements.getInstance().announceToAll(usrCommand);
|
||||
AnnouncementsTable.getInstance().announceToAll(usrCommand);
|
||||
_print.println("Announcement Sent!");
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
|
Reference in New Issue
Block a user