Advertisement
Sarada-L2

Raid Info da acis pra Frozen Yo: Sarada

Mar 4th, 2021
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.65 KB | None | 0 0
  1. diff --git a/config/CustomMods/RaidInfoNpc.ini b/config/CustomMods/RaidInfoNpc.ini
  2. index e69de29..b6b90a3 100644
  3. --- a/config/CustomMods/RaidInfoNpc.ini
  4. +++ b/config/CustomMods/RaidInfoNpc.ini
  5. @@ -0,0 +1,18 @@
  6. +#=============================================================
  7. +# Custom settings
  8. +#=============================================================
  9. +# Limit of displayed raid boss per page
  10. +# Default: 15
  11. +RaidBossInfoPageLimit = 15
  12. +
  13. +# Limit of displayed drop per page
  14. +# Default: 15, Max 18
  15. +RaidBossDropPageLimit = 18
  16. +
  17. +# Displayed date format for dead raid boss
  18. +# Default: (MMM dd, HH:mm)
  19. +RaidBossDateFormat = (MMM dd, HH:mm)
  20. +
  21. +# Displayed raid boss
  22. +# Syntax: bossId,bossId, ...
  23. +RaidBossIds = 25325,29001,29006,29014,29019,29020,29022,29028,29047
  24. \ No newline at end of file
  25. diff --git a/head-src/Dev/SpecialMods/RaidBossInfoManager.java b/head-src/Dev/SpecialMods/RaidBossInfoManager.java
  26. new file mode 100644
  27. index 0000000..8b6f900
  28. --- /dev/null
  29. +++ b/head-src/Dev/SpecialMods/RaidBossInfoManager.java
  30. @@ -0,0 +1,65 @@
  31. +package Dev.SpecialMods;
  32. +
  33. +import java.sql.Connection;
  34. +import java.sql.PreparedStatement;
  35. +import java.sql.ResultSet;
  36. +import java.util.Map;
  37. +import java.util.concurrent.ConcurrentHashMap;
  38. +import java.util.logging.Logger;
  39. +
  40. +import com.l2jfrozen.Config;
  41. +import com.l2jfrozen.util.database.L2DatabaseFactory;
  42. +
  43. +public class RaidBossInfoManager
  44. +{
  45. + private static final Logger _log = Logger.getLogger(RaidBossInfoManager.class.getName());
  46. + private final Map<Integer, Long> _raidBosses;
  47. +
  48. + protected RaidBossInfoManager()
  49. + {
  50. + _raidBosses = new ConcurrentHashMap<>();
  51. + load();
  52. + }
  53. +
  54. + public void load()
  55. + {
  56. + try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  57. + 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"))
  58. + {
  59. + try (ResultSet rs = statement.executeQuery())
  60. + {
  61. + while (rs.next())
  62. + {
  63. + int bossId = rs.getInt("boss_id");
  64. + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
  65. + _raidBosses.put(bossId, rs.getLong("respawn_time"));
  66. + }
  67. + }
  68. + }
  69. + catch (Exception e)
  70. + {
  71. + _log.warning("Exception: RaidBossInfoManager load: " + e);
  72. + }
  73. + _log.info("RaidBossInfoManager: Loaded " + _raidBosses.size() + " instances.");
  74. + }
  75. +
  76. + public void updateRaidBossInfo(int bossId, long respawnTime)
  77. + {
  78. + _raidBosses.put(bossId, respawnTime);
  79. + }
  80. +
  81. + public long getRaidBossRespawnTime(int bossId)
  82. + {
  83. + return _raidBosses.get(bossId);
  84. + }
  85. +
  86. + public static RaidBossInfoManager getInstance()
  87. + {
  88. + return SingletonHolder._instance;
  89. + }
  90. +
  91. + private static class SingletonHolder
  92. + {
  93. + protected static final RaidBossInfoManager _instance = new RaidBossInfoManager();
  94. + }
  95. +}
  96. \ No newline at end of file
  97. diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
  98. index 36631e6..f0cc595 100644
  99. --- a/head-src/com/l2jfrozen/Config.java
  100. +++ b/head-src/com/l2jfrozen/Config.java
  101. @@ -57,6 +57,44 @@
  102. {
  103. private static final Logger LOGGER = Logger.getLogger(Config.class);
  104.  
  105. +
  106. + //============================================================
  107. + /** Raid info*/
  108. + public static int RAID_BOSS_INFO_PAGE_LIMIT;
  109. + public static int RAID_BOSS_DROP_PAGE_LIMIT;
  110. + public static String RAID_BOSS_DATE_FORMAT;
  111. + public static String RAID_BOSS_IDS;
  112. + public static List<Integer> LIST_RAID_BOSS_IDS;
  113. + //============================================================
  114. + public static void loadRaidConfig()
  115. + {
  116. + final String FILENAME = "./config/CustomMods/RaidInfoNpc.ini";
  117. + try
  118. + {
  119. + Properties bossSettings = new Properties();
  120. + InputStream is = new FileInputStream(new File(FILENAME));
  121. + bossSettings.load(is);
  122. + is.close();
  123. + RAID_BOSS_INFO_PAGE_LIMIT = Integer.parseInt(bossSettings.getProperty("RaidBossInfoPageLimit", "15"));
  124. + RAID_BOSS_DROP_PAGE_LIMIT = Integer.parseInt(bossSettings.getProperty("RaidBossDropPageLimit", "15"));
  125. + RAID_BOSS_DATE_FORMAT = bossSettings.getProperty("RaidBossDateFormat", "MMM dd, HH:mm");
  126. + RAID_BOSS_IDS = bossSettings.getProperty("RaidBossIds", "0,0");
  127. + LIST_RAID_BOSS_IDS = new ArrayList<>();
  128. + for (String val : RAID_BOSS_IDS.split(","))
  129. + {
  130. + int npcId = Integer.parseInt(val);
  131. + LIST_RAID_BOSS_IDS.add(npcId);
  132. + }
  133. +
  134. + }
  135. + catch(Exception e)
  136. + {
  137. + e.printStackTrace();
  138. + throw new Error("Failed to Load " + FILENAME + " File.");
  139. + }
  140. + }
  141. +
  142. +
  143. //============================================================
  144. /** Buffer */
  145. public static int BUFFER_MAX_SCHEMES;
  146. @@ -4624,6 +4662,7 @@
  147. loadAccessConfig();
  148. loadModsProtection();
  149. loadSchemeBuffConfig();
  150. + loadRaidConfig();
  151. loadPvpConfig();
  152. loadCraftConfig();
  153.  
  154. diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
  155. index 9742b98..54f932d 100644
  156. --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
  157. +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
  158. @@ -78,6 +78,7 @@
  159. import com.l2jfrozen.gameserver.datatables.sql.TeleportLocationTable;
  160. import com.l2jfrozen.gameserver.datatables.xml.AugmentationData;
  161. import com.l2jfrozen.gameserver.datatables.xml.ExperienceData;
  162. +import com.l2jfrozen.gameserver.datatables.xml.IconTable;
  163. import com.l2jfrozen.gameserver.datatables.xml.ZoneData;
  164. import com.l2jfrozen.gameserver.geo.GeoData;
  165. import com.l2jfrozen.gameserver.geo.geoeditorcon.GeoEditorListener;
  166. @@ -154,6 +155,7 @@
  167. import com.l2jfrozen.util.Util;
  168. import com.l2jfrozen.util.database.L2DatabaseFactory;
  169.  
  170. +import Dev.SpecialMods.RaidBossInfoManager;
  171. import Dev.SpecialMods.XMLDocumentFactory;
  172.  
  173. public class GameServer
  174. @@ -287,6 +289,7 @@
  175. FishTable.getInstance();
  176.  
  177. Util.printSection("Npc");
  178. + RaidBossInfoManager.getInstance();
  179. BufferTable.getInstance();
  180. NpcWalkerRoutesTable.getInstance().load();
  181. if (!NpcTable.getInstance().isInitialized())
  182. @@ -366,6 +369,7 @@
  183. DimensionalRiftManager.getInstance();
  184.  
  185. Util.printSection("Misc");
  186. + IconTable.getInstance();
  187. XMLDocumentFactory.getInstance();
  188. RecipeTable.getInstance();
  189. RecipeController.getInstance();
  190. diff --git a/head-src/com/l2jfrozen/gameserver/datatables/xml/IconTable.java b/head-src/com/l2jfrozen/gameserver/datatables/xml/IconTable.java
  191. new file mode 100644
  192. index 0000000..960533e
  193. --- /dev/null
  194. +++ b/head-src/com/l2jfrozen/gameserver/datatables/xml/IconTable.java
  195. @@ -0,0 +1,92 @@
  196. +/*
  197. + * This program is free software: you can redistribute it and/or modify it under
  198. + * the terms of the GNU General Public License as published by the Free Software
  199. + * Foundation, either version 3 of the License, or (at your option) any later
  200. + * version.
  201. + *
  202. + * This program is distributed in the hope that it will be useful, but WITHOUT
  203. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  204. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  205. + * details.
  206. + *
  207. + * You should have received a copy of the GNU General Public License along with
  208. + * this program. If not, see <http://www.gnu.org/licenses/>.
  209. + */
  210. +package com.l2jfrozen.gameserver.datatables.xml;
  211. +
  212. +import java.io.File;
  213. +import java.util.Map;
  214. +import java.util.concurrent.ConcurrentHashMap;
  215. +import java.util.logging.Level;
  216. +import java.util.logging.Logger;
  217. +
  218. +import org.w3c.dom.Document;
  219. +import org.w3c.dom.NamedNodeMap;
  220. +import org.w3c.dom.Node;
  221. +
  222. +import Dev.SpecialMods.XMLDocumentFactory;
  223. +
  224. +public class IconTable
  225. +{
  226. + private static final Logger _log = Logger.getLogger(IconTable.class.getName());
  227. +
  228. + private static Map<Integer, String> _icons = new ConcurrentHashMap<>();
  229. +
  230. + public static final IconTable getInstance()
  231. + {
  232. + return SingletonHolder._instance;
  233. + }
  234. +
  235. + protected IconTable()
  236. + {
  237. +
  238. + load();
  239. + }
  240. +
  241. + private static void load()
  242. + {
  243. + try
  244. + {
  245. + File f = new File("./data/xml/icons.xml");
  246. + Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
  247. +
  248. + Node n = doc.getFirstChild();
  249. + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  250. + {
  251. + if (d.getNodeName().equalsIgnoreCase("icon"))
  252. + {
  253. + NamedNodeMap attrs = d.getAttributes();
  254. +
  255. + int itemId = Integer.valueOf(attrs.getNamedItem("itemId").getNodeValue());
  256. + String iconName = attrs.getNamedItem("iconName").getNodeValue();
  257. +
  258. + if (itemId == 0 && itemId < 0)
  259. + {
  260. + _log.log(Level.WARNING, "Icon Table: itemId=\"" + itemId + "\" is not item ID, Ignoring it!");
  261. + continue;
  262. + }
  263. + _icons.put(itemId, iconName);
  264. + }
  265. + }
  266. + }
  267. + catch (Exception e)
  268. + {
  269. + _log.log(Level.WARNING, "Icon Table: Error loading from database: " + e.getMessage(), e);
  270. + }
  271. +
  272. + _log.info("Icon Table: Loaded " + _icons.size() + " icons.");
  273. + }
  274. +
  275. + public static String getIcon(int id)
  276. + {
  277. + if (_icons.get(id) == null)
  278. + return "icon.NOIMAGE";
  279. +
  280. + return _icons.get(id);
  281. + }
  282. +
  283. + private static class SingletonHolder
  284. + {
  285. + protected static final IconTable _instance = new IconTable();
  286. + }
  287. +}
  288. \ No newline at end of file
  289. diff --git a/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java b/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java
  290. index b9baa2e..2fbf791 100644
  291. --- a/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java
  292. +++ b/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java
  293. @@ -39,6 +39,8 @@
  294. import com.l2jfrozen.util.database.DatabaseUtils;
  295. import com.l2jfrozen.util.database.L2DatabaseFactory;
  296.  
  297. +import Dev.SpecialMods.RaidBossInfoManager;
  298. +
  299. /**
  300. * This class handles all Grand Bosses:
  301. * <ul>
  302. @@ -299,6 +301,8 @@
  303. _storedInfo.remove(bossId);
  304. }
  305. _storedInfo.put(bossId, info);
  306. + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
  307. + RaidBossInfoManager.getInstance().updateRaidBossInfo(bossId, info.getLong("respawn_time"));
  308. // Update immediately status in Database.
  309. fastStoreToDb();
  310. }
  311. diff --git a/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java b/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java
  312. index fae7a93..b7c7d64 100644
  313. --- a/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java
  314. +++ b/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java
  315. @@ -49,6 +49,8 @@
  316. import com.l2jfrozen.util.database.L2DatabaseFactory;
  317. import com.l2jfrozen.util.random.Rnd;
  318.  
  319. +import Dev.SpecialMods.RaidBossInfoManager;
  320. +
  321. /**
  322. * @author godson
  323. */
  324. @@ -197,7 +199,8 @@
  325. }
  326.  
  327. _schedules.remove(bossId);
  328. -
  329. + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
  330. + RaidBossInfoManager.getInstance().updateRaidBossInfo(bossId, 0);
  331. // To update immediately the database, used for website to show up RaidBoss status.
  332. if (Config.SAVE_RAIDBOSS_STATUS_INTO_DB)
  333. {
  334. @@ -233,7 +236,8 @@
  335.  
  336. ScheduledFuture<?> futureSpawn;
  337. futureSpawn = ThreadPoolManager.getInstance().scheduleGeneral(new spawnSchedule(boss.getNpcId()), respawn_delay);
  338. -
  339. + if (Config.LIST_RAID_BOSS_IDS.contains(boss.getNpcId()))
  340. + RaidBossInfoManager.getInstance().updateRaidBossInfo(boss.getNpcId(), respawnTime);
  341. _schedules.put(boss.getNpcId(), futureSpawn);
  342. futureSpawn = null;
  343.  
  344. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java
  345. index c951ae6..2f6f437 100644
  346. --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java
  347. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java
  348. @@ -24,6 +24,8 @@
  349.  
  350. import java.text.DateFormat;
  351. import java.util.List;
  352. +import java.util.Map;
  353. +import java.util.concurrent.ConcurrentHashMap;
  354.  
  355. import javolution.text.TextBuilder;
  356. import javolution.util.FastList;
  357. @@ -166,7 +168,19 @@
  358.  
  359. /** The _current collision radius. */
  360. private int _currentCollisionRadius; // used for npc grow effect skills
  361. -
  362. + protected static final int PAGE_LIMIT = Config.RAID_BOSS_DROP_PAGE_LIMIT;
  363. + protected static final Map<Integer, Integer> LAST_PAGE = new ConcurrentHashMap<>();
  364. + protected static final String[][] MESSAGE =
  365. + {
  366. + {
  367. + "<font color=\"LEVEL\">%player%</font>, are you not afraid?",
  368. + "Be careful <font color=\"LEVEL\">%player%</font>!"
  369. + },
  370. + {
  371. + "Here is the drop list of <font color=\"LEVEL\">%boss%</font>!",
  372. + "Seems that <font color=\"LEVEL\">%boss%</font> has good drops."
  373. + },
  374. + };
  375. /**
  376. * Task launching the function onRandomAnimation().
  377. */
  378. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2RaidBossInfoInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2RaidBossInfoInstance.java
  379. new file mode 100644
  380. index 0000000..ca097ba
  381. --- /dev/null
  382. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2RaidBossInfoInstance.java
  383. @@ -0,0 +1,327 @@
  384. +/*
  385. +* This program is free software: you can redistribute it and/or modify it under
  386. +* the terms of the GNU General Public License as published by the Free Software
  387. +* Foundation, either version 3 of the License, or (at your option) any later
  388. +* version.
  389. +*
  390. +* This program is distributed in the hope that it will be useful, but WITHOUT
  391. +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  392. +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  393. +* details.
  394. +*
  395. +* You should have received a copy of the GNU General Public License along with
  396. +* this program. If not, see <http://www.gnu.org/licenses/>.
  397. +*/
  398. +package com.l2jfrozen.gameserver.model.actor.instance;
  399. +
  400. +import java.text.DecimalFormat;
  401. +import java.text.SimpleDateFormat;
  402. +import java.util.ArrayList;
  403. +import java.util.Collections;
  404. +import java.util.Date;
  405. +import java.util.List;
  406. +import java.util.Map;
  407. +import java.util.StringTokenizer;
  408. +import java.util.concurrent.ConcurrentHashMap;
  409. +
  410. +import com.l2jfrozen.Config;
  411. +import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
  412. +import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
  413. +import com.l2jfrozen.gameserver.datatables.xml.IconTable;
  414. +import com.l2jfrozen.gameserver.model.L2DropCategory;
  415. +import com.l2jfrozen.gameserver.model.L2DropData;
  416. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  417. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  418. +import com.l2jfrozen.gameserver.templates.L2Item;
  419. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  420. +import com.l2jfrozen.util.StringUtil;
  421. +import com.l2jfrozen.util.random.Rnd;
  422. +
  423. +import Dev.SpecialMods.RaidBossInfoManager;
  424. +
  425. +public class L2RaidBossInfoInstance extends L2NpcInstance
  426. +{
  427. +private final Map<Integer, Integer> _lastPage = new ConcurrentHashMap<>();
  428. +
  429. +private final String[][] _messages =
  430. +{
  431. +{
  432. +"<font color=\"LEVEL\">%player%</font>, are you not afraid?",
  433. +"Be careful <font color=\"LEVEL\">%player%</font>!"
  434. +},
  435. +{
  436. +"Here is the drop list of <font color=\"LEVEL\">%boss%</font>!",
  437. +"Seems that <font color=\"LEVEL\">%boss%</font> has good drops."
  438. +},
  439. +};
  440. +
  441. +public L2RaidBossInfoInstance(int objectId, L2NpcTemplate template)
  442. +{
  443. +super(objectId, template);
  444. +}
  445. +
  446. +@Override
  447. +public void showChatWindow(L2PcInstance player, int val)
  448. +{
  449. +String name = "data/html/mods/raidbossinfo/" + getNpcId() + ".htm";
  450. +if (val != 0)
  451. +name = "data/html/mods/raidbossinfo/" + getNpcId() + "-" + val + ".htm";
  452. +
  453. +NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  454. +html.setFile(name);
  455. +html.replace("%objectId%", getObjectId());
  456. +player.sendPacket(html);
  457. +player.sendPacket(ActionFailed.STATIC_PACKET);
  458. +}
  459. +
  460. +@Override
  461. +public void onBypassFeedback(L2PcInstance player, String command)
  462. +{
  463. +StringTokenizer st = new StringTokenizer(command, " ");
  464. +String currentCommand = st.nextToken();
  465. +
  466. +if (currentCommand.startsWith("RaidBossInfo"))
  467. +{
  468. +int pageId = Integer.parseInt(st.nextToken());
  469. +_lastPage.put(player.getObjectId(), pageId);
  470. +showRaidBossInfo(player, pageId);
  471. +}
  472. +else if (currentCommand.startsWith("RaidBossDrop"))
  473. +{
  474. +int bossId = Integer.parseInt(st.nextToken());
  475. +int pageId = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 1;
  476. +showRaidBossDrop(player, bossId, pageId);
  477. +}
  478. +
  479. +super.onBypassFeedback(player, command);
  480. +}
  481. +
  482. +private void showRaidBossInfo(L2PcInstance player, int pageId)
  483. +{
  484. +List<Integer> infos = new ArrayList<>();
  485. +infos.addAll(Config.LIST_RAID_BOSS_IDS);
  486. +
  487. +final int limit = Config.RAID_BOSS_INFO_PAGE_LIMIT;
  488. +final int max = infos.size() / limit + (infos.size() % limit == 0 ? 0 : 1);
  489. +infos = infos.subList((pageId - 1) * limit, Math.min(pageId * limit, infos.size()));
  490. +
  491. +final StringBuilder sb = new StringBuilder();
  492. +sb.append("<html>");
  493. +sb.append("<center>");
  494. +sb.append("<body>");
  495. +sb.append("<table><tr>");
  496. +sb.append("<td width=32><img src=Icon.etc_alphabet_b_i00 height=32 width=32></td>");
  497. +sb.append("<td width=32><img src=Icon.etc_alphabet_i_i00 height=32 width=32></td>");
  498. +sb.append("<td width=32><img src=Icon.etc_alphabet_g_i00 height=32 width=32></td>");
  499. +sb.append("<td width=32><img src=Icon.etc_alphabet_b_i00 height=32 width=32></td>");
  500. +sb.append("<td width=32><img src=Icon.etc_alphabet_o_i00 height=32 width=32></td>");
  501. +sb.append("<td width=32><img src=Icon.etc_alphabet_s_i00 height=32 width=32></td>");
  502. +sb.append("<td width=32><img src=Icon.etc_alphabet_s_i00 height=32 width=32></td>");
  503. +sb.append("</tr></table><br>");
  504. +
  505. +sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  506. +sb.append("<table bgcolor=\"000000\" width=\"318\">");
  507. +sb.append("<tr><td><center>" + _messages[0][Rnd.get(_messages.length)].replace("%player%", player.getName()) + "</center></td></tr>");
  508. +sb.append("<tr><td><center><font color=\"FF8C00\">Raid Boss Infos</font></center></td></tr>");
  509. +sb.append("</table>");
  510. +sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  511. +
  512. +sb.append("<table bgcolor=\"000000\" width=\"318\">");
  513. +
  514. +for (int bossId : infos)
  515. +{
  516. +final L2NpcTemplate template = NpcTable.getInstance().getTemplate(bossId);
  517. +if (template == null)
  518. +continue;
  519. +
  520. +String bossName = template.getName();
  521. +if (bossName.length() > 23)
  522. +bossName = bossName.substring(0, 23) + "...";
  523. +
  524. +final long respawnTime = RaidBossInfoManager.getInstance().getRaidBossRespawnTime(bossId);
  525. +if (respawnTime <= System.currentTimeMillis())
  526. +{
  527. +sb.append("<tr>");
  528. +sb.append("<td><a action=\"bypass -h npc_%objectId%_RaidBossDrop " + bossId + "\">" + bossName + "</a></td>");
  529. +sb.append("<td><font color=\"9CC300\">Alive</font></td>");
  530. +sb.append("</tr>");
  531. +}
  532. +else
  533. +{
  534. +sb.append("<tr>");
  535. +sb.append("<td width=\"159\" align=\"left\"><a action=\"bypass -h npc_%objectId%_RaidBossDrop " + bossId + "\">" + bossName + "</a></td>");
  536. +sb.append("<td width=\"159\" align=\"left\"><font color=\"FB5858\">Dead</font> " + new SimpleDateFormat(Config.RAID_BOSS_DATE_FORMAT).format(new Date(respawnTime)) + "</td>");
  537. +sb.append("</tr>");
  538. +}
  539. +}
  540. +sb.append("</table>");
  541. +
  542. +sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  543. +
  544. +sb.append("<table width=\"300\" cellspacing=\"2\">");
  545. +sb.append("<tr>");
  546. +for (int x = 0; x < max; x++)
  547. +{
  548. + final int pageNr = x + 1;
  549. + if (pageId == pageNr)
  550. + sb.append("<td align=\"center\">" + pageNr + "</td>");
  551. + else
  552. + sb.append("<td align=\"center\"><a action=\"bypass -h npc_%objectId%_RaidBossInfo " + pageNr + "\">" + pageNr + "</a></td>");
  553. +}
  554. +sb.append("</tr>");
  555. +sb.append("</table>");
  556. +
  557. +sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  558. +
  559. +sb.append("<table bgcolor=\"000000\" width=\"350\">");
  560. +sb.append("<tr><td><center><a action=\"bypass -h npc_%objectId%_Chat 0\">Return</a></center></td></tr>");
  561. +sb.append("</table>");
  562. +sb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
  563. +
  564. +
  565. +sb.append("</center>");
  566. +sb.append("</body>");
  567. +sb.append("</html>");
  568. +
  569. +final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  570. +html.setHtml(sb.toString());
  571. +html.replace("%name%", getName());
  572. +html.replace("%objectId%", getObjectId());
  573. +player.sendPacket(html);
  574. +}
  575. +
  576. +private void showRaidBossDrop(L2PcInstance player, int npcId, int page)
  577. +{
  578. + final L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
  579. + if (template == null)
  580. + return;
  581. +
  582. + if (template.getDropData().isEmpty())
  583. + {
  584. + player.sendMessage("This target have not drop info.");
  585. + return;
  586. + }
  587. +
  588. + final List<L2DropCategory> list = new ArrayList<>();
  589. + template.getDropData().forEach(c -> list.add(c));
  590. + Collections.reverse(list);
  591. +
  592. + int myPage = 1;
  593. + int i = 0;
  594. + int shown = 0;
  595. + boolean hasMore = false;
  596. +
  597. + final StringBuilder sb = new StringBuilder();
  598. + sb.append("<html>");
  599. + sb.append("<center>");
  600. + sb.append("<body>");
  601. + sb.append("<table width=\"256\">");
  602. + sb.append("<tr><td width=\"256\" align=\"center\">%name%</td></tr>");
  603. + sb.append("</table>");
  604. + sb.append("<br>");
  605. + sb.append("<table width=\"256\">");
  606. + sb.append("<tr><td width=\"256\" align=\"left\">" + MESSAGE[1][Rnd.get(MESSAGE.length)].replace("%boss%", template.getName()) + "</td></tr>");
  607. + sb.append("</table>");
  608. + sb.append("<br>");
  609. + sb.append("<table width=\"224\" bgcolor=\"000000\">");
  610. + sb.append("<tr><td width=\"224\" align=\"center\">Raid Boss Drops</td></tr>");
  611. + sb.append("</table>");
  612. + sb.append("<br>");
  613. +
  614. + for (L2DropCategory cat : list)
  615. + {
  616. + if (shown == PAGE_LIMIT)
  617. + {
  618. + hasMore = true;
  619. + break;
  620. + }
  621. +
  622. + for (L2DropData drop : cat.getAllDrops())
  623. + {
  624. + final double chance = Math.min(100, (((drop.getItemId() == 57) ? drop.getChance() * Config.RATE_DROP_ADENA : drop.getChance() * Config.RATE_DROP_ITEMS) / 10000));
  625. + final L2Item item = ItemTable.getInstance().getTemplate(drop.getItemId());
  626. +
  627. + String name = item.getName();
  628. + if (name.startsWith("Recipe: "))
  629. + name = "R: " + name.substring(8);
  630. +
  631. + if (name.length() >= 45)
  632. + name = name.substring(0, 42) + "...";
  633. +
  634. + String percent = null;
  635. + if (chance <= 0.001)
  636. + {
  637. + DecimalFormat df = new DecimalFormat("#.####");
  638. + percent = df.format(chance);
  639. + }
  640. + else if (chance <= 0.01)
  641. + {
  642. + DecimalFormat df = new DecimalFormat("#.###");
  643. + percent = df.format(chance);
  644. + }
  645. + else
  646. + {
  647. + DecimalFormat df = new DecimalFormat("##.##");
  648. + percent = df.format(chance);
  649. + }
  650. +
  651. + if (myPage != page)
  652. + {
  653. + i++;
  654. + if (i == PAGE_LIMIT)
  655. + {
  656. + myPage++;
  657. + i = 0;
  658. + }
  659. + continue;
  660. + }
  661. +
  662. + if (shown == PAGE_LIMIT)
  663. + {
  664. + hasMore = true;
  665. + break;
  666. + }
  667. +
  668. + sb.append(((shown % 2) == 0 ? "<table width=\"280\" bgcolor=\"000000\"><tr>" : "<table width=\"280\"><tr>"));
  669. + sb.append("<td width=44 height=41 align=center><table bgcolor=" + (cat.isSweep() ? "FF00FF" : "FFFFFF") + " cellpadding=6 cellspacing=\"-5\"><tr><td><button width=32 height=32 back=" + IconTable.getIcon(item.getItemId()) + " fore=" + IconTable.getIcon(item.getItemId()) + "></td></tr></table></td>");
  670. + sb.append("<td width=240>" + (cat.isSweep() ? ("<font color=ff00ff>" + name + "</font>") : name) + "<br1><font color=B09878>" + (cat.isSweep() ? "Spoil" : "Drop") + " Chance : " + percent + "%</font></td>");
  671. + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>");
  672. + shown++;
  673. + }
  674. + }
  675. +
  676. + // Build page footer.
  677. + sb.append("<br><img src=\"L2UI.SquareGray\" width=277 height=1><table width=\"100%\" bgcolor=000000><tr>");
  678. +
  679. + if (page > 1)
  680. + StringUtil.append(sb, "<td align=left width=70><a action=\"bypass -h npc_%objectId%_RaidBossDrop "+ npcId + " ", (page - 1), "\">Previous</a></td>");
  681. + else
  682. + StringUtil.append(sb, "<td align=left width=70>Previous</td>");
  683. +
  684. + StringUtil.append(sb, "<td align=center width=100>Page ", page, "</td>");
  685. +
  686. + if (page < shown)
  687. + StringUtil.append(sb, "<td align=right width=70>" + (hasMore ? "<a action=\"bypass -h npc_%objectId%_RaidBossDrop " + npcId + " " + (page + 1) + "\">Next</a>" : "") + "</td>");
  688. + else
  689. + StringUtil.append(sb, "<td align=right width=70>Next</td>");
  690. +
  691. + sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
  692. + sb.append("<br>");
  693. + sb.append("<center>");
  694. + sb.append("<table width=\"160\" cellspacing=\"2\">");
  695. + sb.append("<tr>");
  696. + sb.append("<td width=\"160\" align=\"center\"><a action=\"bypass -h npc_%objectId%_RaidBossInfo " + _lastPage.get(player.getObjectId()) + "\">Return</a></td>");
  697. + sb.append("</tr>");
  698. + sb.append("</table>");
  699. + sb.append("</center>");
  700. + sb.append("</body>");
  701. + sb.append("</html>");
  702. +
  703. + final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  704. + html.setHtml(sb.toString());
  705. + html.replace("%name%", getName());
  706. + html.replace("%objectId%", getObjectId());
  707. + player.sendPacket(html);
  708. +}
  709. +
  710. +}
  711. \ No newline at end of file
  712.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement