Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: data/scripts/custom/BossRespawn/home.htm
- ===================================================================
- --- data/scripts/custom/BossRespawn/home.htm (revision 0)
- +++ data/scripts/custom/BossRespawn/home.htm (revision 0)
- @@ -0,0 +1,16 @@
- +<html>
- + <head>
- + <title>
- + L2 Private Server
- + </title>
- + </head>
- + <body>
- + <center>
- + <img src="L2UI_CH3.herotower_deco" width=256 height=32>
- + Server Rules here ...<br>
- + <button value="I Accept" action="bypass -h npc_%objectId%_Quest BossRespawn" width=100 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
- + <img src="L2UI_CH3.herotower_deco" width=256 height=32>
- + <br>
- + </center>
- + </body>
- +</html>
- \ No newline at end of file
- Index: data/scripts/custom/BossRespawn/raidbosses.htm
- ===================================================================
- --- data/scripts/custom/BossRespawn/raidbosses.htm (revision 0)
- +++ data/scripts/custom/BossRespawn/raidbosses.htm (revision 0)
- @@ -0,0 +1,30 @@
- +<html>
- + <title>Raid Boss Info</title>
- +<body>
- + <br>
- + <center>
- + <img src="L2UI_CH3.herotower_deco" width=256 height=32>
- + <table width=260>
- + <tr>
- + <td><font color="00C3FF">20-30 Level Raid Bosses</color>:</td>
- + <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_20">Click Here</a></color></td>
- + </tr>
- + <tr>
- + <td><font color="00C3FF">40-50 Level Raid Bosses</color>:</td>
- + <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_40">Click Here</a></color></td>
- + </tr>
- + <tr>
- + <td><font color="00C3FF">60-70 Level Raid Bosses</color>:</td>
- + <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_60">Click Here</a></color></td>
- + </tr>
- + <tr>
- + <td><font color="00C3FF">80-90 Level Raid Bosses</color>:</td>
- + <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_80">Click Here</a></color></td>
- + </tr>
- + </table>
- + <img src="L2UI_CH3.herotower_deco" width=256 height=32>
- + <br>
- + </center>
- +</body>
- +</html>
- \ No newline at end of file
- Index: data/scripts/custom/BossRespawn/BossRespawn.java
- ===================================================================
- --- data/scripts/custom/BossRespawn/BossRespawn.java (revision 0)
- +++ data/scripts/custom/BossRespawn/BossRespawn.java (revision 0)
- @@ -0,0 +1,206 @@
- +/*
- + * 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 custom.BossRespawn;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.text.SimpleDateFormat;
- +import java.util.Date;
- +import java.util.Map;
- +import java.util.logging.Level;
- +
- +import javolution.text.TextBuilder;
- +import javolution.util.FastMap;
- +
- +import com.l2jserver.L2DatabaseFactory;
- +import com.l2jserver.gameserver.instancemanager.GrandBossManager;
- +import com.l2jserver.gameserver.model.actor.L2Npc;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.quest.Quest;
- +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jserver.gameserver.templates.StatsSet;
- +
- +/**
- + *
- + * @author Dleogr
- + *
- + */
- +public class BossRespawn extends Quest
- +{
- + private static final int NPC_ID = 93000;
- + private static final boolean GM_ONLY = true;
- + private static Map<Integer, String> GRAND_BOSSES = new FastMap<Integer, String>();
- + private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
- +
- + public BossRespawn(int questid, String name, String descr)
- + {
- + super(questid, name, descr);
- + addFirstTalkId(NPC_ID);
- + addTalkId(NPC_ID);
- + addStartNpc(NPC_ID);
- +
- + Connection con = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = con.prepareStatement("SELECT `n`.`name`, `g`.`boss_id` FROM `npc` as `n` CROSS JOIN `grandboss_data` AS `g` ON `n`.`id` = `g`.`boss_id` GROUP BY `n`.`name` ORDER BY `g`.`respawn_time` DESC");
- +
- + ResultSet rset = statement.executeQuery();
- +
- + while (rset.next())
- + {
- + GRAND_BOSSES.put(rset.getInt("boss_id"), rset.getString("name"));
- + }
- +
- + rset.close();
- + statement.close();
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not restore grand bosses: " + e.getMessage(), e);
- + }
- + finally
- + {
- + L2DatabaseFactory.close(con);
- + }
- +
- + _log.info("Loaded: " + GRAND_BOSSES.size() + " Grand Bosses");
- + }
- +
- + @Override
- + public String onFirstTalk(L2Npc npc, L2PcInstance player)
- + {
- + return "home.htm";
- + }
- +
- + @Override
- + public String onTalk(L2Npc npc, L2PcInstance player)
- + {
- + return "main.htm";
- + }
- +
- + @Override
- + public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
- + {
- + if (event.equalsIgnoreCase("grandbosses"))
- + sendGrandBosses(player);
- + else if (event.equalsIgnoreCase("raidbosses"))
- + return "raidbosses.htm";
- + else if (event.startsWith("raidboss_"))
- + {
- + try
- + {
- + int level = Integer.parseInt(event.substring(9));
- + if (level != 20 && level != 40 && level != 60 && level != 80)
- + return "Are you fackin insain?";
- +
- + sendRaidBosses(player, level);
- + }
- + catch (NumberFormatException nfe) {}
- + }
- +
- + return null;
- + }
- +
- + private void sendRaidBosses(L2PcInstance activeChar, int bosslevel)
- + {
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Raid Boss Info</title><body><br><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><table width=260>");
- +
- + Connection con = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = con.prepareStatement("SELECT `n`.`name`, `n`.`level`, `r`.`respawn_time` FROM `npc` as `n` CROSS JOIN `raidboss_spawnlist` AS `r` ON `n`.`id` = `r`.`boss_id` WHERE `n`.`level` BETWEEN ? AND ? ORDER BY `n`.`level`");
- + statement.setInt(1, bosslevel);
- + statement.setInt(2, bosslevel + 10);
- + ResultSet rset = statement.executeQuery();
- +
- + while (rset.next())
- + {
- + long delay = rset.getLong("respawn_time");
- + String name = rset.getString("name");
- + int level = rset.getInt("level");
- + long currentTime = System.currentTimeMillis();
- +
- + if (delay <= currentTime)
- + tb.append("<tr><td><font color=\"00C3FF\">" + name + " (" + level + ")</color>:</td><td><font color=\"32C332\">" + (activeChar.isGM() && GM_ONLY ? "Is Alive" : "Information is hidden") + "</color></td></tr>");
- +
- + else
- + tb.append("<tr><td><font color=\"00C3FF\">" + name + " (" + level + ")</color>:</td><td><font color=\"9CC300\">" + (activeChar.isGM() && GM_ONLY ? sdf.format(new Date(delay)) : "Information is hidden") + "</color></td></tr>");
- + }
- +
- + tb.append("</table><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br></center></body></html>");
- +
- + rset.close();
- + statement.close();
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
- + msg.setHtml(tb.toString());
- + activeChar.sendPacket(msg);
- +
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Could not restore grand bosses: " + e.getMessage(), e);
- + }
- +
- + finally
- + {
- + L2DatabaseFactory.close(con);
- + }
- + }
- +
- + private void sendGrandBosses(L2PcInstance activeChar)
- + {
- + TextBuilder tb = new TextBuilder();
- + tb.append("<html><title>Grand Boss Info</title><body><br><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><table width=260>");
- +
- + for (int bossId : GRAND_BOSSES.keySet())
- + {
- + String name = GRAND_BOSSES.get(bossId);
- + StatsSet stats = GrandBossManager.getInstance().getStatsSet(bossId);
- + if (stats == null)
- + {
- + activeChar.sendMessage("Stats for GrandBoss " + bossId + " not found!");
- + continue;
- + }
- +
- + long delay = stats.getLong("respawn_time");
- + long currentTime = System.currentTimeMillis();
- +
- + if (delay <= currentTime)
- + tb.append("<tr><td><font color=\"00C3FF\">" + name + "</color>:</td><td><font color=\"32C332\">" + (activeChar.isGM() && GM_ONLY ? "Is Alive" : "Information is hidden") + "</color></td></tr>");
- +
- + else
- + tb.append("<tr><td><font color=\"00C3FF\">" + name + "</color>:</td><td><font color=\"9CC300\">" + (activeChar.isGM() && GM_ONLY ? sdf.format(new Date(delay)) : "Information is hidden") + "</color></td></tr>");
- + }
- +
- + tb.append("</table><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br></center></body></html>");
- +
- + NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
- + msg.setHtml(tb.toString());
- + activeChar.sendPacket(msg);
- + }
- +
- + public static void main(String[] args)
- + {
- + new BossRespawn(-1, "BossRespawn", "custom");
- + }
- +}
- Index: data/scripts/custom/BossRespawn/main.htm
- ===================================================================
- --- data/scripts/custom/BossRespawn/main.htm (revision 0)
- +++ data/scripts/custom/BossRespawn/main.htm (revision 0)
- @@ -0,0 +1,21 @@
- +<html>
- + <title>Grand Boss Info</title>
- +<body>
- + <br>
- + <center>
- + <img src="L2UI_CH3.herotower_deco" width=256 height=32>
- + <table width=260>
- + <tr>
- + <td><font color="00C3FF">Raid Bosses</color>:</td>
- + <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidbosses">Click Here</a></color></td>
- + </tr>
- + <tr>
- + <td><font color="00C3FF">Grand Bosses</color>:</td>
- + <td><font color="32C332"><a action="bypass -h Quest BossRespawn grandbosses">Click Here</a></color></td>
- + </tr>
- + </table>
- + <img src="L2UI_CH3.herotower_deco" width=256 height=32>
- + <br>
- + </center>
- +</body>
- +</html>
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment