Elfocrash

Trivia Event

Sep 27th, 2013
1,785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.87 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P gameserver
  3. Index: java/net/sf/l2j/gameserver/GameServer.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 36)
  6. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  7. @@ -101,6 +101,7 @@
  8.  import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
  9.  import net.sf.l2j.gameserver.model.entity.Castle;
  10.  import net.sf.l2j.gameserver.model.entity.Hero;
  11. +import net.sf.l2j.gameserver.model.entity.TriviaEventManager;
  12.  import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  13.  import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
  14.  import net.sf.l2j.gameserver.model.votereward.VoteMain;
  15. @@ -271,6 +272,8 @@
  16.         OlympiadGameManager.getInstance();
  17.         Olympiad.getInstance();
  18.         Hero.getInstance();
  19. +
  20. +       TriviaEventManager.getInstance();
  21.        
  22.         Util.printSection("Four Sepulchers");
  23.         FourSepulchersManager.getInstance().init();
  24. Index: java/net/sf/l2j/gameserver/model/entity/Trivia.java
  25. ===================================================================
  26. --- java/net/sf/l2j/gameserver/model/entity/Trivia.java (revision 0)
  27. +++ java/net/sf/l2j/gameserver/model/entity/Trivia.java (revision 0)
  28. @@ -0,0 +1,216 @@
  29. +package net.sf.l2j.gameserver.model.entity;
  30. +
  31. +
  32. +import java.io.File;
  33. +import java.util.logging.Logger;
  34. +
  35. +import javax.xml.parsers.DocumentBuilder;
  36. +import javax.xml.parsers.DocumentBuilderFactory;
  37. +
  38. +import javolution.util.FastMap;
  39. +import net.sf.l2j.gameserver.Announcements;
  40. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  41. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  42. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  43. +import net.sf.l2j.util.Rnd;
  44. +
  45. +import org.w3c.dom.Document;
  46. +import org.w3c.dom.Element;
  47. +import org.w3c.dom.Node;
  48. +import org.w3c.dom.NodeList;
  49. +
  50. +
  51. +public class Trivia
  52. +{
  53. +   enum EventState
  54. +   {
  55. +       INACTIVE,
  56. +       ASKING,
  57. +       ANSWERING,
  58. +       CORRECT,
  59. +       REWARDING,
  60. +       ENDING
  61. +   }
  62. +   protected static final Logger _log = Logger.getLogger(Trivia.class.getName());
  63. +   private static EventState _state = EventState.INACTIVE;
  64. +   //ID of the reward
  65. +   private static int _rewardID = 9142;
  66. +   //Ammount of the reward
  67. +   private static int _rewardCount = 1;
  68. +   private static long questionTime=0;
  69. +   private static FastMap<String,String> q_a = new FastMap<String,String>();
  70. +   public static int asked=0;
  71. +   private static String question,answer;
  72. +      
  73. +   private Trivia()
  74. +   {
  75. +      
  76. +   }
  77. +   public static void init()
  78. +   {
  79. +       setState(EventState.INACTIVE);
  80. +       getQuestions();
  81. +   }
  82. +   private static void getQuestions()
  83. +   {
  84. +       File file = new File("config/Trivia.xml");
  85. +       String ask, answer;
  86. +       try
  87. +       {
  88. +           DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  89. +              DocumentBuilder db = dbf.newDocumentBuilder();
  90. +              Document doc = db.parse(file);
  91. +              doc.getDocumentElement().normalize();
  92. +              NodeList trvLst = doc.getElementsByTagName("trivia");     
  93. +             for (int s = 0; s < trvLst.getLength(); s++)
  94. +             {
  95. +               Node trvNode = trvLst.item(s);
  96. +                if (trvNode.getNodeType() == Node.ELEMENT_NODE)
  97. +                {
  98. +                       Element triviaElement = (Element)trvNode;
  99. +                       NodeList trvList = triviaElement.getElementsByTagName("question");
  100. +                       Element questionElement = (Element)trvList.item(0);
  101. +
  102. +                       NodeList textQsList = questionElement.getChildNodes();
  103. +                       ask = ((Node)textQsList.item(0)).getNodeValue().trim();
  104. +
  105. +                       NodeList answerList = triviaElement.getElementsByTagName("answer");
  106. +                       Element answerElement = (Element)answerList.item(0);
  107. +
  108. +                       NodeList textAnList = answerElement.getChildNodes();
  109. +                       answer = ((Node)textAnList.item(0)).getNodeValue().trim();
  110. +                       q_a.put(ask, answer);
  111. +                }
  112. +            
  113. +             }
  114. +       }
  115. +       catch (Exception e)
  116. +       {
  117. +        e.printStackTrace();  
  118. +       }
  119. +   }
  120. +   public static void handleAnswer(String s,L2PcInstance pi)
  121. +   {
  122. +       if(s.equalsIgnoreCase(answer))
  123. +       {
  124. +           pi.sendPacket(new CreatureSay(12345, Say2.TELL, "Trivia", "Correct!"));
  125. +           setState(EventState.REWARDING);
  126. +           Announcements.announceToAll("Winner is "+pi.getName()+"! He answered in "+(System.currentTimeMillis()-questionTime)/1000+" seconds!");
  127. +           announceCorrect();
  128. +           pi.addItem("Trivia", _rewardID, _rewardCount, pi, true);
  129. +       }
  130. +       else
  131. +           pi.sendPacket(new CreatureSay(1234, 2, "Trivia", "Wrong answer."));
  132. +          
  133. +   }
  134. +   public static void startTrivia()
  135. +   {
  136. +       Announcements.announceToAll("Trivia Event begins! You have to PM Trivia with your answer, get ready!");
  137. +       setState(EventState.ASKING);
  138. +   }
  139. +   public static void askQuestion()
  140. +   {
  141. +       pickQuestion();
  142. +       Announcements.announceToAll("Question: "+question);
  143. +       questionTime=System.currentTimeMillis();
  144. +       setState(EventState.ANSWERING);
  145. +   }
  146. +   public static void announceCorrect()
  147. +   {
  148. +       setState(EventState.CORRECT);
  149. +       Announcements.announceToAll("The correct answer was: "+answer);
  150. +       asked++;
  151. +       setState(EventState.ASKING);
  152. +   }
  153. +   public static void endEvent()
  154. +   {
  155. +       setState(EventState.INACTIVE);
  156. +       asked = 0;
  157. +   }
  158. +   private static void pickQuestion()
  159. +   {
  160. +     int roll=Rnd.get(q_a.size())+1;
  161. +     int i=0;
  162. +     for(String q:q_a.keySet())
  163. +     {
  164. +      ++i;
  165. +      if(i==roll)
  166. +      {
  167. +       answer=q_a.get(q);
  168. +       question=q;
  169. +       return;
  170. +      }
  171. +     }
  172. +   }
  173. +   public static boolean isInactive()
  174. +   {
  175. +      boolean isInactive;
  176. +       synchronized (_state)
  177. +       {
  178. +           isInactive = _state == EventState.INACTIVE;
  179. +       }
  180. +       return isInactive;
  181. +   }
  182. +   public static boolean isAnswering()
  183. +   {
  184. +       boolean isAnswering;
  185. +       synchronized (_state)
  186. +       {
  187. +           isAnswering = _state == EventState.ANSWERING;
  188. +       }
  189. +       return isAnswering;
  190. +   }
  191. +   public static boolean isEnding()
  192. +   {
  193. +       boolean isEnding;
  194. +       synchronized (_state)
  195. +       {
  196. +           isEnding = _state == EventState.ENDING;
  197. +       }
  198. +       return isEnding;
  199. +   }
  200. +   public static boolean isCorrect()
  201. +   {
  202. +       boolean isCorrect;
  203. +       synchronized (_state)
  204. +       {
  205. +           isCorrect = _state == EventState.CORRECT;
  206. +       }
  207. +       return isCorrect;
  208. +   }
  209. +   public static boolean isRewarding()
  210. +   {
  211. +       boolean isRewarding;
  212. +       synchronized (_state)
  213. +       {
  214. +           isRewarding = _state == EventState.REWARDING;
  215. +       }
  216. +       return isRewarding;
  217. +   }
  218. +   public static boolean isAsking()
  219. +   {
  220. +       boolean isAsking;
  221. +       synchronized (_state)
  222. +       {
  223. +           isAsking = _state == EventState.ASKING;
  224. +       }
  225. +       return isAsking;
  226. +   }
  227. +   private static void setState(EventState state)
  228. +   {
  229. +       synchronized (_state)
  230. +       {
  231. +           _state = state;
  232. +       }
  233. +   }
  234. +   public static Trivia getInstance()
  235. +   {
  236. +       return SingletonHolder._instance;
  237. +   }
  238. +
  239. +   private static class SingletonHolder
  240. +   {
  241. +       protected static final Trivia _instance = new Trivia();
  242. +   }
  243. +
  244. +}
  245. \ No newline at end of file
  246. Index: java/net/sf/l2j/gameserver/model/entity/TriviaEventManager.java
  247. ===================================================================
  248. --- java/net/sf/l2j/gameserver/model/entity/TriviaEventManager.java (revision 0)
  249. +++ java/net/sf/l2j/gameserver/model/entity/TriviaEventManager.java (revision 0)
  250. @@ -0,0 +1,189 @@
  251. +package net.sf.l2j.gameserver.model.entity;
  252. +
  253. +
  254. +import java.util.Calendar;
  255. +import java.util.concurrent.ScheduledFuture;
  256. +import java.util.logging.Logger;
  257. +
  258. +import net.sf.l2j.Config;
  259. +import net.sf.l2j.gameserver.ThreadPoolManager;
  260. +
  261. +
  262. +public class TriviaEventManager
  263. +{
  264. +    protected static final Logger _log = Logger.getLogger(TriviaEventManager.class.getName());
  265. +      
  266. +       /** Task for event cycles<br> */
  267. +       private TriviaStartTask _task;
  268. +      
  269. +       /**
  270. +        * New instance only by getInstance()<br>
  271. +        */
  272. +       private TriviaEventManager()
  273. +       {
  274. +           if (Config.TRIVIA_ENABLED)
  275. +           {
  276. +               Trivia.init();
  277. +               this.scheduleEventStart();
  278. +               _log.warning("TriviaEventEngine[TriviaManager.TriviaManager()]: Started.");
  279. +           }
  280. +           else
  281. +           {
  282. +               _log.warning("TriviaEventEngine[TriviaManager.TriviaManager()]: Engine is disabled.");
  283. +           }
  284. +       }
  285. +       public static TriviaEventManager getInstance()
  286. +       {
  287. +           return SingletonHolder._instance;
  288. +       }
  289. +      
  290. +       /**
  291. +        * Starts the event
  292. +        */
  293. +       public void scheduleEventStart()
  294. +       {
  295. +           try
  296. +           {
  297. +               Calendar currentTime = Calendar.getInstance();
  298. +               Calendar nextStartTime = null;
  299. +               Calendar testStartTime = null;
  300. +               for (String timeOfDay : Config.TRIVIA_INTERVAL)
  301. +               {
  302. +                   // Creating a Calendar object from the specified interval value
  303. +                   testStartTime = Calendar.getInstance();
  304. +                   testStartTime.setLenient(true);
  305. +                   String[] splitTimeOfDay = timeOfDay.split(":");
  306. +                   testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  307. +                   testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  308. +                   // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
  309. +                   if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  310. +                   {
  311. +                       testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  312. +                   }
  313. +                   // Check for the test date to be the minimum (smallest in the specified list)
  314. +                   if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
  315. +                   {
  316. +                       nextStartTime = testStartTime;
  317. +                   }
  318. +               }
  319. +               _task = new TriviaStartTask(nextStartTime.getTimeInMillis());
  320. +               ThreadPoolManager.getInstance().executeTask(_task);
  321. +           }
  322. +           catch (Exception e)
  323. +           {
  324. +               _log.warning("TriviaEventEngine[TriviaManager.scheduleEventStart()]: Error figuring out a start time. Check TriviaEventInterval in config file.");
  325. +           }
  326. +       }
  327. +      
  328. +       class TriviaStartTask implements Runnable
  329. +       {
  330. +           private long _startTime;
  331. +           public ScheduledFuture<?> nextRun;
  332. +          
  333. +           public TriviaStartTask(long startTime)
  334. +           {
  335. +               _startTime = startTime;
  336. +           }
  337. +          
  338. +           public void setStartTime(long startTime)
  339. +           {
  340. +               _startTime = startTime;
  341. +           }
  342. +          
  343. +           /**
  344. +            * @see java.lang.Runnable#run()
  345. +            */
  346. +           public void run()
  347. +           {
  348. +               int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
  349. +               int nextMsg = 0;
  350. +               if (delay > 3600)
  351. +               {
  352. +                   nextMsg = delay - 3600;
  353. +               }
  354. +               else if (delay > 1800)
  355. +               {
  356. +                   nextMsg = delay - 1800;
  357. +               }
  358. +               else if (delay > 900)
  359. +               {
  360. +                   nextMsg = delay - 900;
  361. +               }
  362. +               else if (delay > 600)
  363. +               {
  364. +                   nextMsg = delay - 600;
  365. +               }
  366. +               else if (delay > 300)
  367. +               {
  368. +                   nextMsg = delay - 300;
  369. +               }
  370. +               else if (delay > 60)
  371. +               {
  372. +                   nextMsg = delay - 60;
  373. +               }
  374. +               else if (delay > 5)
  375. +               {
  376. +                   nextMsg = delay - 5;
  377. +               }
  378. +               else if (delay > 0)
  379. +               {
  380. +                   nextMsg = delay;
  381. +               }
  382. +               else
  383. +               {
  384. +                   if (Trivia.isInactive())
  385. +                   {
  386. +                       startTrivia();         
  387. +                   }
  388. +                   else if(Trivia.isAsking())
  389. +                   {
  390. +                       if(Trivia.asked<Config.TRIVIA_TO_ASK)
  391. +                       {
  392. +                           startQuestion();
  393. +                       }
  394. +                       else
  395. +                       {
  396. +                           endTrivia();
  397. +                       }
  398. +                   }
  399. +                   else if(Trivia.isAnswering())
  400. +                   {
  401. +                       announceAnswer();
  402. +                   }
  403. +               }
  404. +              
  405. +               if (delay > 0)
  406. +               {
  407. +                   nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
  408. +               }
  409. +           }
  410. +       }
  411. +       public void startTrivia()
  412. +       {
  413. +           Trivia.startTrivia();
  414. +           _task.setStartTime(System.currentTimeMillis() + 1000L *10);
  415. +           ThreadPoolManager.getInstance().executeTask(_task);
  416. +       }
  417. +       public void startQuestion()
  418. +       {
  419. +           Trivia.askQuestion();
  420. +           _task.setStartTime(System.currentTimeMillis() + 1000L *Config.TRIVIA_ANSWER_TIME);
  421. +           ThreadPoolManager.getInstance().executeTask(_task);
  422. +       }
  423. +       public void endTrivia()
  424. +       {
  425. +           Trivia.endEvent();
  426. +           this.scheduleEventStart();
  427. +       }
  428. +       public void announceAnswer()
  429. +       {
  430. +           Trivia.announceCorrect();
  431. +           _task.setStartTime(System.currentTimeMillis() +1000L *10);
  432. +           ThreadPoolManager.getInstance().executeTask(_task);
  433. +       }
  434. +       @SuppressWarnings("synthetic-access")
  435. +       private static class SingletonHolder
  436. +       {
  437. +           protected static final TriviaEventManager _instance = new TriviaEventManager();
  438. +       }
  439. +}
  440. \ No newline at end of file
  441. Index: config/Trivia.xml
  442. ===================================================================
  443. --- config/Trivia.xml   (revision 0)
  444. +++ config/Trivia.xml   (revision 0)
  445. @@ -0,0 +1,334 @@
  446. +<?xml version="1.0" encoding="UTF-8"?>
  447. +<event>          
  448. +  <trivia>
  449. +    <question>What current branch of the U.S. military was a corps of only 50 soldiers when World War I broke out</question>
  450. +    <answer>The U.S. Air Force</answer>
  451. +  </trivia>
  452. +
  453. +  <trivia>
  454. +    <question>What game was created by French mathematician Blaise Pascal, which he discovered when doing experiments into perpetual motion?</question>
  455. +    <answer>The Game of Roulette</answer>
  456. +  </trivia>
  457. +
  458. +  <trivia>
  459. +    <question>Who said: &quot; I'm the president of the United States and I'm not going to eat any more broccoli &quot;?</question>
  460. +    <answer>George Bush</answer>
  461. +  </trivia>
  462. +
  463. +  <trivia>
  464. +    <question>What future Soviet dictator was training to be a priest when he got turned on to Marxism?</question>
  465. +    <answer>Joseph Stalin</answer>
  466. +  </trivia>
  467. +
  468. +  <trivia>
  469. +    <question>What election year saw bumper stickers reading &quot;Wallace, Wallace, Uber Alles&quot;</question>
  470. +    <answer>1968</answer>
  471. +  </trivia>
  472. +
  473. +  <trivia>
  474. +    <question>Which is the last NPC you have to talk to, to obtain a Portal Stone?</question>
  475. +    <answer>Theodoric</answer>
  476. +  </trivia>
  477. +
  478. +  <trivia>
  479. +    <question>What color Soul Crystal do you need to have for Acumen SA on Arcana mace?</question>
  480. +    <answer>Red</answer>
  481. +  </trivia>
  482. +
  483. +  <trivia>
  484. +    <question>How many rooms do the 4 Sepulchers have in total?</question>
  485. +    <answer>4</answer>
  486. +  </trivia>
  487. +
  488. +  <trivia>
  489. +    <question>When does the Merchant of Mammon appear in Catacombs?</question>
  490. +    <answer>Never</answer>
  491. +  </trivia>
  492. +
  493. +  <trivia>
  494. +    <question>How many A-grade grandboss jewels exists?</question>
  495. +    <answer>3</answer>
  496. +  </trivia>
  497. +
  498. +  <trivia>
  499. +    <question>What is the name of the only B-grade grandboss jewel?</question>
  500. +    <answer>Ring of queen ant</answer>
  501. +  </trivia>
  502. +
  503. +  <trivia>
  504. +    <question>How many Olympiad points does a Noblesse character have at the end of each month, if he does not compete?</question>
  505. +    <answer>18</answer>
  506. +  </trivia>
  507. +
  508. +  <trivia>
  509. +    <question>When creating a character, you can choose to be a mage or fighter. There is one race that doesn't offer this choice. Which race is that?</question>
  510. +    <answer>Dwarf</answer>
  511. +  </trivia>
  512. +
  513. +  <trivia>
  514. +    <question>What TV show lost Jim Carrey when he stepped into the movies?</question>
  515. +    <answer>In Living Color</answer>
  516. +  </trivia>
  517. +
  518. +  <trivia>
  519. +    <question>At which level can you make the Hatchling quest?</question>
  520. +    <answer>35</answer>
  521. +  </trivia>
  522. +
  523. +  <trivia>
  524. +    <question>What's the name of the item you need to get your clan to level 4?</question>
  525. +    <answer>Alliance Manifesto</answer>
  526. +  </trivia>
  527. +
  528. +  <trivia>
  529. +    <question>What level does your clan have to be in order to start an Alliance?</question>
  530. +    <answer>5</answer>
  531. +  </trivia>
  532. +
  533. +  <trivia>
  534. +    <question>Baium is the father of...</question>
  535. +    <answer>Frintezza</answer>
  536. +  </trivia>
  537. +
  538. +  <trivia>
  539. +    <question>What are the names of the two &quot;teams&quot; on the Seven Signs Quest?</question>
  540. +    <answer>Dawn and Dusk</answer>
  541. +  </trivia>
  542. +
  543. +  <trivia>
  544. +    <question>How many servers are there on the offical lineage II?</question>
  545. +    <answer>8</answer>
  546. +  </trivia>
  547. +
  548. +  <trivia>
  549. +    <question>as a fighter, what is the first level when you can learn your first skills?</question>
  550. +    <answer>5</answer>
  551. +  </trivia>
  552. +
  553. +  <trivia>
  554. +    <question>In what level can you create a clan?</question>
  555. +    <answer>10</answer>
  556. +  </trivia>
  557. +
  558. +  <trivia>
  559. +    <question>What so-called &quot;war&quot; spawned the dueling slogans &quot;Better Dead Than RED&quot; and &quot;Better Red Than Dead&quot; in the 1950's?</question>
  560. +    <answer>The Cold War</answer>
  561. +  </trivia>
  562. +
  563. +  <trivia>
  564. +    <question>What president was shot  while walking to California Governor Jerry Brown' office?</question>
  565. +    <answer>Gerald Ford</answer>
  566. +  </trivia>
  567. +
  568. +  <trivia>
  569. +    <question>What modern vehicle was invented to circumvent trench warfare?</question>
  570. +    <answer>Tank</answer>
  571. +  </trivia>
  572. +
  573. +  <trivia>
  574. +    <question>What congressional award was Dr. Mary Edwards Walker the first woman to receive?</question>
  575. +    <answer>Medal of Honor</answer>
  576. +  </trivia>
  577. +
  578. +  <trivia>
  579. +    <question>What congressional award was Dr. Mary Edwards Walker the first woman to receive?</question>
  580. +    <answer>Medal of Honor</answer>
  581. +  </trivia>
  582. +
  583. +  <trivia>
  584. +    <question>In which television series did Roger Moore star from 1962 to 1970?</question>
  585. +    <answer>The Saint</answer>
  586. +  </trivia>
  587. +
  588. +  <trivia>
  589. +    <question>Who introduced the Betamax video cassette system?</question>
  590. +    <answer>Sony</answer>
  591. +  </trivia>
  592. +
  593. +  <trivia>
  594. +    <question>What is Bugs Bunny's catchphrase?</question>
  595. +    <answer>Eh, whats up Doc?</answer>
  596. +  </trivia>
  597. +
  598. +  <trivia>
  599. +    <question>Which Hollywood film maker produced a string of films in the 1950s and 1960s using animals as actors in a drama?</question>
  600. +    <answer>Walt Disney</answer>
  601. +  </trivia>
  602. +
  603. +  <trivia>
  604. +    <question>Which character made his debut in the silent film Plane Crazy in 1928?</question>
  605. +    <answer>Mickey Mouse</answer>
  606. +  </trivia>
  607. +
  608. +  <trivia>
  609. +    <question>How did James Dean die?</question>
  610. +    <answer>In a car accident</answer>
  611. +  </trivia>
  612. +
  613. +  <trivia>
  614. +    <question>Which world-famous cartoon cat was created in 1920 by Pat Sullivan?</question>
  615. +    <answer>Felix the Cat</answer>
  616. +  </trivia>
  617. +
  618. +  <trivia>
  619. +    <question>Which group flew into the Hotel California?</question>
  620. +    <answer>The Eagles</answer>
  621. +  </trivia>
  622. +
  623. +  <trivia>
  624. +    <question>Which all time great band featured Harrison and Starkey?</question>
  625. +    <answer>The Beatles</answer>
  626. +  </trivia>
  627. +
  628. +  <trivia>
  629. +    <question>Arnold Schwarzenegger married the niece of which US president?</question>
  630. +    <answer>John F. Kennedy</answer>
  631. +  </trivia>
  632. +
  633. +  <trivia>
  634. +    <question>In which city did Steve McQueen take part in the car chase in Bullitt?</question>
  635. +    <answer>San Francisco</answer>
  636. +  </trivia>
  637. +
  638. +  <trivia>
  639. +    <question>In which movie did Alex Guinness first appear as Ben Obi Wan Kenobi?</question>
  640. +    <answer>Star Wars</answer>
  641. +  </trivia>
  642. +
  643. +  <trivia>
  644. +    <question>Marlon and Tito were two members of which famous family group?</question>
  645. +    <answer>Jackson Five</answer>
  646. +  </trivia>
  647. +
  648. +  <trivia>
  649. +    <question>Where did Crazy For You lose half a million dollars before finding success on Broadway?</question>
  650. +    <answer>Washington</answer>
  651. +  </trivia>
  652. +
  653. +  <trivia>
  654. +    <question>Leslie Rogge was the first person to be arrested due to what?</question>
  655. +    <answer>The Internet</answer>
  656. +  </trivia>
  657. +
  658. +  <trivia>
  659. +    <question>In 1908 Wilbur Wright traveled what record-breaking number of miles in 2 hours 20 minutes?</question>
  660. +    <answer>77</answer>
  661. +  </trivia>
  662. +
  663. +  <trivia>
  664. +    <question>How long did Bleriot's first flight across the English Channel last?</question>
  665. +    <answer>43 minutes</answer>
  666. +  </trivia>
  667. +
  668. +  <trivia>
  669. +    <question>What nationality of plane first broke the 100mph sound barrier?</question>
  670. +    <answer>French</answer>
  671. +  </trivia>
  672. +
  673. +  <trivia>
  674. +    <question>The first air collision took place over which country?</question>
  675. +    <answer>Austria</answer>
  676. +  </trivia>
  677. +
  678. +  <trivia>
  679. +    <question>How long did the record-breaking space walk from space shuttle Endeavor last in 1993?</question>
  680. +    <answer>Five hours</answer>
  681. +  </trivia>
  682. +
  683. +  <trivia>
  684. +    <question>Where did the European space probe Ulysses set off for in 1991?</question>
  685. +    <answer>The Sun</answer>
  686. +  </trivia>
  687. +
  688. +  <trivia>
  689. +    <question>What was the name of the first probe to send back pictures from Mars?</question>
  690. +    <answer>Viking</answer>
  691. +  </trivia>
  692. +
  693. +  <trivia>
  694. +    <question>Who was the second Soviet cosmonaut?</question>
  695. +    <answer>Titov</answer>
  696. +  </trivia>
  697. +
  698. +  <trivia>
  699. +    <question>Who said, &quot;All I need to make a comedy is a park, a policeman and a pretty girl?&quot;</question>
  700. +    <answer>Charlie Chaplin</answer>
  701. +  </trivia>
  702. +
  703. +  <trivia>
  704. +    <question>In which country did Steve McQueen die?</question>
  705. +    <answer>Mexico</answer>
  706. +  </trivia>
  707. +
  708. +  <trivia>
  709. +    <question>In 1998 who did Vanity Fair describe as &quot;simply the world's biggest heart throb?&quot;</question>
  710. +    <answer>Leonardo DiCaprio</answer>
  711. +  </trivia>
  712. +
  713. +  <trivia>
  714. +    <question>In 1998 who did Vanity Fair describe as &quot;simply the world's biggest heart throb?&quot;</question>
  715. +    <answer>Leonardo DiCaprio</answer>
  716. +  </trivia>
  717. +
  718. +  <trivia>
  719. +    <question>How many friends are there in Friends?</question>
  720. +    <answer>Six</answer>
  721. +  </trivia>
  722. +
  723. +  <trivia>
  724. +    <question>In which magazine did The Addams Family first appear?</question>
  725. +    <answer>New Yorker</answer>
  726. +  </trivia>
  727. +
  728. +  <trivia>
  729. +    <question>What is Alpha World?</question>
  730. +    <answer>Multi user game</answer>
  731. +  </trivia>
  732. +
  733. +  <trivia>
  734. +    <question>What is a MUD?</question>
  735. +    <answer>Multi User Computer Game</answer>
  736. +  </trivia>
  737. +
  738. +  <trivia>
  739. +    <question>In which European country is the theme park De Efteling?</question>
  740. +    <answer>The Netherlands</answer>
  741. +  </trivia>
  742. +
  743. +  <trivia>
  744. +    <question>Which ethnic group popularized salsa dancing in New York in the 1980s?</question>
  745. +    <answer>Puerto Ricans</answer>
  746. +  </trivia>
  747. +
  748. +  <trivia>
  749. +    <question>Which Russian city was famous for its State Circus?</question>
  750. +    <answer>Moscow</answer>
  751. +  </trivia>
  752. +
  753. +  <trivia>
  754. +    <question>Pokemon is an abbreviation of what?</question>
  755. +    <answer>Pocket Monster</answer>
  756. +  </trivia>
  757. +
  758. +  <trivia>
  759. +    <question>Who is the Princess in the Super Mario Gang?</question>
  760. +    <answer>Daisy</answer>
  761. +  </trivia>
  762. +
  763. +  <trivia>
  764. +    <question>What is russian's favourite gambling game?</question>
  765. +    <answer>Russian Roulette</answer>
  766. +  </trivia>
  767. +
  768. +
  769. +  <trivia>
  770. +    <question>What is russian's favourite drink?</question>
  771. +    <answer>Vodka</answer>
  772. +  </trivia>
  773. +
  774. +  <trivia>
  775. +    <question>What is the quest item used to make a level 5 clan</question>
  776. +    <answer>Seal of aspiration</answer>
  777. +  </trivia>
  778. +
  779. +</event>
  780. \ No newline at end of file
  781. Index: build.xml
  782. ===================================================================
  783. --- build.xml   (revision 5)
  784. +++ build.xml   (working copy)
  785. @@ -99,6 +99,7 @@
  786.         <copy todir="${build.dist.game}/config">
  787.             <fileset dir="config">
  788.                 <include name="*.properties" />
  789. +               <include name="*.xml" />
  790.                 <exclude name="loginserver.properties" />
  791.             </fileset>
  792.             <fileset dir="config">
  793. Index: config/events.properties
  794. ===================================================================
  795. --- config/events.properties    (revision 5)
  796. +++ config/events.properties    (working copy)
  797. @@ -256,3 +256,19 @@
  798.  AltFishChampionshipReward3 = 300000
  799.  AltFishChampionshipReward4 = 200000
  800.  AltFishChampionshipReward5 = 100000
  801. +
  802. +#Trivia event will occur those times
  803. +#Default = 22:00,22:15,22:30
  804. +TriviaInterval = 21:40,22:40,22:45,22:50,23:40
  805. +
  806. +#Time allowed to answer a question in seconds
  807. +#Default = 30
  808. +TriviaAnswerTime = 60
  809. +
  810. +#Trivia event enabled?
  811. +#Default = True
  812. +TriviaEnabled = True
  813. +
  814. +#Each event will have a number of questions.Decide how many to ask
  815. +#Default = 1
  816. +TriviaAsk = 1
  817. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java
  818. ===================================================================
  819. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java   (revision 5)
  820. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java   (working copy)
  821. @@ -18,6 +18,7 @@
  822.  import net.sf.l2j.gameserver.model.BlockList;
  823.  import net.sf.l2j.gameserver.model.L2World;
  824.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  825. +import net.sf.l2j.gameserver.model.entity.Trivia;
  826.  import net.sf.l2j.gameserver.network.SystemMessageId;
  827.  import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  828.  
  829. @@ -39,10 +40,30 @@
  830.     @Override
  831.     public void handleChat(int type, L2PcInstance activeChar, String target, String text)
  832.     {
  833. +          
  834.         // Return if no target is set.
  835.         if (target == null)
  836.             return;
  837.        
  838. +       if(target.equalsIgnoreCase("trivia"))
  839. +       {
  840. +           if(Trivia.isInactive())
  841. +           {
  842. +               activeChar.sendMessage("Trivia event is not currently running.");
  843. +               return;
  844. +           }
  845. +           else if(!Trivia.isAnswering() || Trivia.isCorrect() || Trivia.isRewarding())
  846. +           {
  847. +               activeChar.sendMessage("You cannot answer now.");
  848. +               return;
  849. +           }
  850. +           else
  851. +           {
  852. +               Trivia.handleAnswer(text,activeChar);
  853. +               return;
  854. +           }
  855. +       }
  856. +      
  857.         final L2PcInstance receiver = L2World.getInstance().getPlayer(target);
  858.         if (receiver != null)
  859.         {
  860. Index: java/net/sf/l2j/Config.java
  861. ===================================================================
  862. --- java/net/sf/l2j/Config.java (revision 35)
  863. +++ java/net/sf/l2j/Config.java (working copy)
  864. @@ -18,8 +18,10 @@
  865.  import gnu.trove.map.hash.TIntObjectHashMap;
  866.  
  867.  import java.io.File;
  868. +import java.io.FileInputStream;
  869.  import java.io.FileOutputStream;
  870.  import java.io.IOException;
  871. +import java.io.InputStream;
  872.  import java.io.OutputStream;
  873.  import java.math.BigInteger;
  874.  import java.util.ArrayList;
  875. @@ -57,6 +59,8 @@
  876.     public static final String SIEGE_FILE = "./config/siege.properties";
  877.     public static final String ELFOCRASH_FILE = "./config/elfocrash.properties";
  878.    
  879. +
  880. +    
  881.     // --------------------------------------------------
  882.     // Clans settings
  883.     // --------------------------------------------------
  884. @@ -139,6 +143,13 @@
  885.     // Events settings
  886.     // --------------------------------------------------
  887.    
  888. +  
  889. +
  890. +    public static ArrayList<String>TRIVIA_INTERVAL = new ArrayList<String>();
  891. +    public static int TRIVIA_ANSWER_TIME;
  892. +    public static boolean TRIVIA_ENABLED;
  893. +    public static int TRIVIA_TO_ASK;
  894. +    
  895.     /** Olympiad */
  896.     public static int ALT_OLY_START_TIME;
  897.     public static int ALT_OLY_MIN;
  898. @@ -839,6 +850,13 @@
  899.            
  900.             // Events config
  901.             ExProperties events = load(EVENTS_FILE);
  902. +           String [] times=events.getProperty("TriviaInterval", "22:00,22:15,:22:30").split(",");
  903. +           TRIVIA_INTERVAL = new ArrayList<String>();
  904. +           for(String t:times)
  905. +               TRIVIA_INTERVAL.add(t);
  906. +           TRIVIA_ANSWER_TIME = Integer.parseInt(events.getProperty("TriviaAnswerTime", "30"));
  907. +           TRIVIA_ENABLED = Boolean.parseBoolean(events.getProperty("TriviaEnabled", "true"));
  908. +           TRIVIA_TO_ASK = Integer.parseInt(events.getProperty("TriviaAsk", "1"));
  909.             ALT_OLY_START_TIME = events.getProperty("AltOlyStartTime", 18);
  910.             ALT_OLY_MIN = events.getProperty("AltOlyMin", 0);
  911.             ALT_OLY_CPERIOD = events.getProperty("AltOlyCPeriod", 21600000);
Add Comment
Please, Sign In to add comment