package custom.QuestClass;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
public class QuestClass extends Quest
{
private static final String qn = "QuestClass";
private static final int TAKE_ITEM_TEST = 9999;
private static final int GIVE_ITEM_TEST = 9999;
private final static int[] NPCs =
{
9999
};
public QuestClass(int id, String name, String descr)
{
super(id, name, descr);
for (int i : NPCs)
{
addStartNpc(i);
addFirstTalkId(i);
addTalkId(i);
}
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = event;
QuestState st = player.getQuestState(qn);
if (event.equalsIgnoreCase("press_button"))
{
if (player.getLevel() != 80)
htmltext = "main-no-level.htm";
else
{
st.takeItems(TAKE_ITEM_TEST, 1);
st.giveItems(GIVE_ITEM_TEST, 1);
htmltext = "main-success.htm";
}
}
return htmltext;
}
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(qn);
if (st == null)
st = newQuestState(player);
return showWindow(player);
}
public String showWindow(L2PcInstance player)
{
StringBuilder tb = new StringBuilder();
tb.append("<html><body>");
tb.append("<center><a action=\"bypass -h Quest QuestClass press_button\">CONFIRM</a></center>");
tb.append("</body></html>");
NpcHtmlMessage msg = new NpcHtmlMessage(7);
msg.setHtml(tb.toString());
player.sendPacket(msg);
return null;
}
public static void main(String[] args)
{
new QuestClass(-1, qn, "custom");
}
}