Advertisement
Sarada-L2

.epic pra Nova Acis, RusAcis

Oct 2nd, 2021
1,386
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.19 KB | None | 1 0
  1. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  2. index 504e2f7..a55c67b 100644
  3. --- a/java/net/sf/l2j/Config.java
  4. +++ b/java/net/sf/l2j/Config.java
  5. @@ -282,6 +282,10 @@
  6.  
  7. /** Misc */
  8. public static boolean ALLOW_CLASS_MASTERS;
  9. + public static boolean ENABLE_COMMAND_EPIC;
  10. + public static String RAID_BOSS_DATE_FORMAT;
  11. + public static String RAID_BOSS_IDS;
  12. + public static List<Integer> LIST_RAID_BOSS_IDS;
  13. public static ClassMasterSettings CLASS_MASTER_SETTINGS;
  14. public static boolean ALLOW_ENTIRE_TREE;
  15. public static boolean ANNOUNCE_MAMMON_SPAWN;
  16. @@ -1016,7 +1020,15 @@
  17. final ExProperties npcs = initProperties(NPCS_FILE);
  18. BUFFER_MAX_SCHEMES = npcs.getProperty("BufferMaxSchemesPerChar", 4);
  19. BUFFER_STATIC_BUFF_COST = npcs.getProperty("BufferStaticCostPerBuff", -1);
  20.  
  21. + ENABLE_COMMAND_EPIC = npcs.getProperty("EnableCommandEpic", false);
  22. + RAID_BOSS_DATE_FORMAT = npcs.getProperty("RaidBossDateFormat", "MMM dd, HH:mm");
  23. + RAID_BOSS_IDS = npcs.getProperty("RaidBossIds", "0,0");
  24. + LIST_RAID_BOSS_IDS = new ArrayList<>();
  25. + for (String val : RAID_BOSS_IDS.split(","))
  26. + {
  27. + int npcId = Integer.parseInt(val);
  28. + LIST_RAID_BOSS_IDS.add(npcId);
  29. + }
  30. ALLOW_CLASS_MASTERS = npcs.getProperty("AllowClassMasters", false);
  31. ALLOW_ENTIRE_TREE = npcs.getProperty("AllowEntireTree", false);
  32. if (ALLOW_CLASS_MASTERS)
  33. diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
  34. index d82ef6c..70b72dd 100644
  35. --- a/java/net/sf/l2j/gameserver/GameServer.java
  36. +++ b/java/net/sf/l2j/gameserver/GameServer.java
  37. @@ -41,6 +41,7 @@
  38. import net.sf.l2j.gameserver.data.manager.PartyMatchRoomManager;
  39. import net.sf.l2j.gameserver.data.manager.PetitionManager;
  40. import net.sf.l2j.gameserver.data.manager.PremiumManager;
  41. +import net.sf.l2j.gameserver.data.manager.RaidBossInfoManager;
  42. import net.sf.l2j.gameserver.data.manager.RaidBossManager;
  43. import net.sf.l2j.gameserver.data.manager.RaidPointManager;
  44. import net.sf.l2j.gameserver.data.manager.SevenSignsManager;
  45. @@ -243,6 +244,7 @@
  46. SevenSignsSpawnManager.getInstance().notifyChangeMode();
  47. DayNightManager.getInstance().notifyChangeMode();
  48. DimensionalRiftManager.getInstance();
  49. + RaidBossInfoManager.getInstance();
  50.  
  51. StringUtil.printSection("Olympiads & Heroes");
  52. OlympiadGameManager.getInstance();
  53. diff --git a/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java b/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java
  54. index d319a5e..260eeff 100644
  55. --- a/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java
  56. +++ b/java/net/sf/l2j/gameserver/data/manager/GrandBossManager.java
  57. @@ -10,6 +10,7 @@
  58. import net.sf.l2j.commons.pool.ConnectionPool;
  59. import net.sf.l2j.commons.util.StatsSet;
  60.  
  61. +import net.sf.l2j.Config;
  62. import net.sf.l2j.gameserver.data.xml.NpcData;
  63. import net.sf.l2j.gameserver.model.actor.instance.GrandBoss;
  64.  
  65. @@ -106,7 +107,8 @@
  66. public void setStatsSet(int bossId, StatsSet info)
  67. {
  68. _storedInfo.put(bossId, info);
  69. + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
  70. + RaidBossInfoManager.getInstance().updateRaidBossInfo(bossId, info.getLong("respawn_time"));
  71. updateDb(bossId, false);
  72. }
  73.  
  74. diff --git a/java/net/sf/l2j/gameserver/data/manager/RaidBossInfoManager.java b/java/net/sf/l2j/gameserver/data/manager/RaidBossInfoManager.java
  75. new file mode 100644
  76. index 0000000..c64acee
  77. --- /dev/null
  78. +++ b/java/net/sf/l2j/gameserver/data/manager/RaidBossInfoManager.java
  79. @@ -0,0 +1,66 @@
  80. +package net.sf.l2j.gameserver.data.manager;
  81. +
  82. +import java.sql.Connection;
  83. +import java.sql.PreparedStatement;
  84. +import java.sql.ResultSet;
  85. +import java.util.Map;
  86. +import java.util.concurrent.ConcurrentHashMap;
  87. +import java.util.logging.Logger;
  88. +
  89. +import net.sf.l2j.commons.pool.ConnectionPool;
  90. +
  91. +import net.sf.l2j.Config;
  92. +
  93. +public class RaidBossInfoManager
  94. +{
  95. + private static final Logger _log = Logger.getLogger(RaidBossInfoManager.class.getName());
  96. + private final Map<Integer, Long> _raidBosses;
  97. +
  98. + protected RaidBossInfoManager()
  99. + {
  100. + _raidBosses = new ConcurrentHashMap<>();
  101. + load();
  102. + }
  103. +
  104. + public void load()
  105. + {
  106. + try (Connection con = ConnectionPool.getConnection();
  107. + 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"))
  108. + {
  109. + try (ResultSet rs = statement.executeQuery())
  110. + {
  111. + while (rs.next())
  112. + {
  113. + int bossId = rs.getInt("boss_id");
  114. + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
  115. + _raidBosses.put(bossId, rs.getLong("respawn_time"));
  116. + }
  117. + }
  118. + }
  119. + catch (Exception e)
  120. + {
  121. + _log.warning("Exception: RaidBossInfoManager load: " + e);
  122. + }
  123. + _log.info("RaidBossInfoManager: Loaded " + _raidBosses.size() + " instances.");
  124. + }
  125. +
  126. + public void updateRaidBossInfo(int bossId, long respawnTime)
  127. + {
  128. + _raidBosses.put(bossId, respawnTime);
  129. + }
  130. +
  131. + public long getRaidBossRespawnTime(int bossId)
  132. + {
  133. + return _raidBosses.get(bossId);
  134. + }
  135. +
  136. + public static RaidBossInfoManager getInstance()
  137. + {
  138. + return SingletonHolder._instance;
  139. + }
  140. +
  141. + private static class SingletonHolder
  142. + {
  143. + protected static final RaidBossInfoManager _instance = new RaidBossInfoManager();
  144. + }
  145. +}
  146. \ No newline at end of file
  147. diff --git a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  148. index 3c0a026..7a3e893 100644
  149. --- a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  150. +++ b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  151. @@ -3,7 +3,9 @@
  152. import java.util.HashMap;
  153. import java.util.Map;
  154.  
  155. +import net.sf.l2j.Config;
  156. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.ExpGain;
  157. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.GrandBossStatus;
  158. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.PremiumInfo;
  159.  
  160. public class VoicedCommandHandler
  161. @@ -14,6 +16,11 @@
  162. {
  163. registerHandler(new PremiumInfo());
  164. registerHandler(new ExpGain());
  165. + if(Config.ENABLE_COMMAND_EPIC)
  166. + {
  167. + registerHandler(new GrandBossStatus());
  168. + }
  169. +
  170. }
  171.  
  172. public void registerHandler(IVoicedCommandHandler handler)
  173. diff --git a/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/GrandBossStatus.java b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/GrandBossStatus.java
  174. new file mode 100644
  175. index 0000000..321a760
  176. --- /dev/null
  177. +++ b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/GrandBossStatus.java
  178. @@ -0,0 +1,115 @@
  179. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  180. +
  181. +import java.sql.Date;
  182. +import java.text.SimpleDateFormat;
  183. +import java.util.ArrayList;
  184. +import java.util.List;
  185. +import net.sf.l2j.Config;
  186. +import net.sf.l2j.gameserver.data.manager.RaidBossInfoManager;
  187. +import net.sf.l2j.gameserver.data.xml.NpcData;
  188. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  189. +import net.sf.l2j.gameserver.model.actor.Player;
  190. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  191. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  192. +
  193. +public class GrandBossStatus implements IVoicedCommandHandler
  194. +{
  195. + private static final String[] _voicedCommands =
  196. + {
  197. + "epic"
  198. + };
  199. +
  200. + @Override
  201. + public boolean useVoicedCommand(String command, Player activeChar, String target)
  202. + {
  203. + if (command.startsWith("epic"))
  204. + {
  205. + showMainPage(activeChar);
  206. + }
  207. +
  208. + return true;
  209. + }
  210. +
  211. + public void showMainPage(Player player)
  212. + {
  213. + List<Integer> infos = new ArrayList<>();
  214. + infos.addAll(Config.LIST_RAID_BOSS_IDS);
  215. +
  216. + final StringBuilder sb = new StringBuilder();
  217. + sb.append("<html>");
  218. + sb.append("<center>");
  219. + sb.append("<body>");
  220. + sb.append("<table><tr>");
  221. + sb.append("<td width=32><img src=Icon.etc_alphabet_b_i00 height=32 width=32></td>");
  222. + sb.append("<td width=32><img src=Icon.etc_alphabet_o_i00 height=32 width=32></td>");
  223. + sb.append("<td width=32><img src=Icon.etc_alphabet_s_i00 height=32 width=32></td>");
  224. + sb.append("<td width=32><img src=Icon.etc_alphabet_s_i00 height=32 width=32></td>");
  225. + sb.append("</tr></table><br>");
  226. +
  227. + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  228. + sb.append("<table bgcolor=\"000000\" width=\"318\">");
  229. + sb.append("<tr><td><center><font color=\"FF8C00\">Grand Boss Info</font></center></td></tr>");
  230. + sb.append("</table>");
  231. + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  232. +
  233. + sb.append("<table bgcolor=\"000000\" width=\"318\">");
  234. +
  235. + for (int bossId : infos)
  236. + {
  237. + final NpcTemplate template = NpcData.getInstance().getTemplate(bossId);
  238. + if (template == null)
  239. + continue;
  240. +
  241. + String bossName = template.getName();
  242. + if (bossName.length() > 23)
  243. + bossName = bossName.substring(0, 23) + "...";
  244. +
  245. + final long respawnTime = RaidBossInfoManager.getInstance().getRaidBossRespawnTime(bossId);
  246. + if (respawnTime <= System.currentTimeMillis())
  247. + {
  248. + sb.append("<tr>");
  249. + sb.append("<td><a action=\"" + bossId + "\">" + bossName + "</a></td>");
  250. + sb.append("<td><font color=\"9CC300\">Alive</font></td>");
  251. + sb.append("</tr>");
  252. + }
  253. + else
  254. + {
  255. + sb.append("<tr>");
  256. + sb.append("<td width=\"159\" align=\"left\"><a action=\"" + bossId + "\">" + bossName + "</a></td>");
  257. + sb.append("<td width=\"159\" align=\"left\"><font color=\"FB5858\">Dead</font> " + new SimpleDateFormat(Config.RAID_BOSS_DATE_FORMAT).format(new Date(respawnTime)) + "</td>");
  258. + sb.append("</tr>");
  259. + }
  260. + }
  261. + sb.append("</table>");
  262. +
  263. + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  264. +
  265. + sb.append("<table width=\"300\" cellspacing=\"2\">");
  266. + sb.append("<tr>");
  267. +
  268. + sb.append("</tr>");
  269. + sb.append("</table>");
  270. +
  271. + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  272. +
  273. + sb.append("<table bgcolor=\"000000\" width=\"350\">");
  274. + //sb.append("<tr><td><center><a action=\"bypass returnboss\">Return</a></center></td></tr>");
  275. + sb.append("</table>");
  276. + sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  277. +
  278. +
  279. + sb.append("</center>");
  280. + sb.append("</body>");
  281. + sb.append("</html>");
  282. +
  283. + NpcHtmlMessage msg = new NpcHtmlMessage(5);
  284. + msg.setHtml(sb.toString());
  285. + player.sendPacket(msg);
  286. + }
  287. +
  288. + @Override
  289. + public String[] getVoicedCommandList()
  290. + {
  291. + return _voicedCommands;
  292. + }
  293. +}
  294. \ No newline at end of file
  295. diff --git a/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java b/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java
  296. index bbedd70..772e199 100644
  297. --- a/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java
  298. +++ b/java/net/sf/l2j/gameserver/model/spawn/BossSpawn.java
  299. @@ -10,6 +10,8 @@
  300. import net.sf.l2j.commons.pool.ThreadPool;
  301. import net.sf.l2j.commons.random.Rnd;
  302.  
  303. +import net.sf.l2j.Config;
  304. +import net.sf.l2j.gameserver.data.manager.RaidBossInfoManager;
  305. import net.sf.l2j.gameserver.enums.BossStatus;
  306. import net.sf.l2j.gameserver.model.actor.Npc;
  307.  
  308. @@ -145,6 +147,8 @@
  309.  
  310. // Refresh the database for this particular boss entry.
  311. updateOnDb();
  312. + if (Config.LIST_RAID_BOSS_IDS.contains(_spawn.getNpcId()))
  313. + RaidBossInfoManager.getInstance().updateRaidBossInfo(_spawn.getNpcId(), respawnTime);
  314.  
  315. LOGGER.info("Raid boss: {} - {} ({}h).", _spawn.getNpc().getName(), new SimpleDateFormat("dd-MM-yyyy HH:mm").format(respawnTime), respawnDelay);
  316. }
  317. @@ -173,7 +177,8 @@
  318.  
  319. // Refresh the database for this particular boss entry.
  320. updateOnDb();
  321.  
  322. + if (Config.LIST_RAID_BOSS_IDS.contains(npc.getNpcId()))
  323. + RaidBossInfoManager.getInstance().updateRaidBossInfo(npc.getNpcId(), 0);
  324. LOGGER.info("{} raid boss has spawned.", npc.getName());
  325. }
  326.  
  327. index : gameserver\config\npcs.properties
  328.  
  329. #=============================================================
  330. # Misc
  331. #=============================================================
  332.  
  333. # Allow the use of class Managers to change occupation
  334. # Default = False
  335. AllowClassMasters = False
  336.  
  337. +EnableCommandEpic = True
  338. +RaidBossIds = 25325,29001,29006,29014,29019,29028,29047,29022
  339. +# Displayed date format for dead raid boss
  340. +# Default: (MMM dd, HH:mm)
  341. +RaidBossDateFormat = (MMM dd, HH:mm)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement