Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/config/CustomMods/RaidInfoNpc.ini b/config/CustomMods/RaidInfoNpc.ini
- index e69de29..b6b90a3 100644
- --- a/config/CustomMods/RaidInfoNpc.ini
- +++ b/config/CustomMods/RaidInfoNpc.ini
- @@ -0,0 +1,18 @@
- +#=============================================================
- +# Custom settings
- +#=============================================================
- +# Limit of displayed raid boss per page
- +# Default: 15
- +RaidBossInfoPageLimit = 15
- +
- +# Limit of displayed drop per page
- +# Default: 15, Max 18
- +RaidBossDropPageLimit = 18
- +
- +# Displayed date format for dead raid boss
- +# Default: (MMM dd, HH:mm)
- +RaidBossDateFormat = (MMM dd, HH:mm)
- +
- +# Displayed raid boss
- +# Syntax: bossId,bossId, ...
- +RaidBossIds = 25325,29001,29006,29014,29019,29020,29022,29028,29047
- \ No newline at end of file
- diff --git a/head-src/Dev/SpecialMods/RaidBossInfoManager.java b/head-src/Dev/SpecialMods/RaidBossInfoManager.java
- new file mode 100644
- index 0000000..8b6f900
- --- /dev/null
- +++ b/head-src/Dev/SpecialMods/RaidBossInfoManager.java
- @@ -0,0 +1,65 @@
- +package Dev.SpecialMods;
- +
- +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 com.l2jfrozen.Config;
- +import com.l2jfrozen.util.database.L2DatabaseFactory;
- +
- +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 = L2DatabaseFactory.getInstance().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/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
- index 36631e6..f0cc595 100644
- --- a/head-src/com/l2jfrozen/Config.java
- +++ b/head-src/com/l2jfrozen/Config.java
- @@ -57,6 +57,44 @@
- {
- private static final Logger LOGGER = Logger.getLogger(Config.class);
- +
- + //============================================================
- + /** Raid info*/
- + public static int RAID_BOSS_INFO_PAGE_LIMIT;
- + public static int RAID_BOSS_DROP_PAGE_LIMIT;
- + public static String RAID_BOSS_DATE_FORMAT;
- + public static String RAID_BOSS_IDS;
- + public static List<Integer> LIST_RAID_BOSS_IDS;
- + //============================================================
- + public static void loadRaidConfig()
- + {
- + final String FILENAME = "./config/CustomMods/RaidInfoNpc.ini";
- + try
- + {
- + Properties bossSettings = new Properties();
- + InputStream is = new FileInputStream(new File(FILENAME));
- + bossSettings.load(is);
- + is.close();
- + RAID_BOSS_INFO_PAGE_LIMIT = Integer.parseInt(bossSettings.getProperty("RaidBossInfoPageLimit", "15"));
- + RAID_BOSS_DROP_PAGE_LIMIT = Integer.parseInt(bossSettings.getProperty("RaidBossDropPageLimit", "15"));
- + RAID_BOSS_DATE_FORMAT = bossSettings.getProperty("RaidBossDateFormat", "MMM dd, HH:mm");
- + RAID_BOSS_IDS = bossSettings.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);
- + }
- +
- + }
- + catch(Exception e)
- + {
- + e.printStackTrace();
- + throw new Error("Failed to Load " + FILENAME + " File.");
- + }
- + }
- +
- +
- //============================================================
- /** Buffer */
- public static int BUFFER_MAX_SCHEMES;
- @@ -4624,6 +4662,7 @@
- loadAccessConfig();
- loadModsProtection();
- loadSchemeBuffConfig();
- + loadRaidConfig();
- loadPvpConfig();
- loadCraftConfig();
- diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
- index 9742b98..54f932d 100644
- --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
- +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
- @@ -78,6 +78,7 @@
- import com.l2jfrozen.gameserver.datatables.sql.TeleportLocationTable;
- import com.l2jfrozen.gameserver.datatables.xml.AugmentationData;
- import com.l2jfrozen.gameserver.datatables.xml.ExperienceData;
- +import com.l2jfrozen.gameserver.datatables.xml.IconTable;
- import com.l2jfrozen.gameserver.datatables.xml.ZoneData;
- import com.l2jfrozen.gameserver.geo.GeoData;
- import com.l2jfrozen.gameserver.geo.geoeditorcon.GeoEditorListener;
- @@ -154,6 +155,7 @@
- import com.l2jfrozen.util.Util;
- import com.l2jfrozen.util.database.L2DatabaseFactory;
- +import Dev.SpecialMods.RaidBossInfoManager;
- import Dev.SpecialMods.XMLDocumentFactory;
- public class GameServer
- @@ -287,6 +289,7 @@
- FishTable.getInstance();
- Util.printSection("Npc");
- + RaidBossInfoManager.getInstance();
- BufferTable.getInstance();
- NpcWalkerRoutesTable.getInstance().load();
- if (!NpcTable.getInstance().isInitialized())
- @@ -366,6 +369,7 @@
- DimensionalRiftManager.getInstance();
- Util.printSection("Misc");
- + IconTable.getInstance();
- XMLDocumentFactory.getInstance();
- RecipeTable.getInstance();
- RecipeController.getInstance();
- diff --git a/head-src/com/l2jfrozen/gameserver/datatables/xml/IconTable.java b/head-src/com/l2jfrozen/gameserver/datatables/xml/IconTable.java
- new file mode 100644
- index 0000000..960533e
- --- /dev/null
- +++ b/head-src/com/l2jfrozen/gameserver/datatables/xml/IconTable.java
- @@ -0,0 +1,92 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package com.l2jfrozen.gameserver.datatables.xml;
- +
- +import java.io.File;
- +import java.util.Map;
- +import java.util.concurrent.ConcurrentHashMap;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +import Dev.SpecialMods.XMLDocumentFactory;
- +
- +public class IconTable
- +{
- + private static final Logger _log = Logger.getLogger(IconTable.class.getName());
- +
- + private static Map<Integer, String> _icons = new ConcurrentHashMap<>();
- +
- + public static final IconTable getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + protected IconTable()
- + {
- +
- + load();
- + }
- +
- + private static void load()
- + {
- + try
- + {
- + File f = new File("./data/xml/icons.xml");
- + Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
- +
- + Node n = doc.getFirstChild();
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + if (d.getNodeName().equalsIgnoreCase("icon"))
- + {
- + NamedNodeMap attrs = d.getAttributes();
- +
- + int itemId = Integer.valueOf(attrs.getNamedItem("itemId").getNodeValue());
- + String iconName = attrs.getNamedItem("iconName").getNodeValue();
- +
- + if (itemId == 0 && itemId < 0)
- + {
- + _log.log(Level.WARNING, "Icon Table: itemId=\"" + itemId + "\" is not item ID, Ignoring it!");
- + continue;
- + }
- + _icons.put(itemId, iconName);
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Icon Table: Error loading from database: " + e.getMessage(), e);
- + }
- +
- + _log.info("Icon Table: Loaded " + _icons.size() + " icons.");
- + }
- +
- + public static String getIcon(int id)
- + {
- + if (_icons.get(id) == null)
- + return "icon.NOIMAGE";
- +
- + return _icons.get(id);
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final IconTable _instance = new IconTable();
- + }
- +}
- \ No newline at end of file
- diff --git a/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java b/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java
- index b9baa2e..2fbf791 100644
- --- a/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java
- +++ b/head-src/com/l2jfrozen/gameserver/managers/GrandBossManager.java
- @@ -39,6 +39,8 @@
- import com.l2jfrozen.util.database.DatabaseUtils;
- import com.l2jfrozen.util.database.L2DatabaseFactory;
- +import Dev.SpecialMods.RaidBossInfoManager;
- +
- /**
- * This class handles all Grand Bosses:
- * <ul>
- @@ -299,6 +301,8 @@
- _storedInfo.remove(bossId);
- }
- _storedInfo.put(bossId, info);
- + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
- + RaidBossInfoManager.getInstance().updateRaidBossInfo(bossId, info.getLong("respawn_time"));
- // Update immediately status in Database.
- fastStoreToDb();
- }
- diff --git a/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java b/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java
- index fae7a93..b7c7d64 100644
- --- a/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java
- +++ b/head-src/com/l2jfrozen/gameserver/managers/RaidBossSpawnManager.java
- @@ -49,6 +49,8 @@
- import com.l2jfrozen.util.database.L2DatabaseFactory;
- import com.l2jfrozen.util.random.Rnd;
- +import Dev.SpecialMods.RaidBossInfoManager;
- +
- /**
- * @author godson
- */
- @@ -197,7 +199,8 @@
- }
- _schedules.remove(bossId);
- -
- + if (Config.LIST_RAID_BOSS_IDS.contains(bossId))
- + RaidBossInfoManager.getInstance().updateRaidBossInfo(bossId, 0);
- // To update immediately the database, used for website to show up RaidBoss status.
- if (Config.SAVE_RAIDBOSS_STATUS_INTO_DB)
- {
- @@ -233,7 +236,8 @@
- ScheduledFuture<?> futureSpawn;
- futureSpawn = ThreadPoolManager.getInstance().scheduleGeneral(new spawnSchedule(boss.getNpcId()), respawn_delay);
- -
- + if (Config.LIST_RAID_BOSS_IDS.contains(boss.getNpcId()))
- + RaidBossInfoManager.getInstance().updateRaidBossInfo(boss.getNpcId(), respawnTime);
- _schedules.put(boss.getNpcId(), futureSpawn);
- futureSpawn = null;
- diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java
- index c951ae6..2f6f437 100644
- --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java
- +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java
- @@ -24,6 +24,8 @@
- import java.text.DateFormat;
- import java.util.List;
- +import java.util.Map;
- +import java.util.concurrent.ConcurrentHashMap;
- import javolution.text.TextBuilder;
- import javolution.util.FastList;
- @@ -166,7 +168,19 @@
- /** The _current collision radius. */
- private int _currentCollisionRadius; // used for npc grow effect skills
- -
- + protected static final int PAGE_LIMIT = Config.RAID_BOSS_DROP_PAGE_LIMIT;
- + protected static final Map<Integer, Integer> LAST_PAGE = new ConcurrentHashMap<>();
- + protected static final String[][] MESSAGE =
- + {
- + {
- + "<font color=\"LEVEL\">%player%</font>, are you not afraid?",
- + "Be careful <font color=\"LEVEL\">%player%</font>!"
- + },
- + {
- + "Here is the drop list of <font color=\"LEVEL\">%boss%</font>!",
- + "Seems that <font color=\"LEVEL\">%boss%</font> has good drops."
- + },
- + };
- /**
- * Task launching the function onRandomAnimation().
- */
- diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2RaidBossInfoInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2RaidBossInfoInstance.java
- new file mode 100644
- index 0000000..ca097ba
- --- /dev/null
- +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2RaidBossInfoInstance.java
- @@ -0,0 +1,327 @@
- +/*
- +* This program is free software: you can redistribute it and/or modify it under
- +* the terms of the GNU General Public License as published by the Free Software
- +* Foundation, either version 3 of the License, or (at your option) any later
- +* version.
- +*
- +* This program is distributed in the hope that it will be useful, but WITHOUT
- +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- +* details.
- +*
- +* You should have received a copy of the GNU General Public License along with
- +* this program. If not, see <http://www.gnu.org/licenses/>.
- +*/
- +package com.l2jfrozen.gameserver.model.actor.instance;
- +
- +import java.text.DecimalFormat;
- +import java.text.SimpleDateFormat;
- +import java.util.ArrayList;
- +import java.util.Collections;
- +import java.util.Date;
- +import java.util.List;
- +import java.util.Map;
- +import java.util.StringTokenizer;
- +import java.util.concurrent.ConcurrentHashMap;
- +
- +import com.l2jfrozen.Config;
- +import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
- +import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
- +import com.l2jfrozen.gameserver.datatables.xml.IconTable;
- +import com.l2jfrozen.gameserver.model.L2DropCategory;
- +import com.l2jfrozen.gameserver.model.L2DropData;
- +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
- +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jfrozen.gameserver.templates.L2Item;
- +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
- +import com.l2jfrozen.util.StringUtil;
- +import com.l2jfrozen.util.random.Rnd;
- +
- +import Dev.SpecialMods.RaidBossInfoManager;
- +
- +public class L2RaidBossInfoInstance extends L2NpcInstance
- +{
- +private final Map<Integer, Integer> _lastPage = new ConcurrentHashMap<>();
- +
- +private final String[][] _messages =
- +{
- +{
- +"<font color=\"LEVEL\">%player%</font>, are you not afraid?",
- +"Be careful <font color=\"LEVEL\">%player%</font>!"
- +},
- +{
- +"Here is the drop list of <font color=\"LEVEL\">%boss%</font>!",
- +"Seems that <font color=\"LEVEL\">%boss%</font> has good drops."
- +},
- +};
- +
- +public L2RaidBossInfoInstance(int objectId, L2NpcTemplate template)
- +{
- +super(objectId, template);
- +}
- +
- +@Override
- +public void showChatWindow(L2PcInstance player, int val)
- +{
- +String name = "data/html/mods/raidbossinfo/" + getNpcId() + ".htm";
- +if (val != 0)
- +name = "data/html/mods/raidbossinfo/" + getNpcId() + "-" + val + ".htm";
- +
- +NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- +html.setFile(name);
- +html.replace("%objectId%", getObjectId());
- +player.sendPacket(html);
- +player.sendPacket(ActionFailed.STATIC_PACKET);
- +}
- +
- +@Override
- +public void onBypassFeedback(L2PcInstance player, String command)
- +{
- +StringTokenizer st = new StringTokenizer(command, " ");
- +String currentCommand = st.nextToken();
- +
- +if (currentCommand.startsWith("RaidBossInfo"))
- +{
- +int pageId = Integer.parseInt(st.nextToken());
- +_lastPage.put(player.getObjectId(), pageId);
- +showRaidBossInfo(player, pageId);
- +}
- +else if (currentCommand.startsWith("RaidBossDrop"))
- +{
- +int bossId = Integer.parseInt(st.nextToken());
- +int pageId = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 1;
- +showRaidBossDrop(player, bossId, pageId);
- +}
- +
- +super.onBypassFeedback(player, command);
- +}
- +
- +private void showRaidBossInfo(L2PcInstance player, int pageId)
- +{
- +List<Integer> infos = new ArrayList<>();
- +infos.addAll(Config.LIST_RAID_BOSS_IDS);
- +
- +final int limit = Config.RAID_BOSS_INFO_PAGE_LIMIT;
- +final int max = infos.size() / limit + (infos.size() % limit == 0 ? 0 : 1);
- +infos = infos.subList((pageId - 1) * limit, Math.min(pageId * limit, infos.size()));
- +
- +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_i_i00 height=32 width=32></td>");
- +sb.append("<td width=32><img src=Icon.etc_alphabet_g_i00 height=32 width=32></td>");
- +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>" + _messages[0][Rnd.get(_messages.length)].replace("%player%", player.getName()) + "</center></td></tr>");
- +sb.append("<tr><td><center><font color=\"FF8C00\">Raid Boss Infos</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 L2NpcTemplate template = NpcTable.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=\"bypass -h npc_%objectId%_RaidBossDrop " + 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=\"bypass -h npc_%objectId%_RaidBossDrop " + 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>");
- +for (int x = 0; x < max; x++)
- +{
- + final int pageNr = x + 1;
- + if (pageId == pageNr)
- + sb.append("<td align=\"center\">" + pageNr + "</td>");
- + else
- + sb.append("<td align=\"center\"><a action=\"bypass -h npc_%objectId%_RaidBossInfo " + pageNr + "\">" + pageNr + "</a></td>");
- +}
- +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 -h npc_%objectId%_Chat 0\">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>");
- +
- +final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- +html.setHtml(sb.toString());
- +html.replace("%name%", getName());
- +html.replace("%objectId%", getObjectId());
- +player.sendPacket(html);
- +}
- +
- +private void showRaidBossDrop(L2PcInstance player, int npcId, int page)
- +{
- + final L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
- + if (template == null)
- + return;
- +
- + if (template.getDropData().isEmpty())
- + {
- + player.sendMessage("This target have not drop info.");
- + return;
- + }
- +
- + final List<L2DropCategory> list = new ArrayList<>();
- + template.getDropData().forEach(c -> list.add(c));
- + Collections.reverse(list);
- +
- + int myPage = 1;
- + int i = 0;
- + int shown = 0;
- + boolean hasMore = false;
- +
- + final StringBuilder sb = new StringBuilder();
- + sb.append("<html>");
- + sb.append("<center>");
- + sb.append("<body>");
- + sb.append("<table width=\"256\">");
- + sb.append("<tr><td width=\"256\" align=\"center\">%name%</td></tr>");
- + sb.append("</table>");
- + sb.append("<br>");
- + sb.append("<table width=\"256\">");
- + sb.append("<tr><td width=\"256\" align=\"left\">" + MESSAGE[1][Rnd.get(MESSAGE.length)].replace("%boss%", template.getName()) + "</td></tr>");
- + sb.append("</table>");
- + sb.append("<br>");
- + sb.append("<table width=\"224\" bgcolor=\"000000\">");
- + sb.append("<tr><td width=\"224\" align=\"center\">Raid Boss Drops</td></tr>");
- + sb.append("</table>");
- + sb.append("<br>");
- +
- + for (L2DropCategory cat : list)
- + {
- + if (shown == PAGE_LIMIT)
- + {
- + hasMore = true;
- + break;
- + }
- +
- + for (L2DropData drop : cat.getAllDrops())
- + {
- + final double chance = Math.min(100, (((drop.getItemId() == 57) ? drop.getChance() * Config.RATE_DROP_ADENA : drop.getChance() * Config.RATE_DROP_ITEMS) / 10000));
- + final L2Item item = ItemTable.getInstance().getTemplate(drop.getItemId());
- +
- + String name = item.getName();
- + if (name.startsWith("Recipe: "))
- + name = "R: " + name.substring(8);
- +
- + if (name.length() >= 45)
- + name = name.substring(0, 42) + "...";
- +
- + String percent = null;
- + if (chance <= 0.001)
- + {
- + DecimalFormat df = new DecimalFormat("#.####");
- + percent = df.format(chance);
- + }
- + else if (chance <= 0.01)
- + {
- + DecimalFormat df = new DecimalFormat("#.###");
- + percent = df.format(chance);
- + }
- + else
- + {
- + DecimalFormat df = new DecimalFormat("##.##");
- + percent = df.format(chance);
- + }
- +
- + if (myPage != page)
- + {
- + i++;
- + if (i == PAGE_LIMIT)
- + {
- + myPage++;
- + i = 0;
- + }
- + continue;
- + }
- +
- + if (shown == PAGE_LIMIT)
- + {
- + hasMore = true;
- + break;
- + }
- +
- + sb.append(((shown % 2) == 0 ? "<table width=\"280\" bgcolor=\"000000\"><tr>" : "<table width=\"280\"><tr>"));
- + 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>");
- + 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>");
- + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>");
- + shown++;
- + }
- + }
- +
- + // Build page footer.
- + sb.append("<br><img src=\"L2UI.SquareGray\" width=277 height=1><table width=\"100%\" bgcolor=000000><tr>");
- +
- + if (page > 1)
- + StringUtil.append(sb, "<td align=left width=70><a action=\"bypass -h npc_%objectId%_RaidBossDrop "+ npcId + " ", (page - 1), "\">Previous</a></td>");
- + else
- + StringUtil.append(sb, "<td align=left width=70>Previous</td>");
- +
- + StringUtil.append(sb, "<td align=center width=100>Page ", page, "</td>");
- +
- + if (page < shown)
- + StringUtil.append(sb, "<td align=right width=70>" + (hasMore ? "<a action=\"bypass -h npc_%objectId%_RaidBossDrop " + npcId + " " + (page + 1) + "\">Next</a>" : "") + "</td>");
- + else
- + StringUtil.append(sb, "<td align=right width=70>Next</td>");
- +
- + sb.append("</tr></table><img src=\"L2UI.SquareGray\" width=277 height=1>");
- + sb.append("<br>");
- + sb.append("<center>");
- + sb.append("<table width=\"160\" cellspacing=\"2\">");
- + sb.append("<tr>");
- + sb.append("<td width=\"160\" align=\"center\"><a action=\"bypass -h npc_%objectId%_RaidBossInfo " + _lastPage.get(player.getObjectId()) + "\">Return</a></td>");
- + sb.append("</tr>");
- + sb.append("</table>");
- + sb.append("</center>");
- + sb.append("</body>");
- + sb.append("</html>");
- +
- + final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
- + html.setHtml(sb.toString());
- + html.replace("%name%", getName());
- + html.replace("%objectId%", getObjectId());
- + player.sendPacket(html);
- +}
- +
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement