Guest User

hall of fame

a guest
Nov 27th, 2012
237
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 1 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.instancemanager;
  16.  
  17. import java.sql.Connection;
  18. import java.sql.PreparedStatement;
  19. import java.sql.ResultSet;
  20.  
  21. import javolution.util.FastMap;
  22.  
  23. import com.l2jserver.L2DatabaseFactory;
  24. import com.l2jserver.gameserver.model.L2World;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. import com.l2jserver.gameserver.model.quest.QuestState;
  29.  
  30. /**
  31. * HallOfFame
  32. * @author Marwan
  33. */
  34. public final class HallOfFame extends Quest
  35. {
  36.  
  37. private final static int NpcId = 1234;
  38. String noob;
  39. int num = 0;
  40.  
  41. private HallOfFame(int questId, String name, String descr)
  42. {
  43. super(questId, name, descr);
  44. addStartNpc(NpcId);
  45. addTalkId(NpcId);
  46. get();
  47. }
  48.  
  49. @Override
  50. public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  51. {
  52. QuestState st = player.getQuestState("HallOfFame");
  53. if (st == null)
  54. {
  55. return "";
  56. }
  57. else if (event.equalsIgnoreCase("show"))
  58. {
  59.  
  60. StringBuilder sb = new StringBuilder();
  61. sb.append("<html><title>HallOfFame</title>");
  62. sb.append("<body>");
  63. // sb.append("<br><font color=\"0066FF\">Current Event: 1vs1 </font>");
  64. sb.append("<table width=270 border=0 bgcolor=\"FF9900\"><tr>");
  65. sb.append("<td width=135 ALIGN=\"CENTER\">HallOfFame" + "</td><br>");
  66. sb.append("</tr></table><br>");
  67. sb.append("<br><font color=\"00ff4d\">Hello " + player.getName() + "<br><br></font>");
  68. sb.append("<hr>");
  69. sb.append("<br><br><br><br>");
  70. sb.append("<center><img src=\"L2UI.SquareWhite\" width=300 height=1>");
  71. sb.append("<table bgcolor=333333 width=100>");
  72. sb.append("<tr>");
  73. sb.append("<td width=135 ALIGN=\"LEFT\"><button value=\"Vote List\" action=\"bypass -h Quest HallOfFame showlist\" width=100 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td>");
  74. sb.append("<td width=135 ALIGN=\"RIGHT\"><button value=\"Info\" action=\"bypass -h Quest HallOfFame moreinfo\" width=100 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></td>");
  75.  
  76. sb.append("</tr>");
  77. sb.append("</table>");
  78. sb.append("<br><br></center>");
  79.  
  80. return sb.toString();
  81. }
  82. else if (event.equalsIgnoreCase("addme"))
  83. {
  84. StringBuilder sb = new StringBuilder();
  85. if (player.getPvpKills() >= 1000)
  86. {
  87. sb.append("<html><title>HallOfFame</title><body><font color=\"1B8900\"><center>");
  88. sb.append("<br><br><br></font>You have been added to the list<br1></center></body></html>");
  89. }
  90. else
  91. {
  92.  
  93. sb.append("<html><title>HallOfFame</title><body><font color=\"FF0033\"><center>");
  94. sb.append("<br><br><br></font>You dont meet the criteria<br1></center></body></html>");
  95.  
  96. }
  97. return sb.toString();
  98. }
  99.  
  100. else if (event.equalsIgnoreCase("showlist"))
  101. {
  102. StringBuilder sb = new StringBuilder();
  103.  
  104. sb.append("<html><title>HallOfFame</title><body><font color=\"525252\">");
  105. sb.append("<br><br><table width=300><tr><td>Num.</td><td width=80>Name</td><td>Status</td></tr><br></font>");
  106. sb.append("<table>" + noob + "</table></body></html>");
  107. return sb.toString();
  108.  
  109. }
  110. else if (event.equalsIgnoreCase("moreinfo"))
  111. {
  112.  
  113. StringBuilder sb = new StringBuilder();
  114. sb.append("<html><title>HallOfFame</title>");
  115. sb.append("<body><h1>Info</h1></body></html>");
  116. return sb.toString();
  117. }
  118. return event;
  119. }
  120.  
  121. public FastMap<L2PcInstance, String> get()
  122. {
  123. try
  124. {
  125. Connection con = L2DatabaseFactory.getInstance().getConnection();
  126.  
  127. String sql = "SELECT char_name FROM characters WHERE famer=?";
  128. PreparedStatement statement = con.prepareStatement(sql);
  129. statement.setInt(1, 1);
  130. ResultSet rset = statement.executeQuery();
  131. while (rset.next())
  132. {
  133. boolean status = false;
  134. for (L2PcInstance n00b : L2World.getInstance().getAllPlayersArray())
  135. {
  136.  
  137. if (n00b.getName().equals(rset.getString("char_name")))
  138. {
  139. status = true;
  140. }
  141. }
  142. num++;
  143. noob += "<tr><td><font color=\"336699\">" + num + "</td><td>" + rset.getString("char_name") + "</font></td><td>";
  144. if (status)
  145. {
  146. noob += "<font color=\"66FF00\">Online</font></td></tr>";
  147. }
  148. else
  149. {
  150. noob += "<font color=\"66FF00\">Offline</font></td></tr>";
  151. }
  152. }
  153. rset.close();
  154. }
  155. catch (Exception e)
  156. {
  157. }
  158. return null;
  159.  
  160. }
  161.  
  162. @SuppressWarnings("synthetic-access")
  163. public static HallOfFame getInstance()
  164. {
  165. return SingletonHolder._instance;
  166. }
  167.  
  168. private static class SingletonHolder
  169. {
  170. @SuppressWarnings("synthetic-access")
  171. private static final HallOfFame _instance = new HallOfFame(-1, "HallOfFame", "instances");
  172. }
  173.  
  174. }
Advertisement
Add Comment
Please, Sign In to add comment