From e43087f9cd095807f0401882b12c1bf4fbb82b4c Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sat, 24 Apr 2021 12:49:26 +0000 Subject: [PATCH] Moved announcements to SQL. --- .../db_installer/sql/game/announcements.sql | 14 + .../sql/game/auto_announcements.sql | 9 - .../dist/game/data/announcements.txt | 2 - .../dist/game/data/html/admin/announce.htm | 7 +- .../game/data/html/admin/announce_auto.htm | 19 + .../game/data/scripts/ai/bosses/Baium.java | 10 +- .../game/data/scripts/ai/bosses/Core.java | 8 +- .../game/data/scripts/ai/bosses/Orfen.java | 10 +- .../game/data/scripts/ai/bosses/QueenAnt.java | 10 +- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../org/l2jmobius/gameserver/Shutdown.java | 11 +- .../gameserver/data/Announcements.java | 278 ----------- .../data/sql/AnnouncementsTable.java | 205 ++++++++ .../handler/AutoAnnouncementHandler.java | 448 ------------------ .../AdminAnnouncements.java | 90 +++- .../admincommandhandlers/AdminTownWar.java | 14 +- .../instancemanager/ChristmasManager.java | 8 +- .../instancemanager/RaidBossSpawnManager.java | 4 +- .../instancemanager/events/CTF.java | 74 +-- .../gameserver/instancemanager/events/DM.java | 54 +-- .../instancemanager/events/TvT.java | 62 +-- .../instancemanager/events/VIP.java | 24 +- .../instancemanager/games/Lottery.java | 11 +- .../model/actor/instance/PlayerInstance.java | 18 +- .../instance/WeddingManagerInstance.java | 4 +- .../model/announce/Announcement.java | 170 +++++++ .../model/announce/AnnouncementType.java | 59 +++ .../model/announce/AutoAnnouncement.java | 194 ++++++++ .../model/announce/IAnnouncement.java | 43 ++ .../model/interfaces/IUpdatable.java | 25 + .../gameserver/model/olympiad/Olympiad.java | 19 +- .../gameserver/model/siege/Castle.java | 8 +- .../gameserver/model/siege/Fort.java | 8 +- .../gameserver/model/siege/FortSiege.java | 4 +- .../gameserver/model/siege/Siege.java | 4 +- .../siege/clanhalls/DevastatedCastle.java | 4 +- .../siege/clanhalls/FortressOfResistance.java | 4 +- .../model/spawn/AutoSpawnHandler.java | 4 +- .../network/clientpackets/EnterWorld.java | 8 +- .../script/faenor/FaenorInterface.java | 13 +- .../l2jmobius/telnet/GameStatusThread.java | 4 +- .../db_installer/sql/game/announcements.sql | 14 + .../sql/game/auto_announcements.sql | 9 - .../dist/game/data/announcements.txt | 2 - .../dist/game/data/html/admin/announce.htm | 7 +- .../game/data/html/admin/announce_auto.htm | 19 + .../game/data/scripts/ai/bosses/Baium.java | 10 +- .../game/data/scripts/ai/bosses/Core.java | 8 +- .../game/data/scripts/ai/bosses/Orfen.java | 10 +- .../game/data/scripts/ai/bosses/QueenAnt.java | 10 +- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../org/l2jmobius/gameserver/Shutdown.java | 11 +- .../gameserver/data/Announcements.java | 278 ----------- .../data/sql/AnnouncementsTable.java | 205 ++++++++ .../handler/AutoAnnouncementHandler.java | 448 ------------------ .../AdminAnnouncements.java | 90 +++- .../admincommandhandlers/AdminTownWar.java | 14 +- .../instancemanager/ChristmasManager.java | 8 +- .../instancemanager/RaidBossSpawnManager.java | 4 +- .../instancemanager/events/CTF.java | 74 +-- .../gameserver/instancemanager/events/DM.java | 54 +-- .../instancemanager/events/TvT.java | 62 +-- .../instancemanager/events/VIP.java | 24 +- .../instancemanager/games/Lottery.java | 11 +- .../model/actor/instance/PlayerInstance.java | 18 +- .../instance/WeddingManagerInstance.java | 4 +- .../model/announce/Announcement.java | 170 +++++++ .../model/announce/AnnouncementType.java | 59 +++ .../model/announce/AutoAnnouncement.java | 194 ++++++++ .../model/announce/IAnnouncement.java | 43 ++ .../model/interfaces/IUpdatable.java | 25 + .../gameserver/model/olympiad/Olympiad.java | 19 +- .../gameserver/model/siege/Castle.java | 8 +- .../gameserver/model/siege/Fort.java | 8 +- .../gameserver/model/siege/FortSiege.java | 4 +- .../gameserver/model/siege/Siege.java | 4 +- .../siege/clanhalls/DevastatedCastle.java | 4 +- .../siege/clanhalls/FortressOfResistance.java | 4 +- .../model/spawn/AutoSpawnHandler.java | 4 +- .../network/clientpackets/EnterWorld.java | 8 +- .../script/faenor/FaenorInterface.java | 13 +- .../l2jmobius/telnet/GameStatusThread.java | 4 +- 82 files changed, 2014 insertions(+), 1928 deletions(-) create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/announcements.sql delete mode 100644 L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/auto_announcements.sql delete mode 100644 L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/announcements.txt create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce_auto.htm delete mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/Announcements.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java delete mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/Announcement.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java create mode 100644 L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/announcements.sql delete mode 100644 L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/auto_announcements.sql delete mode 100644 L2J_Mobius_C6_Interlude/dist/game/data/announcements.txt create mode 100644 L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce_auto.htm delete mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/Announcements.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java delete mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/Announcement.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/announcements.sql b/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/announcements.sql new file mode 100644 index 0000000000..686ce7db92 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/announcements.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS `announcements` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `type` int(11) NOT NULL, + `initial` bigint(20) NOT NULL DEFAULT 0, + `delay` bigint(20) NOT NULL DEFAULT 0, + `repeat` int(11) NOT NULL DEFAULT 0, + `author` text NOT NULL, + `content` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +INSERT INTO announcements (`type`, `author`, `content`) VALUES +(0, 'L2jMobius', 'Thanks for using L2jMobius!'), +(0, 'L2jMobius', 'http://www.l2jmobius.org'); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/auto_announcements.sql b/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/auto_announcements.sql deleted file mode 100644 index 9316b7f4d2..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/auto_announcements.sql +++ /dev/null @@ -1,9 +0,0 @@ --- -------------------------------------- --- Table structure for auto_announcements --- -------------------------------------- -CREATE TABLE IF NOT EXISTS `auto_announcements` ( - `id` int(11) NOT NULL auto_increment, - `announcement` varchar(255) NOT NULL, - `delay` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/announcements.txt b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/announcements.txt deleted file mode 100644 index 69e914d5bc..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/announcements.txt +++ /dev/null @@ -1,2 +0,0 @@ -Thanks for using L2jMobius! -http://www.l2jmobius.org \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce.htm b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce.htm index 59e52323c3..ce5c542d7c 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce.htm +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce.htm @@ -7,12 +7,9 @@
Write the message of the announcement.

- - - - - + +
%announces% diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce_auto.htm b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce_auto.htm new file mode 100644 index 0000000000..7454c0c0f0 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/html/admin/announce_auto.htm @@ -0,0 +1,19 @@ + + + + + +
Auto Announcements Menu


+
Write the message of the announcement.
+


+Delay (in seconds)
+Minimum time is 30 seconds. +

+ + + + + +
+%announces% + \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Baium.java b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Baium.java index 885743f647..58dbb49e28 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Baium.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Baium.java @@ -29,8 +29,8 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.data.Announcements; import org.l2jmobius.gameserver.data.SkillTable; +import org.l2jmobius.gameserver.data.sql.AnnouncementsTable; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.instancemanager.GrandBossManager; import org.l2jmobius.gameserver.model.Effect; @@ -130,7 +130,7 @@ public class Baium extends Quest addSpawn(STONE_BAIUM, 116033, 17447, 10104, 40188, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); } GrandBossManager.getInstance().setBossStatus(LIVE_BAIUM, ASLEEP); } @@ -146,7 +146,7 @@ public class Baium extends Quest final GrandBossInstance baium = (GrandBossInstance) addSpawn(LIVE_BAIUM, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + baium.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + baium.getName() + " spawned in world."); } GrandBossManager.getInstance().addBoss(baium); ThreadPool.schedule(() -> @@ -170,7 +170,7 @@ public class Baium extends Quest addSpawn(STONE_BAIUM, 116033, 17447, 10104, 40188, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); } } } @@ -184,7 +184,7 @@ public class Baium extends Quest addSpawn(STONE_BAIUM, 116033, 17447, 10104, 40188, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); } } else if (event.equals("skill_range") && (npc != null)) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Core.java b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Core.java index 7f576994f5..7a40930c1f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Core.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Core.java @@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; 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.enums.ChatType; import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager; import org.l2jmobius.gameserver.instancemanager.GrandBossManager; @@ -118,7 +118,7 @@ public class Core extends Quest final GrandBossInstance core = (GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(CORE, ALIVE); spawnBoss(core); @@ -133,7 +133,7 @@ public class Core extends Quest final GrandBossInstance core = (GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); } spawnBoss(core); } @@ -169,7 +169,7 @@ public class Core extends Quest final GrandBossInstance core = (GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(CORE, ALIVE); spawnBoss(core); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Orfen.java b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Orfen.java index 59720810f4..6192e06573 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Orfen.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/Orfen.java @@ -20,8 +20,8 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; 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.GrandBossManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance; @@ -76,7 +76,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, 55024, 17368, -5412, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(ORFEN, LIVE); GrandBossManager.getInstance().addBoss(_orfen); @@ -97,7 +97,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().addBoss(_orfen); _orfen.setCurrentHpMp(hp, mp); @@ -112,7 +112,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(ORFEN, LIVE); GrandBossManager.getInstance().addBoss(_orfen); @@ -137,7 +137,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(ORFEN, LIVE); GrandBossManager.getInstance().addBoss(_orfen); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/QueenAnt.java b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/QueenAnt.java index 13d1fd05ee..8a8aa3d7ee 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/QueenAnt.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/data/scripts/ai/bosses/QueenAnt.java @@ -23,8 +23,8 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; 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.GrandBossManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Attackable; @@ -109,7 +109,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(QUEEN, LIVE); GrandBossManager.getInstance().addBoss(queen); @@ -127,7 +127,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().addBoss(queen); queen.setCurrentHpMp(hp, mp); @@ -139,7 +139,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(QUEEN, LIVE); GrandBossManager.getInstance().addBoss(queen); @@ -175,7 +175,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(QUEEN, LIVE); GrandBossManager.getInstance().addBoss(queen); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java index e460d45244..44a47f0582 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java @@ -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; @@ -71,7 +71,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; @@ -193,8 +192,7 @@ public class GameServer Util.printSection("World"); World.getInstance(); MapRegionData.getInstance(); - Announcements.getInstance(); - AutoAnnouncementHandler.getInstance(); + AnnouncementsTable.getInstance(); GlobalVariablesManager.getInstance(); StaticObjectData.getInstance(); TeleportLocationTable.getInstance(); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/Shutdown.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/Shutdown.java index 064685d929..3477d8890a 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/Shutdown.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/Shutdown.java @@ -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.GlobalVariablesManager; import org.l2jmobius.gameserver.instancemanager.GrandBossManager; @@ -43,6 +43,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.
@@ -172,7 +173,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!"); @@ -217,7 +218,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!"); @@ -267,7 +268,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 @@ -379,7 +380,7 @@ public class Shutdown extends Thread */ private synchronized void saveData() { - final Announcements _an = Announcements.getInstance(); + final AnnouncementsTable _an = AnnouncementsTable.getInstance(); switch (_shutdownMode) { case SIGTERM: diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/Announcements.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/Announcements.java deleted file mode 100644 index 671a4548ac..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/Announcements.java +++ /dev/null @@ -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 . - */ -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 _announcements = new ArrayList<>(); - private final List> _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 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 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("
"); - for (int i = 0; i < _announcements.size(); i++) - { - replyMSG.append("
" + _announcements.get(i) + ""); - replyMSG.append("
"); - } - - 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(); - } -} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java new file mode 100644 index 0000000000..de387a0490 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java @@ -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 . + */ +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 _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 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(); + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java deleted file mode 100644 index 543c86b3d8..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java +++ /dev/null @@ -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 . - */ -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 _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(""); - replyMSG.append(""); - replyMSG.append(""); - replyMSG.append(""); - replyMSG.append(""); - replyMSG.append("
Auto Announcement Menu
"); - replyMSG.append("

"); - replyMSG.append("
Add new auto announcement:
"); - replyMSG.append("

"); - replyMSG.append("

"); - replyMSG.append("
Delay:
"); - replyMSG.append("
Note: Time in Seconds 60s = 1 min.
"); - replyMSG.append("
Note2: Minimum Time is 30 Seconds.
"); - replyMSG.append("

"); - replyMSG.append("
"); - replyMSG.append(""); - replyMSG.append("
"); - replyMSG.append("
"); - - for (AutoAnnouncementInstance announcementInst : getInstance().values()) - { - replyMSG.append("
[" + announcementInst.getDefaultDelay() + "s] " + announcementInst.getDefaultTexts() + ""); - replyMSG.append("
"); - } - - replyMSG.append(""); - - adminReply.setHtml(replyMSG.toString()); - player.sendPacket(adminReply); - } - - /** - * @return - */ - public int size() - { - return _registeredAnnouncements.size(); - } - - /** - * Registers a globally active autoannouncement.
- * 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
- * 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 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
- *
- * 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(); - } -} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java index d3246ae305..86d99ba6af 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java @@ -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 (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 (Seconds > 30) "); @@ -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("
"); + for (Entry entry : AnnouncementsTable.getInstance().getAllAnnouncements().entrySet()) + { + final IAnnouncement announcement = entry.getValue(); + if ((announcement.getType() == AnnouncementType.CRITICAL) || (announcement.getType() == AnnouncementType.NORMAL)) + { + replyMSG.append("
[" + entry.getKey() + "] " + announcement.getContent() + ""); + replyMSG.append("
"); + } + } + 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("
"); + for (Entry entry : AnnouncementsTable.getInstance().getAllAnnouncements().entrySet()) + { + final IAnnouncement announcement = entry.getValue(); + if ((announcement.getType() == AnnouncementType.AUTO_CRITICAL) || (announcement.getType() == AnnouncementType.AUTO_NORMAL)) + { + replyMSG.append("
[" + entry.getKey() + " (" + ((AutoAnnouncement) announcement).getDelay() + ")] " + announcement.getContent() + ""); + replyMSG.append("
"); + } + } + adminReply.replace("%announces%", replyMSG.toString()); + player.sendPacket(adminReply); + } + @Override public String[] getAdminCommandList() { diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java index 9aae76e00f..7218491cea 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java @@ -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() + "."); } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java index eea4631c14..27525fa456 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java @@ -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; } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java index 181458f7e8..ebaff1dd67 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java @@ -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); } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java index fe9b75633a..33e84d5e53 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java @@ -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; } @@ -2585,7 +2585,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."); } } @@ -2760,13 +2760,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; @@ -2792,7 +2792,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: @@ -2802,13 +2802,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; @@ -3086,7 +3086,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 @@ -3101,7 +3101,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; } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/DM.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/DM.java index 77d91bbbf5..54d50bb64f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/DM.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/DM.java @@ -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; } @@ -2002,7 +2002,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!"); } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java index 063b1ce14c..386b3859a0 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java @@ -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; } @@ -2473,7 +2473,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."); } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java index 38a470651f..0f38f23764 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java @@ -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) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java index d712958801..2e020462c9 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java @@ -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()) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index d36f770b5a..7d300c305f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -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; @@ -5828,7 +5828,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); } @@ -5940,7 +5940,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."); } /** @@ -6126,11 +6126,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; @@ -6148,7 +6148,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 @@ -6156,14 +6156,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()) @@ -6344,7 +6344,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) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java index 77597bcd9e..9729ace096 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java @@ -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"; diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/Announcement.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/Announcement.java new file mode 100644 index 0000000000..c43a146632 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/Announcement.java @@ -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 . + */ +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; + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java new file mode 100644 index 0000000000..481612cd09 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java @@ -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 . + */ +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; + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java new file mode 100644 index 0000000000..4e448b7644 --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java new file mode 100644 index 0000000000..a822e77a7b --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java @@ -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 . + */ +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); +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java new file mode 100644 index 0000000000..569d104e1f --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java @@ -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 . + */ +package org.l2jmobius.gameserver.model.interfaces; + +/** + * @author UnAfraid + */ +public interface IUpdatable +{ + boolean updateMe(); +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java index 3434a8ec5d..63a3bc38e5 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java @@ -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(); @@ -783,7 +784,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); @@ -792,7 +793,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(() -> @@ -802,7 +803,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) @@ -863,7 +864,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); @@ -1614,7 +1615,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); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Castle.java index 7ea7a109fc..5d9bbf6dcd 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -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 diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Fort.java index 347d0fb331..3868536075 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -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")); } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/FortSiege.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/FortSiege.java index 53b01761fa..72f7079c7f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/FortSiege.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/FortSiege.java @@ -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; } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Siege.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Siege.java index 99dd4dc1d1..0ea9311e9d 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Siege.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/Siege.java @@ -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; } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java index 5231a5534c..ed17a8af47 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java @@ -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 diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java index 0ee1571fdd..a818176c97 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java @@ -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() diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java index 5e568900bb..56f3f76662 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java @@ -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 + "!"); } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 8c6ab2a8af..ab45b90ea7 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -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; @@ -263,7 +263,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)) { @@ -559,7 +559,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."); } } } @@ -833,7 +833,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!"); } } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java index 4a29fc5888..d748c8bef8 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java @@ -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 diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/telnet/GameStatusThread.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/telnet/GameStatusThread.java index 539ad5e065..75bb91daf5 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/telnet/GameStatusThread.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/telnet/GameStatusThread.java @@ -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) diff --git a/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/announcements.sql b/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/announcements.sql new file mode 100644 index 0000000000..686ce7db92 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/announcements.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS `announcements` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `type` int(11) NOT NULL, + `initial` bigint(20) NOT NULL DEFAULT 0, + `delay` bigint(20) NOT NULL DEFAULT 0, + `repeat` int(11) NOT NULL DEFAULT 0, + `author` text NOT NULL, + `content` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +INSERT INTO announcements (`type`, `author`, `content`) VALUES +(0, 'L2jMobius', 'Thanks for using L2jMobius!'), +(0, 'L2jMobius', 'http://www.l2jmobius.org'); diff --git a/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/auto_announcements.sql b/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/auto_announcements.sql deleted file mode 100644 index 9316b7f4d2..0000000000 --- a/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/auto_announcements.sql +++ /dev/null @@ -1,9 +0,0 @@ --- -------------------------------------- --- Table structure for auto_announcements --- -------------------------------------- -CREATE TABLE IF NOT EXISTS `auto_announcements` ( - `id` int(11) NOT NULL auto_increment, - `announcement` varchar(255) NOT NULL, - `delay` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/announcements.txt b/L2J_Mobius_C6_Interlude/dist/game/data/announcements.txt deleted file mode 100644 index 69e914d5bc..0000000000 --- a/L2J_Mobius_C6_Interlude/dist/game/data/announcements.txt +++ /dev/null @@ -1,2 +0,0 @@ -Thanks for using L2jMobius! -http://www.l2jmobius.org \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce.htm b/L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce.htm index 59e52323c3..ce5c542d7c 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce.htm +++ b/L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce.htm @@ -7,12 +7,9 @@
Write the message of the announcement.

- - - - - + +
%announces% diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce_auto.htm b/L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce_auto.htm new file mode 100644 index 0000000000..ebab7fa031 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/dist/game/data/html/admin/announce_auto.htm @@ -0,0 +1,19 @@ + + + + + +
Auto Announcements Menu


+
Write the message of the announcement.
+


+Delay (in seconds)
+Minimum time is 30 seconds. +

+ + + + + +
+%announces% + \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Baium.java b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Baium.java index 885743f647..58dbb49e28 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Baium.java +++ b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Baium.java @@ -29,8 +29,8 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.data.Announcements; import org.l2jmobius.gameserver.data.SkillTable; +import org.l2jmobius.gameserver.data.sql.AnnouncementsTable; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.instancemanager.GrandBossManager; import org.l2jmobius.gameserver.model.Effect; @@ -130,7 +130,7 @@ public class Baium extends Quest addSpawn(STONE_BAIUM, 116033, 17447, 10104, 40188, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); } GrandBossManager.getInstance().setBossStatus(LIVE_BAIUM, ASLEEP); } @@ -146,7 +146,7 @@ public class Baium extends Quest final GrandBossInstance baium = (GrandBossInstance) addSpawn(LIVE_BAIUM, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + baium.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + baium.getName() + " spawned in world."); } GrandBossManager.getInstance().addBoss(baium); ThreadPool.schedule(() -> @@ -170,7 +170,7 @@ public class Baium extends Quest addSpawn(STONE_BAIUM, 116033, 17447, 10104, 40188, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); } } } @@ -184,7 +184,7 @@ public class Baium extends Quest addSpawn(STONE_BAIUM, 116033, 17447, 10104, 40188, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss Baium Stone spawned in world."); } } else if (event.equals("skill_range") && (npc != null)) diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Core.java b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Core.java index 7f576994f5..7a40930c1f 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Core.java +++ b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Core.java @@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; 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.enums.ChatType; import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager; import org.l2jmobius.gameserver.instancemanager.GrandBossManager; @@ -118,7 +118,7 @@ public class Core extends Quest final GrandBossInstance core = (GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(CORE, ALIVE); spawnBoss(core); @@ -133,7 +133,7 @@ public class Core extends Quest final GrandBossInstance core = (GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); } spawnBoss(core); } @@ -169,7 +169,7 @@ public class Core extends Quest final GrandBossInstance core = (GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + core.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(CORE, ALIVE); spawnBoss(core); diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Orfen.java b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Orfen.java index 59720810f4..6192e06573 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Orfen.java +++ b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/Orfen.java @@ -20,8 +20,8 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; 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.GrandBossManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance; @@ -76,7 +76,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, 55024, 17368, -5412, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(ORFEN, LIVE); GrandBossManager.getInstance().addBoss(_orfen); @@ -97,7 +97,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().addBoss(_orfen); _orfen.setCurrentHpMp(hp, mp); @@ -112,7 +112,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(ORFEN, LIVE); GrandBossManager.getInstance().addBoss(_orfen); @@ -137,7 +137,7 @@ public class Orfen extends Quest _orfen = (GrandBossInstance) addSpawn(ORFEN, loc_x, loc_y, loc_z, heading, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + _orfen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(ORFEN, LIVE); GrandBossManager.getInstance().addBoss(_orfen); diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/QueenAnt.java b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/QueenAnt.java index 13d1fd05ee..8a8aa3d7ee 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/QueenAnt.java +++ b/L2J_Mobius_C6_Interlude/dist/game/data/scripts/ai/bosses/QueenAnt.java @@ -23,8 +23,8 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; 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.GrandBossManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Attackable; @@ -109,7 +109,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(QUEEN, LIVE); GrandBossManager.getInstance().addBoss(queen); @@ -127,7 +127,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().addBoss(queen); queen.setCurrentHpMp(hp, mp); @@ -139,7 +139,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(QUEEN, LIVE); GrandBossManager.getInstance().addBoss(queen); @@ -175,7 +175,7 @@ public class QueenAnt extends Quest final GrandBossInstance queen = (GrandBossInstance) addSpawn(QUEEN, -21610, 181594, -5734, 0, false, 0); if (Config.ANNOUNCE_TO_ALL_SPAWN_RB) { - Announcements.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); + AnnouncementsTable.getInstance().announceToAll("Raid boss " + queen.getName() + " spawned in world."); } GrandBossManager.getInstance().setBossStatus(QUEEN, LIVE); GrandBossManager.getInstance().addBoss(queen); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java index 250a1a79f5..f4d7addbc2 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java @@ -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(); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/Shutdown.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/Shutdown.java index 00fdc3f22d..b939f85939 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/Shutdown.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/Shutdown.java @@ -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.
@@ -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: diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/Announcements.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/Announcements.java deleted file mode 100644 index 671a4548ac..0000000000 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/Announcements.java +++ /dev/null @@ -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 . - */ -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 _announcements = new ArrayList<>(); - private final List> _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 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 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("
"); - for (int i = 0; i < _announcements.size(); i++) - { - replyMSG.append("
" + _announcements.get(i) + ""); - replyMSG.append("
"); - } - - 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(); - } -} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java new file mode 100644 index 0000000000..de387a0490 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/data/sql/AnnouncementsTable.java @@ -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 . + */ +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 _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 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(); + } +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java deleted file mode 100644 index 543c86b3d8..0000000000 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AutoAnnouncementHandler.java +++ /dev/null @@ -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 . - */ -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 _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(""); - replyMSG.append(""); - replyMSG.append(""); - replyMSG.append(""); - replyMSG.append(""); - replyMSG.append("
Auto Announcement Menu
"); - replyMSG.append("

"); - replyMSG.append("
Add new auto announcement:
"); - replyMSG.append("

"); - replyMSG.append("

"); - replyMSG.append("
Delay:
"); - replyMSG.append("
Note: Time in Seconds 60s = 1 min.
"); - replyMSG.append("
Note2: Minimum Time is 30 Seconds.
"); - replyMSG.append("

"); - replyMSG.append("
"); - replyMSG.append(""); - replyMSG.append("
"); - replyMSG.append("
"); - - for (AutoAnnouncementInstance announcementInst : getInstance().values()) - { - replyMSG.append("
[" + announcementInst.getDefaultDelay() + "s] " + announcementInst.getDefaultTexts() + ""); - replyMSG.append("
"); - } - - replyMSG.append(""); - - adminReply.setHtml(replyMSG.toString()); - player.sendPacket(adminReply); - } - - /** - * @return - */ - public int size() - { - return _registeredAnnouncements.size(); - } - - /** - * Registers a globally active autoannouncement.
- * 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
- * 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 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
- *
- * 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(); - } -} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java index d3246ae305..86d99ba6af 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminAnnouncements.java @@ -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 (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 (Seconds > 30) "); @@ -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("
"); + for (Entry entry : AnnouncementsTable.getInstance().getAllAnnouncements().entrySet()) + { + final IAnnouncement announcement = entry.getValue(); + if ((announcement.getType() == AnnouncementType.CRITICAL) || (announcement.getType() == AnnouncementType.NORMAL)) + { + replyMSG.append("
[" + entry.getKey() + "] " + announcement.getContent() + ""); + replyMSG.append("
"); + } + } + 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("
"); + for (Entry entry : AnnouncementsTable.getInstance().getAllAnnouncements().entrySet()) + { + final IAnnouncement announcement = entry.getValue(); + if ((announcement.getType() == AnnouncementType.AUTO_CRITICAL) || (announcement.getType() == AnnouncementType.AUTO_NORMAL)) + { + replyMSG.append("
[" + entry.getKey() + " (" + ((AutoAnnouncement) announcement).getDelay() + ")] " + announcement.getContent() + ""); + replyMSG.append("
"); + } + } + adminReply.replace("%announces%", replyMSG.toString()); + player.sendPacket(adminReply); + } + @Override public String[] getAdminCommandList() { diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java index 9aae76e00f..7218491cea 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTownWar.java @@ -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() + "."); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java index eea4631c14..27525fa456 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/ChristmasManager.java @@ -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; } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java index 181458f7e8..ebaff1dd67 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/RaidBossSpawnManager.java @@ -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); } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java index 4e65aaa2f8..e18f541ff1 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/CTF.java @@ -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; } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/DM.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/DM.java index cd3fc27ec3..e9f9d1c456 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/DM.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/DM.java @@ -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!"); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java index 8a90500b17..02b8708b57 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java @@ -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."); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java index 38a470651f..0f38f23764 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/VIP.java @@ -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) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java index d712958801..2e020462c9 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/games/Lottery.java @@ -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()) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 4fd309f2e1..16fbf4fe60 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -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) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java index 77597bcd9e..9729ace096 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/WeddingManagerInstance.java @@ -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"; diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/Announcement.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/Announcement.java new file mode 100644 index 0000000000..c43a146632 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/Announcement.java @@ -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 . + */ +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; + } +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java new file mode 100644 index 0000000000..481612cd09 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AnnouncementType.java @@ -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 . + */ +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; + } +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java new file mode 100644 index 0000000000..4e448b7644 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/AutoAnnouncement.java @@ -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 . + */ +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); + } +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java new file mode 100644 index 0000000000..a822e77a7b --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/announce/IAnnouncement.java @@ -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 . + */ +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); +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java new file mode 100644 index 0000000000..569d104e1f --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/interfaces/IUpdatable.java @@ -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 . + */ +package org.l2jmobius.gameserver.model.interfaces; + +/** + * @author UnAfraid + */ +public interface IUpdatable +{ + boolean updateMe(); +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java index 30542c120e..de3e17e4c5 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java @@ -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); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java index 7ea7a109fc..5d9bbf6dcd 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Castle.java @@ -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 diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java index 347d0fb331..3868536075 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Fort.java @@ -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")); } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/FortSiege.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/FortSiege.java index 53b01761fa..72f7079c7f 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/FortSiege.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/FortSiege.java @@ -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; } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Siege.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Siege.java index 99dd4dc1d1..0ea9311e9d 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Siege.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/Siege.java @@ -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; } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java index 5231a5534c..ed17a8af47 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/DevastatedCastle.java @@ -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 diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java index 0ee1571fdd..a818176c97 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/siege/clanhalls/FortressOfResistance.java @@ -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() diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java index 5e568900bb..56f3f76662 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/AutoSpawnHandler.java @@ -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 + "!"); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index ebdce68807..d2d2806f70 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -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!"); } } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java index 4a29fc5888..d748c8bef8 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/script/faenor/FaenorInterface.java @@ -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 diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/telnet/GameStatusThread.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/telnet/GameStatusThread.java index 539ad5e065..75bb91daf5 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/telnet/GameStatusThread.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/telnet/GameStatusThread.java @@ -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)