Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
- index 504e2f7..a55c67b 100644
- --- a/java/net/sf/l2j/Config.java
- +++ b/java/net/sf/l2j/Config.java
- @@ -282,6 +282,10 @@
- /** Misc */
- public static boolean ALLOW_CLASS_MASTERS;
- + public static boolean ENABLE_COMMAND_EPIC;
- + public static String RAID_BOSS_DATE_FORMAT;
- + public static String RAID_BOSS_IDS;
- + public static List<Integer> LIST_RAID_BOSS_IDS;
- public static ClassMasterSettings CLASS_MASTER_SETTINGS;
- public static boolean ALLOW_ENTIRE_TREE;
- public static boolean ANNOUNCE_MAMMON_SPAWN;
- @@ -1016,7 +1020,15 @@
- final ExProperties npcs = initProperties(NPCS_FILE);
- BUFFER_MAX_SCHEMES = npcs.getProperty("BufferMaxSchemesPerChar", 4);
- BUFFER_STATIC_BUFF_COST = npcs.getProperty("BufferStaticCostPerBuff", -1);
- + ENABLE_COMMAND_EPIC = npcs.getProperty("EnableCommandEpic", false);
- + RAID_BOSS_DATE_FORMAT = npcs.getProperty("RaidBossDateFormat", "MMM dd, HH:mm");
- + RAID_BOSS_IDS = npcs.getProperty("RaidBossIds", "0,0");
- + LIST_RAID_BOSS_IDS = new ArrayList<>();
- + for (String val : RAID_BOSS_IDS.split(","))
- + {
- + int npcId = Integer.parseInt(val);
- + LIST_RAID_BOSS_IDS.add(npcId);
- + }
- ALLOW_CLASS_MASTERS = npcs.getProperty("AllowClassMasters", false);
- ALLOW_ENTIRE_TREE = npcs.getProperty("AllowEntireTree", false);
- if (ALLOW_CLASS_MASTERS)
- diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
- index d82ef6c..70b72dd 100644
- --- a/java/net/sf/l2j/gameserver/GameServer.java
- +++ b/java/net/sf/l2j/gameserver/GameServer.java
- @@ -41,6 +41,7 @@
- import net.sf.l2j.gameserver.data.manager.PartyMatchRoomManager;
- import net.sf.l2j.gameserver.data.manager.PetitionManager;
- import net.sf.l2j.gameserver.data.manager.PremiumManager;
- +import net.sf.l2j.gameserver.data.manager.RaidBossInfoManager;
- import net.sf.l2j.gameserver.data.manager.RaidBossManager;
- import net.sf.l2j.gameserver.data.manager.RaidPointManager;
- import net.sf.l2j.gameserver.data.manager.SevenSignsManager;
- @@ -243,6 +244,7 @@
- SevenSignsSpawnManager.getInstance().notifyChangeMode();
- DayNightManager.getInstance().notifyChangeMode();
- DimensionalRiftManager.getInstance();
- + RaidBossInfoManager.getInstance();
- StringUtil.printSection("Olympiads & Heroes");
- OlympiadGameManager.getInstance();
- diff --git a/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java b/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java
- index d319a5e..260eeff 100644
- --- a/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java
- +++ b/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java
- @@ -10,6 +10,7 @@
- import net.sf.l2j.commons.pool.ConnectionPool;
- import net.sf.l2j.commons.util.StatsSet;
- +import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.data.xml.NpcData;
- import net.sf.l2j.gameserver.model.actor.instance.GrandBoss;
- @@ -106,7 +107,8 @@
- public void setStatsSet(int bossId, StatsSet info)
- {
- _storedInfo.put(bossId, info);
- + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
- + RaidBossInfoManager.getInstance().updateRaidBossInfo(bossId, info.getLong("respawn_time"));
- updateDb(bossId, false);
- }
- diff --git a/java/net/sf/l2j/gameserver/data/manager/RaidBossInfoManager.java b/java/net/sf/l2j/gameserver/data/manager/RaidBossInfoManager.java
- new file mode 100644
- index 0000000..c64acee
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/data/manager/RaidBossInfoManager.java
- @@ -0,0 +1,66 @@
- +package net.sf.l2j.gameserver.data.manager;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.Map;
- +import java.util.concurrent.ConcurrentHashMap;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.commons.pool.ConnectionPool;
- +
- +import net.sf.l2j.Config;
- +
- +public class RaidBossInfoManager
- +{
- + private static final Logger _log = Logger.getLogger(RaidBossInfoManager.class.getName());
- + private final Map<Integer, Long> _raidBosses;
- +
- + protected RaidBossInfoManager()
- + {
- + _raidBosses = new ConcurrentHashMap<>();
- + load();
- + }
- +
- + public void load()
- + {
- + try (Connection con = ConnectionPool.getConnection();
- + PreparedStatement statement = con.prepareStatement("SELECT boss_id, respawn_time FROM grandboss_data UNION SELECT boss_id, respawn_time FROM raidboss_spawnlist ORDER BY boss_id"))
- + {
- + try (ResultSet rs = statement.executeQuery())
- + {
- + while (rs.next())
- + {
- + int bossId = rs.getInt("boss_id");
- + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
- + _raidBosses.put(bossId, rs.getLong("respawn_time"));
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("Exception: RaidBossInfoManager load: " + e);
- + }
- + _log.info("RaidBossInfoManager: Loaded " + _raidBosses.size() + " instances.");
- + }
- +
- + public void updateRaidBossInfo(int bossId, long respawnTime)
- + {
- + _raidBosses.put(bossId, respawnTime);
- + }
- +
- + public long getRaidBossRespawnTime(int bossId)
- + {
- + return _raidBosses.get(bossId);
- + }
- +
- + public static RaidBossInfoManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final RaidBossInfoManager _instance = new RaidBossInfoManager();
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- index 3c0a026..7a3e893 100644
- --- a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- +++ b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- @@ -3,7 +3,9 @@
- import java.util.HashMap;
- import java.util.Map;
- +import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.handler.voicedcommandhandlers.ExpGain;
- +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.GrandBossStatus;
- import net.sf.l2j.gameserver.handler.voicedcommandhandlers.PremiumInfo;
- public class VoicedCommandHandler
- @@ -14,6 +16,11 @@
- {
- registerHandler(new PremiumInfo());
- registerHandler(new ExpGain());
- + if(Config.ENABLE_COMMAND_EPIC)
- + {
- + registerHandler(new GrandBossStatus());
- + }
- +
- }
- public void registerHandler(IVoicedCommandHandler handler)
- diff --git a/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/GrandBossStatus.java b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/GrandBossStatus.java
- new file mode 100644
- index 0000000..321a760
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/GrandBossStatus.java
- @@ -0,0 +1,115 @@
- +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
- +
- +import java.sql.Date;
- +import java.text.SimpleDateFormat;
- +import java.util.ArrayList;
- +import java.util.List;
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.manager.RaidBossInfoManager;
- +import net.sf.l2j.gameserver.data.xml.NpcData;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +public class GrandBossStatus implements IVoicedCommandHandler
- +{
- + private static final String[] _voicedCommands =
- + {
- + "epic"
- + };
- +
- + @Override
- + public boolean useVoicedCommand(String command, Player activeChar, String target)
- + {
- + if (command.startsWith("epic"))
- + {
- + showMainPage(activeChar);
- + }
- +
- + return true;
- + }
- +
- + public void showMainPage(Player player)
- + {
- + List<Integer> infos = new ArrayList<>();
- + infos.addAll(Config.LIST_RAID_BOSS_IDS);
- +
- + final StringBuilder sb = new StringBuilder();
- + sb.append("<html>");
- + sb.append("<center>");
- + sb.append("<body>");
- + sb.append("<table><tr>");
- + sb.append("<td width=32><img src=Icon.etc_alphabet_b_i00 height=32 width=32></td>");
- + sb.append("<td width=32><img src=Icon.etc_alphabet_o_i00 height=32 width=32></td>");
- + sb.append("<td width=32><img src=Icon.etc_alphabet_s_i00 height=32 width=32></td>");
- + sb.append("<td width=32><img src=Icon.etc_alphabet_s_i00 height=32 width=32></td>");
- + sb.append("</tr></table><br>");
- +
- + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
- + sb.append("<table bgcolor=\"000000\" width=\"318\">");
- + sb.append("<tr><td><center><font color=\"FF8C00\">Grand Boss Info</font></center></td></tr>");
- + sb.append("</table>");
- + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
- +
- + sb.append("<table bgcolor=\"000000\" width=\"318\">");
- +
- + for (int bossId : infos)
- + {
- + final NpcTemplate template = NpcData.getInstance().getTemplate(bossId);
- + if (template == null)
- + continue;
- +
- + String bossName = template.getName();
- + if (bossName.length() > 23)
- + bossName = bossName.substring(0, 23) + "...";
- +
- + final long respawnTime = RaidBossInfoManager.getInstance().getRaidBossRespawnTime(bossId);
- + if (respawnTime <= System.currentTimeMillis())
- + {
- + sb.append("<tr>");
- + sb.append("<td><a action=\"" + bossId + "\">" + bossName + "</a></td>");
- + sb.append("<td><font color=\"9CC300\">Alive</font></td>");
- + sb.append("</tr>");
- + }
- + else
- + {
- + sb.append("<tr>");
- + sb.append("<td width=\"159\" align=\"left\"><a action=\"" + bossId + "\">" + bossName + "</a></td>");
- + sb.append("<td width=\"159\" align=\"left\"><font color=\"FB5858\">Dead</font> " + new SimpleDateFormat(Config.RAID_BOSS_DATE_FORMAT).format(new Date(respawnTime)) + "</td>");
- + sb.append("</tr>");
- + }
- + }
- + sb.append("</table>");
- +
- + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
- +
- + sb.append("<table width=\"300\" cellspacing=\"2\">");
- + sb.append("<tr>");
- +
- + sb.append("</tr>");
- + sb.append("</table>");
- +
- + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
- +
- + sb.append("<table bgcolor=\"000000\" width=\"350\">");
- + //sb.append("<tr><td><center><a action=\"bypass returnboss\">Return</a></center></td></tr>");
- + sb.append("</table>");
- + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
- +
- +
- + sb.append("</center>");
- + sb.append("</body>");
- + sb.append("</html>");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(5);
- + msg.setHtml(sb.toString());
- + player.sendPacket(msg);
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- + return _voicedCommands;
- + }
- +}
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java b/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java
- index bbedd70..772e199 100644
- --- a/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java
- +++ b/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java
- @@ -10,6 +10,8 @@
- import net.sf.l2j.commons.pool.ThreadPool;
- import net.sf.l2j.commons.random.Rnd;
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.manager.RaidBossInfoManager;
- import net.sf.l2j.gameserver.enums.BossStatus;
- import net.sf.l2j.gameserver.model.actor.Npc;
- @@ -145,6 +147,8 @@
- // Refresh the database for this particular boss entry.
- updateOnDb();
- + if (Config.LIST_RAID_BOSS_IDS.contains(_spawn.getNpcId()))
- + RaidBossInfoManager.getInstance().updateRaidBossInfo(_spawn.getNpcId(), respawnTime);
- LOGGER.info("Raid boss: {} - {} ({}h).", _spawn.getNpc().getName(), new SimpleDateFormat("dd-MM-yyyy HH:mm").format(respawnTime), respawnDelay);
- }
- @@ -173,7 +177,8 @@
- // Refresh the database for this particular boss entry.
- updateOnDb();
- + if (Config.LIST_RAID_BOSS_IDS.contains(npc.getNpcId()))
- + RaidBossInfoManager.getInstance().updateRaidBossInfo(npc.getNpcId(), 0);
- LOGGER.info("{} raid boss has spawned.", npc.getName());
- }
- index : gameserver\config\npcs.properties
- #=============================================================
- # Misc
- #=============================================================
- # Allow the use of class Managers to change occupation
- # Default = False
- AllowClassMasters = False
- +EnableCommandEpic = True
- +RaidBossIds = 25325,29001,29006,29014,29019,29028,29047,29022
- +# Displayed date format for dead raid boss
- +# Default: (MMM dd, HH:mm)
- +RaidBossDateFormat = (MMM dd, HH:mm)
Advertisement
Comments
-
- Gracias tratarde adaptarlo en acis 401. Saludos.
Add Comment
Please, Sign In to add comment
Advertisement