Guest User

Untitled

a guest
Mar 13th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.97 KB | None | 0 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.l2jfrozen.gameserver.model.entity.event;
  16.  
  17. import java.sql.PreparedStatement;
  18. import java.sql.ResultSet;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. import java.util.Vector;
  22.  
  23. import javolution.text.TextBuilder;
  24.  
  25. import org.slf4j.Logger;
  26. import org.slf4j.LoggerFactory;
  27.  
  28. import com.l2jfrozen.Config;
  29. import com.l2jfrozen.gameserver.datatables.SkillTable;
  30. import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable;
  31. import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
  32. import com.l2jfrozen.gameserver.managers.CastleManager;
  33. import com.l2jfrozen.gameserver.model.L2Character;
  34. import com.l2jfrozen.gameserver.model.L2Party;
  35. import com.l2jfrozen.gameserver.model.L2Summon;
  36. import com.l2jfrozen.gameserver.model.L2World;
  37. import com.l2jfrozen.gameserver.model.Location;
  38. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  39. import com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance;
  40. import com.l2jfrozen.gameserver.model.base.ClassId;
  41. import com.l2jfrozen.gameserver.model.entity.Announcements;
  42. import com.l2jfrozen.gameserver.model.entity.event.manager.EventTask;
  43. import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  44. import com.l2jfrozen.gameserver.model.entity.siege.Castle;
  45. import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  46. import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  47. import com.l2jfrozen.gameserver.network.serverpackets.Ride;
  48. import com.l2jfrozen.gameserver.network.serverpackets.StatusUpdate;
  49. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  50. import com.l2jfrozen.util.CloseUtil;
  51. import com.l2jfrozen.util.database.L2DatabaseFactory;
  52. import com.l2jfrozen.util.random.Rnd;
  53.  
  54. /**
  55. * The Class DM.
  56. */
  57. public class DM implements EventTask
  58. {
  59.  
  60. /** The Constant LOGGER. */
  61. protected static final Logger LOGGER = LoggerFactory.getLogger(DM.class.getName());
  62.  
  63. /** The _joining location name. */
  64. private static String _eventName = new String(), _eventDesc = new String(), _joiningLocationName = new String();
  65.  
  66. /** The _in progress. */
  67. public static boolean _joining = false, _teleport = false, _started = false, _aborted = false, _sitForced = false, _inProgress = false, _isEventMobDM = false;
  68.  
  69. /** The _player z. */
  70. protected static int _npcId = 0, _npcX = 0, _npcY = 0, _npcZ = 0, _npcHeading = 0, _rewardId = 0, _rewardAmount = 0, _minlvl = 0, _maxlvl = 0, _joinTime = 0, _eventTime = 0, _minPlayers = 0, _maxPlayers = 0, _topKills = 0, _playerColors = 0, _playerX = 0, _playerY = 0, _playerZ = 0;
  71.  
  72. /** The _interval between matchs. */
  73. private static long _intervalBetweenMatchs = 0;
  74.  
  75. /** The start event time. */
  76. private String startEventTime;
  77.  
  78. /** The _team event. */
  79. protected static boolean _teamEvent = false; // TODO to be integrated
  80.  
  81. /** The _players. */
  82. public static Vector<L2PcInstance> _players = new Vector<L2PcInstance>();
  83.  
  84. /** The _top players. */
  85. public static List<L2PcInstance> _topPlayers = new ArrayList<L2PcInstance>();
  86.  
  87. /** The _save players. */
  88. public static Vector<String> _savePlayers = new Vector<String>();
  89.  
  90. /**
  91. * Instantiates a new dM.
  92. */
  93. private DM()
  94. {
  95. }
  96.  
  97. /**
  98. * Gets the new instance.
  99. * @return the new instance
  100. */
  101. public static DM getNewInstance()
  102. {
  103. return new DM();
  104. }
  105.  
  106. /**
  107. * Gets the _event name.
  108. * @return the _eventName
  109. */
  110. public static String get_eventName()
  111. {
  112. return _eventName;
  113. }
  114.  
  115. /**
  116. * Set_event name.
  117. * @param _eventName the _eventName to set
  118. * @return true, if successful
  119. */
  120. public static boolean set_eventName(String _eventName)
  121. {
  122. if (!is_inProgress())
  123. {
  124. DM._eventName = _eventName;
  125. return true;
  126. }
  127. return false;
  128. }
  129.  
  130. /**
  131. * Gets the _event desc.
  132. * @return the _eventDesc
  133. */
  134. public static String get_eventDesc()
  135. {
  136. return _eventDesc;
  137. }
  138.  
  139. /**
  140. * Set_event desc.
  141. * @param _eventDesc the _eventDesc to set
  142. * @return true, if successful
  143. */
  144. public static boolean set_eventDesc(String _eventDesc)
  145. {
  146. if (!is_inProgress())
  147. {
  148. DM._eventDesc = _eventDesc;
  149. return true;
  150. }
  151. return false;
  152. }
  153.  
  154. /**
  155. * Gets the _joining location name.
  156. * @return the _joiningLocationName
  157. */
  158. public static String get_joiningLocationName()
  159. {
  160. return _joiningLocationName;
  161. }
  162.  
  163. /**
  164. * Set_joining location name.
  165. * @param _joiningLocationName the _joiningLocationName to set
  166. * @return true, if successful
  167. */
  168. public static boolean set_joiningLocationName(String _joiningLocationName)
  169. {
  170. if (!is_inProgress())
  171. {
  172. DM._joiningLocationName = _joiningLocationName;
  173. return true;
  174. }
  175. return false;
  176. }
  177.  
  178. /**
  179. * Gets the _npc id.
  180. * @return the _npcId
  181. */
  182. public static int get_npcId()
  183. {
  184. return _npcId;
  185. }
  186.  
  187. /**
  188. * Set_npc id.
  189. * @param _npcId the _npcId to set
  190. * @return true, if successful
  191. */
  192. public static boolean set_npcId(int _npcId)
  193. {
  194. if (!is_inProgress())
  195. {
  196. DM._npcId = _npcId;
  197. return true;
  198. }
  199. return false;
  200. }
  201.  
  202. /**
  203. * Gets the _npc location.
  204. * @return the _npc location
  205. */
  206. public static Location get_npcLocation()
  207. {
  208. Location npc_loc = new Location(_npcX, _npcY, _npcZ, _npcHeading);
  209.  
  210. return npc_loc;
  211. }
  212.  
  213. /**
  214. * Gets the _reward id.
  215. * @return the _rewardId
  216. */
  217. public static int get_rewardId()
  218. {
  219. return _rewardId;
  220. }
  221.  
  222. /**
  223. * Set_reward id.
  224. * @param _rewardId the _rewardId to set
  225. * @return true, if successful
  226. */
  227. public static boolean set_rewardId(int _rewardId)
  228. {
  229. if (!is_inProgress())
  230. {
  231. DM._rewardId = _rewardId;
  232. return true;
  233. }
  234. return false;
  235. }
  236.  
  237. /**
  238. * Gets the _reward amount.
  239. * @return the _rewardAmount
  240. */
  241. public static int get_rewardAmount()
  242. {
  243. return _rewardAmount;
  244. }
  245.  
  246. /**
  247. * Set_reward amount.
  248. * @param _rewardAmount the _rewardAmount to set
  249. * @return true, if successful
  250. */
  251. public static boolean set_rewardAmount(int _rewardAmount)
  252. {
  253. if (!is_inProgress())
  254. {
  255. DM._rewardAmount = _rewardAmount;
  256. return true;
  257. }
  258. return false;
  259. }
  260.  
  261. /**
  262. * Gets the _minlvl.
  263. * @return the _minlvl
  264. */
  265. public static int get_minlvl()
  266. {
  267. return _minlvl;
  268. }
  269.  
  270. /**
  271. * Set_minlvl.
  272. * @param _minlvl the _minlvl to set
  273. * @return true, if successful
  274. */
  275. public static boolean set_minlvl(int _minlvl)
  276. {
  277. if (!is_inProgress())
  278. {
  279. DM._minlvl = _minlvl;
  280. return true;
  281. }
  282. return false;
  283. }
  284.  
  285. /**
  286. * Gets the _maxlvl.
  287. * @return the _maxlvl
  288. */
  289. public static int get_maxlvl()
  290. {
  291. return _maxlvl;
  292. }
  293.  
  294. /**
  295. * Set_maxlvl.
  296. * @param _maxlvl the _maxlvl to set
  297. * @return true, if successful
  298. */
  299. public static boolean set_maxlvl(int _maxlvl)
  300. {
  301. if (!is_inProgress())
  302. {
  303. DM._maxlvl = _maxlvl;
  304. return true;
  305. }
  306. return false;
  307. }
  308.  
  309. /**
  310. * Gets the _join time.
  311. * @return the _joinTime
  312. */
  313. public static int get_joinTime()
  314. {
  315. return _joinTime;
  316. }
  317.  
  318. /**
  319. * Set_join time.
  320. * @param _joinTime the _joinTime to set
  321. * @return true, if successful
  322. */
  323. public static boolean set_joinTime(int _joinTime)
  324. {
  325. if (!is_inProgress())
  326. {
  327. DM._joinTime = _joinTime;
  328. return true;
  329. }
  330. return false;
  331. }
  332.  
  333. /**
  334. * Gets the _event time.
  335. * @return the _eventTime
  336. */
  337. public static int get_eventTime()
  338. {
  339. return _eventTime;
  340. }
  341.  
  342. /**
  343. * Set_event time.
  344. * @param _eventTime the _eventTime to set
  345. * @return true, if successful
  346. */
  347. public static boolean set_eventTime(int _eventTime)
  348. {
  349. if (!is_inProgress())
  350. {
  351. DM._eventTime = _eventTime;
  352. return true;
  353. }
  354. return false;
  355. }
  356.  
  357. /**
  358. * Gets the _min players.
  359. * @return the _minPlayers
  360. */
  361. public static int get_minPlayers()
  362. {
  363. return _minPlayers;
  364. }
  365.  
  366. /**
  367. * Set_min players.
  368. * @param _minPlayers the _minPlayers to set
  369. * @return true, if successful
  370. */
  371. public static boolean set_minPlayers(int _minPlayers)
  372. {
  373. if (!is_inProgress())
  374. {
  375. DM._minPlayers = _minPlayers;
  376. return true;
  377. }
  378. return false;
  379. }
  380.  
  381. /**
  382. * Gets the _max players.
  383. * @return the _maxPlayers
  384. */
  385. public static int get_maxPlayers()
  386. {
  387. return _maxPlayers;
  388. }
  389.  
  390. /**
  391. * Set_max players.
  392. * @param _maxPlayers the _maxPlayers to set
  393. * @return true, if successful
  394. */
  395. public static boolean set_maxPlayers(int _maxPlayers)
  396. {
  397. if (!is_inProgress())
  398. {
  399. DM._maxPlayers = _maxPlayers;
  400. return true;
  401. }
  402. return false;
  403. }
  404.  
  405. /**
  406. * Gets the _interval between matchs.
  407. * @return the _intervalBetweenMatchs
  408. */
  409. public static long get_intervalBetweenMatchs()
  410. {
  411. return _intervalBetweenMatchs;
  412. }
  413.  
  414. /**
  415. * Set_interval between matchs.
  416. * @param _intervalBetweenMatchs the _intervalBetweenMatchs to set
  417. * @return true, if successful
  418. */
  419. public static boolean set_intervalBetweenMatchs(long _intervalBetweenMatchs)
  420. {
  421. if (!is_inProgress())
  422. {
  423. DM._intervalBetweenMatchs = _intervalBetweenMatchs;
  424. return true;
  425. }
  426. return false;
  427. }
  428.  
  429. /**
  430. * Gets the start event time.
  431. * @return the startEventTime
  432. */
  433. public String getStartEventTime()
  434. {
  435. return startEventTime;
  436. }
  437.  
  438. /**
  439. * Sets the start event time.
  440. * @param startEventTime the startEventTime to set
  441. * @return true, if successful
  442. */
  443. public boolean setStartEventTime(String startEventTime)
  444. {
  445. if (!is_inProgress())
  446. {
  447. this.startEventTime = startEventTime;
  448. return true;
  449. }
  450. return false;
  451. }
  452.  
  453. /**
  454. * Checks if is _joining.
  455. * @return the _joining
  456. */
  457. public static boolean is_joining()
  458. {
  459. return _joining;
  460. }
  461.  
  462. /**
  463. * Checks if is _teleport.
  464. * @return the _teleport
  465. */
  466. public static boolean is_teleport()
  467. {
  468. return _teleport;
  469. }
  470.  
  471. /**
  472. * Checks if is _started.
  473. * @return the _started
  474. */
  475. public static boolean is_started()
  476. {
  477. return _started;
  478. }
  479.  
  480. /**
  481. * Checks if is _aborted.
  482. * @return the _aborted
  483. */
  484. public static boolean is_aborted()
  485. {
  486. return _aborted;
  487. }
  488.  
  489. /**
  490. * Checks if is _sit forced.
  491. * @return the _sitForced
  492. */
  493. public static boolean is_sitForced()
  494. {
  495. return _sitForced;
  496. }
  497.  
  498. /**
  499. * Checks if is _in progress.
  500. * @return the _inProgress
  501. */
  502. public static boolean is_inProgress()
  503. {
  504. return _inProgress;
  505. }
  506.  
  507. /**
  508. * Check max level.
  509. * @param maxlvl the maxlvl
  510. * @return true, if successful
  511. */
  512. public static boolean checkMaxLevel(int maxlvl)
  513. {
  514. if (_minlvl >= maxlvl)
  515. return false;
  516.  
  517. return true;
  518. }
  519.  
  520. /**
  521. * Check min level.
  522. * @param minlvl the minlvl
  523. * @return true, if successful
  524. */
  525. public static boolean checkMinLevel(int minlvl)
  526. {
  527. if (_maxlvl <= minlvl)
  528. return false;
  529.  
  530. return true;
  531. }
  532.  
  533. /**
  534. * returns true if participated players is higher or equal then minimum needed players.
  535. * @param players the players
  536. * @return true, if successful
  537. */
  538. public static boolean checkMinPlayers(int players)
  539. {
  540. if (_minPlayers <= players)
  541. return true;
  542.  
  543. return false;
  544. }
  545.  
  546. /**
  547. * returns true if max players is higher or equal then participated players.
  548. * @param players the players
  549. * @return true, if successful
  550. */
  551. public static boolean checkMaxPlayers(int players)
  552. {
  553. if (_maxPlayers > players)
  554. return true;
  555.  
  556. return false;
  557. }
  558.  
  559. /**
  560. * Check start join ok.
  561. * @return true, if successful
  562. */
  563. public static boolean checkStartJoinOk()
  564. {
  565. if (_started || _teleport || _joining || _eventName.equals("") || _joiningLocationName.equals("") || _eventDesc.equals("") || _npcId == 0 || _npcX == 0 || _npcY == 0 || _npcZ == 0 || _rewardId == 0 || _rewardAmount == 0)
  566. return false;
  567.  
  568. if (_teamEvent)
  569. {
  570. if (!checkStartJoinTeamInfo())
  571. return false;
  572. }
  573. else
  574. {
  575. if (!checkStartJoinPlayerInfo())
  576. return false;
  577. }
  578.  
  579. if (!Config.ALLOW_EVENTS_DURING_OLY && Olympiad.getInstance().inCompPeriod())
  580. return false;
  581.  
  582. for (Castle castle : CastleManager.getInstance().getCastles())
  583. {
  584. if (castle != null && castle.getSiege() != null && castle.getSiege().getIsInProgress())
  585. return false;
  586. }
  587.  
  588. if (!checkOptionalEventStartJoinOk())
  589. return false;
  590.  
  591. return true;
  592. }
  593.  
  594. /**
  595. * Check start join team info.
  596. * @return true, if successful
  597. */
  598. private static boolean checkStartJoinTeamInfo()
  599. {
  600. // TODO be integrated
  601. return true;
  602. }
  603.  
  604. /**
  605. * Check start join player info.
  606. * @return true, if successful
  607. */
  608. private static boolean checkStartJoinPlayerInfo()
  609. {
  610. if (_playerX == 0 || _playerY == 0 || _playerZ == 0 || _playerColors == 0)
  611. {
  612. return false;
  613. }
  614.  
  615. return true;
  616. }
  617.  
  618. /**
  619. * Check auto event start join ok.
  620. * @return true, if successful
  621. */
  622. private static boolean checkAutoEventStartJoinOk()
  623. {
  624. if (_joinTime == 0 || _eventTime == 0)
  625. {
  626. return false;
  627. }
  628.  
  629. return true;
  630. }
  631.  
  632. /**
  633. * Check optional event start join ok.
  634. * @return true, if successful
  635. */
  636. private static boolean checkOptionalEventStartJoinOk()
  637. {
  638. // TODO be integrated
  639. return true;
  640. }
  641.  
  642. /**
  643. * Sets the npc pos.
  644. * @param activeChar the new npc pos
  645. */
  646. public static void setNpcPos(L2PcInstance activeChar)
  647. {
  648. _npcX = activeChar.getX();
  649. _npcY = activeChar.getY();
  650. _npcZ = activeChar.getZ();
  651. _npcHeading = activeChar.getHeading();
  652. }
  653.  
  654. /**
  655. * Start join.
  656. * @return true, if successful
  657. */
  658. public static boolean startJoin()
  659. {
  660. if (!checkStartJoinOk())
  661. {
  662. if (Config.DEBUG)
  663. LOGGER.info( _eventName + " Engine[startJoin]: startJoinOk() = false");
  664. return false;
  665. }
  666. removeNoneParticipantsInZone();
  667. _inProgress = true;
  668. _joining = true;
  669. _isEventMobDM = true;
  670. Announcements.getInstance().gameAnnounceToAll(_eventName + " Event");
  671. if (Config.DM_ANNOUNCE_REWARD && ItemTable.getInstance().getTemplate(_rewardId) != null)
  672. Announcements.getInstance().gameAnnounceToAll("Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
  673. Announcements.getInstance().gameAnnounceToAll("DM: Recruiting levels: " + _minlvl + " to " + _maxlvl);
  674. Announcements.getInstance().gameAnnounceToAll("DM: Joinable in " + _joiningLocationName);
  675.  
  676. if (Config.DM_COMMAND)
  677. Announcements.getInstance().gameAnnounceToAll(" or by command .dmjoin! To leave .dmleave! For Info .dminfo!");
  678. return true;
  679. }
  680.  
  681. /**
  682. * Start teleport.
  683. * @return true, if successful
  684. */
  685. public static boolean startTeleport()
  686. {
  687. if (!_joining || _started || _teleport)
  688. return false;
  689.  
  690. removeOfflinePlayers();
  691.  
  692. if (_teamEvent)
  693. {
  694. /*
  695. * if(Config.EVEN_TEAMS.equals("SHUFFLE") && checkMinPlayers(_playersShuffle.size())) { shuffleTeams(); } else if(Config.EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size())) {
  696. * Announcements.getInstance().gameAnnounceToAll("Not enough players for event. Min Requested : " + _minPlayers +", Participating : " + _playersShuffle.size()); return false; }
  697. */
  698. }
  699. else
  700. {
  701. // final int size = getPlayers().size();
  702. synchronized (_players)
  703. {
  704. final int size = _players.size();
  705. if (!checkMinPlayers(size))
  706. {
  707. Announcements.getInstance().gameAnnounceToAll("DM: Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + size);
  708. if (Config.DM_STATS_LOGGER)
  709. LOGGER.info(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + size);
  710.  
  711. return false;
  712. }
  713. }
  714. }
  715.  
  716. _joining = false;
  717. Announcements.getInstance().gameAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
  718.  
  719. setUserData();
  720. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  721. {
  722. @Override
  723. public void run()
  724. {
  725. sit();
  726. afterTeleportOperations();
  727.  
  728. // final Vector<L2PcInstance> players = getPlayers();
  729. synchronized (_players)
  730. {
  731.  
  732. for (final L2PcInstance player : _players)
  733. {
  734. if (player != null)
  735. {
  736. if (Config.DM_ON_START_UNSUMMON_PET)
  737. {
  738. // Remove Summon's buffs
  739. if (player.getPet() != null)
  740. {
  741. L2Summon summon = player.getPet();
  742. summon.stopAllEffects();
  743.  
  744. if (summon instanceof L2PetInstance)
  745. summon.unSummon(player);
  746. }
  747. }
  748.  
  749. if (Config.DM_ON_START_REMOVE_ALL_EFFECTS)
  750. {
  751. player.stopAllEffects();
  752.  
  753. }
  754.  
  755. // Remove player from his party
  756. if (player.getParty() != null)
  757. {
  758. L2Party party = player.getParty();
  759. party.removePartyMember(player);
  760. }
  761.  
  762. // player._originalTitleDM = player.getTitle();
  763. // player.setTitle("Kills: " + player._countDMkills);
  764.  
  765. if (_teamEvent)
  766. {
  767. // player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
  768.  
  769. }
  770. else
  771. {
  772. int offset = Config.DM_SPAWN_OFFSET;
  773. player.teleToLocation(_playerX + Rnd.get(offset), _playerY + Rnd.get(offset), _playerZ);
  774. }
  775. }
  776. }
  777.  
  778. }
  779.  
  780. }
  781. }, 20000);
  782. _teleport = true;
  783. return true;
  784. }
  785.  
  786. /**
  787. * After teleport operations.
  788. */
  789. protected static void afterTeleportOperations()
  790. {
  791.  
  792. }
  793.  
  794. /**
  795. * Start event.
  796. * @return true, if successful
  797. */
  798. public static boolean startEvent()
  799. {
  800. if (!startEventOk())
  801. {
  802. if (Config.DEBUG)
  803. LOGGER.info( _eventName + " Engine[startEvent()]: startEventOk() = false");
  804. return false;
  805. }
  806.  
  807. _teleport = false;
  808.  
  809. sit();
  810. removeParties();
  811.  
  812. afterStartOperations();
  813.  
  814. Announcements.getInstance().gameAnnounceToAll(_eventName + ": Started. Go kill your enemies!");
  815. _started = true;
  816.  
  817. return true;
  818. }
  819.  
  820. /**
  821. * Removes the parties.
  822. */
  823. private static void removeParties()
  824. {
  825. // final Vector<L2PcInstance> players = getPlayers();
  826. synchronized (_players)
  827. {
  828.  
  829. for (final L2PcInstance player : _players)
  830. {
  831. if (player.getParty() != null)
  832. {
  833. L2Party party = player.getParty();
  834. party.removePartyMember(player);
  835. }
  836. }
  837. }
  838. }
  839.  
  840. /**
  841. * After start operations.
  842. */
  843. private static void afterStartOperations()
  844. {
  845.  
  846. }
  847.  
  848. /**
  849. * Restarts Event checks if event was aborted. and if true cancels restart task
  850. */
  851. public synchronized static void restartEvent()
  852. {
  853. LOGGER.info(_eventName + ": Event has been restarted...");
  854. _joining = false;
  855. _started = false;
  856. _inProgress = false;
  857. _aborted = false;
  858. long delay = _intervalBetweenMatchs;
  859.  
  860. Announcements.getInstance().gameAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatchs + " minute(s)!");
  861.  
  862. waiter(delay);
  863.  
  864. try
  865. {
  866. if (!_aborted)
  867. autoEvent(); // start a new event
  868. else
  869. Announcements.getInstance().gameAnnounceToAll(_eventName + ": next event aborted!");
  870. }
  871. catch (Exception e)
  872. {
  873. LOGGER.info( _eventName + ": Error While Trying to restart Event...", e);
  874. e.printStackTrace();
  875. }
  876. }
  877.  
  878. /**
  879. * Finish event.
  880. */
  881. public static void finishEvent()
  882. {
  883. if (!finishEventOk())
  884. {
  885. if (Config.DEBUG)
  886. LOGGER.info( _eventName + " Engine[finishEvent]: finishEventOk() = false");
  887. return;
  888. }
  889.  
  890. _started = false;
  891. _aborted = false;
  892. _isEventMobDM = false;
  893.  
  894. afterFinishOperations();
  895.  
  896. if (_teamEvent)
  897. {
  898. processTopTeam();
  899. }
  900. else
  901. {
  902. processTopPlayer();
  903.  
  904. if (_topKills != 0)
  905. {
  906. String winners = "";
  907. for (L2PcInstance winner : _topPlayers)
  908. {
  909. winners = winners + " " + winner.getName();
  910. }
  911. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + winners + " win the match! " + _topKills + " kills.");
  912. rewardPlayer();
  913.  
  914. if (Config.DM_STATS_LOGGER)
  915. {
  916. LOGGER.info("**** " + _eventName + " ****");
  917. LOGGER.info(_eventName + ": " + winners + " win the match! " + _topKills + " kills.");
  918. }
  919. }
  920. else
  921. {
  922.  
  923. Announcements.getInstance().gameAnnounceToAll(_eventName + ": No players win the match(nobody killed).");
  924. if (Config.DM_STATS_LOGGER)
  925. LOGGER.info(_eventName + ": No players win the match(nobody killed).");
  926. }
  927. }
  928.  
  929. teleportFinish();
  930. }
  931.  
  932. /**
  933. * After finish operations.
  934. */
  935. private static void afterFinishOperations()
  936. {
  937.  
  938. }
  939.  
  940. /**
  941. * Abort event.
  942. */
  943. public static void abortEvent()
  944. {
  945. if (!_joining && !_teleport && !_started)
  946. return;
  947.  
  948. if (_joining && !_teleport && !_started)
  949. {
  950. cleanDM();
  951. _isEventMobDM = false;
  952. _joining = false;
  953. _inProgress = false;
  954. Announcements.getInstance().gameAnnounceToAll(_eventName + ": Match aborted!");
  955. return;
  956. }
  957. _joining = false;
  958. _teleport = false;
  959. _started = false;
  960. _aborted = true;
  961. _isEventMobDM = false;
  962.  
  963. afterFinish();
  964.  
  965. Announcements.getInstance().gameAnnounceToAll(_eventName + ": Match aborted!");
  966. teleportFinish();
  967. }
  968.  
  969. /**
  970. * After finish.
  971. */
  972. private static void afterFinish()
  973. {
  974.  
  975. }
  976.  
  977. /**
  978. * Teleport finish.
  979. */
  980. public static void teleportFinish()
  981. {
  982. sit();
  983.  
  984. Announcements.getInstance().gameAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
  985.  
  986. removeUserData();
  987. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  988. {
  989. @Override
  990. public void run()
  991. {
  992. // final Vector<L2PcInstance> players = getPlayers();
  993. synchronized (_players)
  994. {
  995.  
  996. for (final L2PcInstance player : _players)
  997. {
  998. if (player != null)
  999. {
  1000. if (player.isOnline() != 0)
  1001. player.teleToLocation(_npcX, _npcY, _npcZ, false);
  1002. else
  1003. {
  1004. java.sql.Connection con = null;
  1005. try
  1006. {
  1007. con = L2DatabaseFactory.getInstance().getConnection(false);
  1008.  
  1009. PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
  1010. statement.setInt(1, _npcX);
  1011. statement.setInt(2, _npcY);
  1012. statement.setInt(3, _npcZ);
  1013. statement.setString(4, player.getName());
  1014. statement.execute();
  1015. statement.close();
  1016. }
  1017. catch (Exception e) {
  1018. LOGGER.error("", e);
  1019.  
  1020. LOGGER.info(e.getMessage(), e);
  1021. }
  1022. finally
  1023. {
  1024. CloseUtil.close(con);
  1025. con = null;
  1026. }
  1027. }
  1028. }
  1029. }
  1030.  
  1031. }
  1032.  
  1033. sit();
  1034. cleanDM();
  1035. }
  1036. }, 20000);
  1037. }
  1038.  
  1039. /**
  1040. * Auto event.
  1041. */
  1042. public static void autoEvent()
  1043. {
  1044. LOGGER.info("Starting " + _eventName + "!");
  1045. LOGGER.info("Matchs Are Restarted At Every: " + getIntervalBetweenMatchs() + " Minutes.");
  1046. if (checkAutoEventStartJoinOk() && startJoin() && !_aborted)
  1047. {
  1048. if (_joinTime > 0)
  1049. waiter(_joinTime * 60 * 1000); // minutes for join event
  1050. else if (_joinTime <= 0)
  1051. {
  1052. LOGGER.info(_eventName + ": join time <=0 aborting event.");
  1053. abortEvent();
  1054. return;
  1055. }
  1056. if (startTeleport() && !_aborted)
  1057. {
  1058. waiter(30 * 1000); // 30 sec wait time untill start fight after teleported
  1059. if (startEvent() && !_aborted)
  1060. {
  1061. LOGGER.info( _eventName + ": waiting.....minutes for event time " + _eventTime);
  1062.  
  1063. waiter(_eventTime * 60 * 1000); // minutes for event time
  1064. finishEvent();
  1065.  
  1066. LOGGER.info(_eventName + ": waiting... delay for final messages ");
  1067. waiter(60000);// just a give a delay delay for final messages
  1068. sendFinalMessages();
  1069.  
  1070. if (!_started && !_aborted)
  1071. { // if is not already started and it's not aborted
  1072.  
  1073. LOGGER.info(_eventName + ": waiting.....delay for restart event " + _intervalBetweenMatchs + " minutes.");
  1074. waiter(60000);// just a give a delay to next restart
  1075.  
  1076. try
  1077. {
  1078. if (!_aborted)
  1079. restartEvent();
  1080. }
  1081. catch (Exception e)
  1082. {
  1083. LOGGER.info( "Error while tying to Restart Event", e);
  1084. e.printStackTrace();
  1085. }
  1086.  
  1087. }
  1088.  
  1089. }
  1090. }
  1091. else if (!_aborted)
  1092. {
  1093.  
  1094. abortEvent();
  1095. restartEvent();
  1096.  
  1097. }
  1098. }
  1099. }
  1100.  
  1101. // start without restart
  1102. /**
  1103. * Event once start.
  1104. */
  1105. public static void eventOnceStart()
  1106. {
  1107. if (startJoin() && !_aborted)
  1108. {
  1109. if (_joinTime > 0)
  1110. waiter(_joinTime * 60 * 1000); // minutes for join event
  1111. else if (_joinTime <= 0)
  1112. {
  1113. abortEvent();
  1114. return;
  1115. }
  1116. if (startTeleport() && !_aborted)
  1117. {
  1118. waiter(1 * 60 * 1000); // 1 min wait time untill start fight after teleported
  1119. if (startEvent() && !_aborted)
  1120. {
  1121. waiter(_eventTime * 60 * 1000); // minutes for event time
  1122. finishEvent();
  1123. }
  1124. }
  1125. else if (!_aborted)
  1126. {
  1127. abortEvent();
  1128. }
  1129. }
  1130. }
  1131.  
  1132. /**
  1133. * Waiter.
  1134. * @param interval the interval
  1135. */
  1136. private static void waiter(long interval)
  1137. {
  1138. long startWaiterTime = System.currentTimeMillis();
  1139. int seconds = (int) (interval / 1000);
  1140.  
  1141. while (startWaiterTime + interval > System.currentTimeMillis() && !_aborted)
  1142. {
  1143. seconds--; // Here because we don't want to see two time announce at the same time
  1144.  
  1145. if (_joining || _started || _teleport)
  1146. {
  1147. switch (seconds)
  1148. {
  1149. case 3600: // 1 hour left
  1150. removeOfflinePlayers();
  1151.  
  1152. if (_joining)
  1153. {
  1154. Announcements.getInstance().gameAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
  1155. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + seconds / 60 / 60 + " hour(s) till registration close!");
  1156. }
  1157. else if (_started)
  1158. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + seconds / 60 / 60 + " hour(s) till event finish!");
  1159.  
  1160. break;
  1161. case 1800: // 30 minutes left
  1162. case 900: // 15 minutes left
  1163. case 600: // 10 minutes left
  1164. case 300: // 5 minutes left
  1165. case 240: // 4 minutes left
  1166. case 180: // 3 minutes left
  1167. case 120: // 2 minutes left
  1168. case 60: // 1 minute left
  1169. // removeOfflinePlayers();
  1170.  
  1171. if (_joining)
  1172. {
  1173. Announcements.getInstance().gameAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
  1174. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + seconds / 60 + " minute(s) till registration close!");
  1175. }
  1176. else if (_started)
  1177. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + seconds / 60 + " minute(s) till event finish!");
  1178.  
  1179. break;
  1180. case 30: // 30 seconds left
  1181. case 15: // 15 seconds left
  1182. case 10: // 10 seconds left
  1183. removeOfflinePlayers();
  1184. case 3: // 3 seconds left
  1185. case 2: // 2 seconds left
  1186. case 1: // 1 seconds left
  1187.  
  1188. if (_joining)
  1189. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
  1190. else if (_teleport)
  1191. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
  1192. else if (_started)
  1193. Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
  1194.  
  1195. break;
  1196. }
  1197. }
  1198.  
  1199. long startOneSecondWaiterStartTime = System.currentTimeMillis();
  1200.  
  1201. // Only the try catch with Thread.sleep(1000) give bad countdown on high wait times
  1202. while (startOneSecondWaiterStartTime + 1000 > System.currentTimeMillis())
  1203. {
  1204. try
  1205. {
  1206. Thread.sleep(1);
  1207. }
  1208. catch (InterruptedException ie) {
  1209. LOGGER.error("", ie);
  1210. }
  1211. }
  1212. }
  1213. }
  1214.  
  1215. /**
  1216. * Sit.
  1217. */
  1218. public static void sit()
  1219. {
  1220. if (_sitForced)
  1221. _sitForced = false;
  1222. else
  1223. _sitForced = true;
  1224.  
  1225. // final Vector<L2PcInstance> players = getPlayers();
  1226. synchronized (_players)
  1227. {
  1228.  
  1229. for (final L2PcInstance player : _players)
  1230. {
  1231. if (player != null)
  1232. {
  1233. if (_sitForced)
  1234. {
  1235. player.stopMove(null, false);
  1236. player.abortAttack();
  1237. player.abortCast();
  1238.  
  1239. if (!player.isSitting())
  1240. player.sitDown();
  1241. }
  1242. else
  1243. {
  1244. if (player.isSitting())
  1245. player.standUp();
  1246. }
  1247. }
  1248. }
  1249.  
  1250. }
  1251.  
  1252. }
  1253.  
  1254. /**
  1255. * Removes the offline players.
  1256. */
  1257. public static void removeOfflinePlayers()
  1258. {
  1259. try
  1260. {
  1261. // final Vector<L2PcInstance> players = getPlayers();
  1262. synchronized (_players)
  1263. {
  1264.  
  1265. if (_players == null || _players.isEmpty())
  1266. return;
  1267.  
  1268. List<L2PcInstance> toBeRemoved = new ArrayList<L2PcInstance>();
  1269.  
  1270. for (L2PcInstance player : _players)
  1271. {
  1272. if (player == null)
  1273. continue;
  1274. else if (player._inEventDM && player.isOnline() == 0 || player.isInJail() || player.isOffline())
  1275. {
  1276.  
  1277. if (!_joining)
  1278. {
  1279. player.getAppearance().setNameColor(player._originalNameColorDM);
  1280. player.setTitle(player._originalTitleDM);
  1281. player.setKarma(player._originalKarmaDM);
  1282.  
  1283. player.broadcastUserInfo();
  1284.  
  1285. }
  1286.  
  1287. // after remove, all event data must be cleaned in player
  1288. player._originalNameColorDM = 0;
  1289. player._originalTitleDM = null;
  1290. player._originalKarmaDM = 0;
  1291. player._countDMkills = 0;
  1292. player._inEventDM = false;
  1293.  
  1294. toBeRemoved.add(player);
  1295. // _players.remove(player);
  1296.  
  1297. player.sendMessage("Your participation in the DeathMatch event has been removed.");
  1298. }
  1299.  
  1300. }
  1301. _players.removeAll(toBeRemoved);
  1302.  
  1303. }
  1304. }
  1305. catch (Exception e) {
  1306. LOGGER.error("", e);
  1307.  
  1308. LOGGER.info(e.getMessage(), e);
  1309. return;
  1310. }
  1311. }
  1312.  
  1313. /**
  1314. * Start event ok.
  1315. * @return true, if successful
  1316. */
  1317. private static boolean startEventOk()
  1318. {
  1319. if (_joining || !_teleport || _started)
  1320. return false;
  1321.  
  1322. return true;
  1323. }
  1324.  
  1325. /**
  1326. * Finish event ok.
  1327. * @return true, if successful
  1328. */
  1329. private static boolean finishEventOk()
  1330. {
  1331. if (!_started)
  1332. return false;
  1333.  
  1334. return true;
  1335. }
  1336.  
  1337. /**
  1338. * Adds the player ok.
  1339. * @param eventPlayer the event player
  1340. * @return true, if successful
  1341. */
  1342. private static boolean addPlayerOk(L2PcInstance eventPlayer)
  1343. {
  1344. if (eventPlayer._inEventDM)
  1345. {
  1346. eventPlayer.sendMessage("You already participated in the event!");
  1347. return false;
  1348. }
  1349.  
  1350. if(eventPlayer._inEventCTF || eventPlayer._inEventTvT || eventPlayer._inEventRaid)
  1351. {
  1352. eventPlayer.sendMessage("You already participated to another event!");
  1353. return false;
  1354. }
  1355.  
  1356. if (Olympiad.getInstance().isRegistered(eventPlayer) || eventPlayer.isInOlympiadMode())
  1357. {
  1358. eventPlayer.sendMessage("You already participated in Olympiad!");
  1359. return false;
  1360. }
  1361.  
  1362. if (!Config.Allow_Same_HWID_On_Events && eventPlayer.getHWid() != null && eventPlayer.getHWid().length() != 0)
  1363. {
  1364. List<String> players_in_boxes = eventPlayer.active_boxes_characters;
  1365. L2PcInstance pc = null;
  1366. for(String character_name: players_in_boxes)
  1367. {
  1368. pc = L2World.getInstance().getPlayer(character_name);
  1369. if (pc != null && eventPlayer.getHWid().equals(pc.getHWid()))
  1370. {
  1371. if(pc._inEventDM)
  1372. {
  1373. eventPlayer.sendMessage("You already participated in event with a different char!");
  1374. return false;
  1375. }
  1376. }
  1377. }
  1378. }
  1379.  
  1380. if (eventPlayer._active_boxes > 1 && !Config.ALLOW_DUALBOX_EVENT)
  1381. {
  1382. List<String> players_in_boxes = eventPlayer.active_boxes_characters;
  1383.  
  1384. if (players_in_boxes != null && players_in_boxes.size() > 1)
  1385. for (String character_name : players_in_boxes)
  1386. {
  1387. L2PcInstance player = L2World.getInstance().getPlayer(character_name);
  1388.  
  1389. if (player != null && player._inEventDM)
  1390. {
  1391. eventPlayer.sendMessage("You already participated in event with another char!");
  1392. return false;
  1393. }
  1394. }
  1395.  
  1396. /*
  1397. * eventPlayer.sendMessage("Dual Box not allowed in Events"); return false;
  1398. */
  1399. }
  1400.  
  1401. if (!Config.DM_ALLOW_HEALER_CLASSES && (eventPlayer.getClassId() == ClassId.cardinal || eventPlayer.getClassId() == ClassId.evaSaint || eventPlayer.getClassId() == ClassId.shillienSaint))
  1402. {
  1403. eventPlayer.sendMessage("You cant join with Healer Class!");
  1404. return false;
  1405. }
  1406.  
  1407. // final Vector<L2PcInstance> players = getPlayers();
  1408. synchronized (_players)
  1409. {
  1410. if (_players.contains(eventPlayer))
  1411. {
  1412. eventPlayer.sendMessage("You already participated in the event!");
  1413. return false;
  1414. }
  1415.  
  1416. for (L2PcInstance player : _players)
  1417. {
  1418. if (player.getObjectId() == eventPlayer.getObjectId())
  1419. {
  1420. eventPlayer.sendMessage("You already participated in the event!");
  1421. return false;
  1422. }
  1423. else if (player.getName().equalsIgnoreCase(eventPlayer.getName()))
  1424. {
  1425. eventPlayer.sendMessage("You already participated in the event!");
  1426. return false;
  1427. }
  1428. }
  1429.  
  1430. }
  1431.  
  1432. return true;
  1433. }
  1434.  
  1435. /**
  1436. * Sets the user data.
  1437. */
  1438. public static void setUserData()
  1439. {
  1440. // final Vector<L2PcInstance> players = getPlayers();
  1441.  
  1442. synchronized (_players)
  1443. {
  1444.  
  1445. for (L2PcInstance player : _players)
  1446. {
  1447. player._originalNameColorDM = player.getAppearance().getNameColor();
  1448. player._originalKarmaDM = player.getKarma();
  1449. player._originalTitleDM = player.getTitle();
  1450. player.getAppearance().setNameColor(_playerColors);
  1451. player.setKarma(0);
  1452. player.setTitle("Kills: " + player._countDMkills);
  1453.  
  1454. if (player.isMounted())
  1455. {
  1456. if (player.setMountType(0))
  1457. {
  1458. if (player.isFlying())
  1459. {
  1460. player.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
  1461. }
  1462.  
  1463. Ride dismount = new Ride(player.getObjectId(), Ride.ACTION_DISMOUNT, 0);
  1464. player.broadcastPacket(dismount);
  1465. player.setMountObjectID(0);
  1466. }
  1467. }
  1468. player.broadcastUserInfo();
  1469. }
  1470. }
  1471. }
  1472.  
  1473. /**
  1474. * Dump data.
  1475. */
  1476. public static void dumpData()
  1477. {
  1478. LOGGER.info("");
  1479. LOGGER.info("");
  1480.  
  1481. if (!_joining && !_teleport && !_started)
  1482. {
  1483. LOGGER.info("<<---------------------------------->>");
  1484. LOGGER.info(">> " + _eventName + " Engine infos dump (INACTIVE) <<");
  1485. LOGGER.info("<<--^----^^-----^----^^------^^----->>");
  1486. }
  1487. else if (_joining && !_teleport && !_started)
  1488. {
  1489. LOGGER.info("<<--------------------------------->>");
  1490. LOGGER.info(">> " + _eventName + " Engine infos dump (JOINING) <<");
  1491. LOGGER.info("<<--^----^^-----^----^^------^----->>");
  1492. }
  1493. else if (!_joining && _teleport && !_started)
  1494. {
  1495. LOGGER.info("<<---------------------------------->>");
  1496. LOGGER.info(">> " + _eventName + " Engine infos dump (TELEPORT) <<");
  1497. LOGGER.info("<<--^----^^-----^----^^------^^----->>");
  1498. }
  1499. else if (!_joining && !_teleport && _started)
  1500. {
  1501. LOGGER.info("<<--------------------------------->>");
  1502. LOGGER.info(">> " + _eventName + " Engine infos dump (STARTED) <<");
  1503. LOGGER.info("<<--^----^^-----^----^^------^----->>");
  1504. }
  1505.  
  1506. LOGGER.info("Name: " + _eventName);
  1507. LOGGER.info("Desc: " + _eventDesc);
  1508. LOGGER.info("Join location: " + _joiningLocationName);
  1509. LOGGER.info("Min lvl: " + _minlvl);
  1510. LOGGER.info("Max lvl: " + _maxlvl);
  1511.  
  1512. LOGGER.warn("SYS_LOG: "+"");
  1513. LOGGER.warn("SYS_LOG: "+"##################################");
  1514. LOGGER.warn("SYS_LOG: "+"# _players(Vector<L2PcInstance>) #");
  1515. LOGGER.warn("SYS_LOG: "+"##################################");
  1516.  
  1517. // final Vector<L2PcInstance> players = getPlayers();
  1518. synchronized (_players)
  1519. {
  1520. LOGGER.warn("SYS_LOG: "+"Total Players : " + _players.size());
  1521.  
  1522. for (final L2PcInstance player : _players)
  1523. {
  1524. if (player != null)
  1525. LOGGER.warn("SYS_LOG: "+"Name: " + player.getName() + " kills :" + player._countDMkills);
  1526. }
  1527. }
  1528.  
  1529. LOGGER.warn("SYS_LOG: "+"");
  1530. LOGGER.warn("SYS_LOG: "+"################################");
  1531. LOGGER.warn("SYS_LOG: "+"# _savePlayers(Vector<String>) #");
  1532. LOGGER.warn("SYS_LOG: "+"################################");
  1533.  
  1534. for (String player : _savePlayers)
  1535. LOGGER.warn("SYS_LOG: "+"Name: " + player);
  1536.  
  1537. LOGGER.info("");
  1538. LOGGER.info("");
  1539.  
  1540. dumpLocalEventInfo();
  1541. }
  1542.  
  1543. /**
  1544. * Dump local event info.
  1545. */
  1546. private static void dumpLocalEventInfo()
  1547. {
  1548.  
  1549. }
  1550.  
  1551. /**
  1552. * Load data.
  1553. */
  1554. public static void loadData()
  1555. {
  1556. _eventName = new String();
  1557. _eventDesc = new String();
  1558. _joiningLocationName = new String();
  1559. _savePlayers = new Vector<String>();
  1560.  
  1561. synchronized (_players)
  1562. {
  1563. _players.clear();
  1564. }
  1565.  
  1566. _topPlayers = new ArrayList<L2PcInstance>();
  1567. _joining = false;
  1568. _teleport = false;
  1569. _started = false;
  1570. _sitForced = false;
  1571. _aborted = false;
  1572. _inProgress = false;
  1573.  
  1574. _npcId = 0;
  1575. _npcX = 0;
  1576. _npcY = 0;
  1577. _npcZ = 0;
  1578. _npcHeading = 0;
  1579. _rewardId = 0;
  1580. _rewardAmount = 0;
  1581. _topKills = 0;
  1582. _minlvl = 0;
  1583. _maxlvl = 0;
  1584. _joinTime = 0;
  1585. _eventTime = 0;
  1586. _minPlayers = 0;
  1587. _maxPlayers = 0;
  1588. _intervalBetweenMatchs = 0;
  1589. _playerColors = 0;
  1590. _playerX = 0;
  1591. _playerY = 0;
  1592. _playerZ = 0;
  1593.  
  1594. java.sql.Connection con = null;
  1595. try
  1596. {
  1597. PreparedStatement statement;
  1598. ResultSet rs;
  1599.  
  1600. con = L2DatabaseFactory.getInstance().getConnection(false);
  1601.  
  1602. statement = con.prepareStatement("Select * from dm");
  1603. rs = statement.executeQuery();
  1604.  
  1605. while (rs.next())
  1606. {
  1607. _eventName = rs.getString("eventName");
  1608. _eventDesc = rs.getString("eventDesc");
  1609. _joiningLocationName = rs.getString("joiningLocation");
  1610. _minlvl = rs.getInt("minlvl");
  1611. _maxlvl = rs.getInt("maxlvl");
  1612. _npcId = rs.getInt("npcId");
  1613. _npcX = rs.getInt("npcX");
  1614. _npcY = rs.getInt("npcY");
  1615. _npcZ = rs.getInt("npcZ");
  1616. _npcHeading = rs.getInt("npcHeading");
  1617. _rewardId = rs.getInt("rewardId");
  1618. _rewardAmount = rs.getInt("rewardAmount");
  1619. _joinTime = rs.getInt("joinTime");
  1620. _eventTime = rs.getInt("eventTime");
  1621. _minPlayers = rs.getInt("minPlayers");
  1622. _maxPlayers = rs.getInt("maxPlayers");
  1623. _playerColors = rs.getInt("color");
  1624. _playerX = rs.getInt("playerX");
  1625. _playerY = rs.getInt("playerY");
  1626. _playerZ = rs.getInt("playerZ");
  1627. _intervalBetweenMatchs = rs.getInt("delayForNextEvent");
  1628. }
  1629. statement.close();
  1630. }
  1631. catch (Exception e) {
  1632. LOGGER.error("", e);
  1633. LOGGER.info("Exception: DM.loadData(): " + e.getMessage());
  1634. }
  1635. finally
  1636. {
  1637. CloseUtil.close(con);
  1638. con = null;
  1639. }
  1640. }
  1641.  
  1642. /**
  1643. * Save data.
  1644. */
  1645. public static void saveData()
  1646. {
  1647. java.sql.Connection con = null;
  1648. try
  1649. {
  1650. con = L2DatabaseFactory.getInstance().getConnection(false);
  1651. PreparedStatement statement;
  1652.  
  1653. statement = con.prepareStatement("Delete from dm");
  1654. statement.execute();
  1655. statement.close();
  1656.  
  1657. statement = con.prepareStatement("INSERT INTO dm (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, joinTime, eventTime, minPlayers, maxPlayers, color, playerX, playerY, playerZ, delayForNextEvent ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  1658. statement.setString(1, _eventName);
  1659. statement.setString(2, _eventDesc);
  1660. statement.setString(3, _joiningLocationName);
  1661. statement.setInt(4, _minlvl);
  1662. statement.setInt(5, _maxlvl);
  1663. statement.setInt(6, _npcId);
  1664. statement.setInt(7, _npcX);
  1665. statement.setInt(8, _npcY);
  1666. statement.setInt(9, _npcZ);
  1667. statement.setInt(10, _npcHeading);
  1668. statement.setInt(11, _rewardId);
  1669. statement.setInt(12, _rewardAmount);
  1670. statement.setInt(13, _joinTime);
  1671. statement.setInt(14, _eventTime);
  1672. statement.setInt(15, _minPlayers);
  1673. statement.setInt(16, _maxPlayers);
  1674. statement.setInt(17, _playerColors);
  1675. statement.setInt(18, _playerX);
  1676. statement.setInt(19, _playerY);
  1677. statement.setInt(20, _playerZ);
  1678. statement.setLong(21, _intervalBetweenMatchs);
  1679. statement.execute();
  1680. statement.close();
  1681. }
  1682. catch (Exception e) {
  1683. LOGGER.error("", e);
  1684.  
  1685. LOGGER.info("Exception: DM.saveData(): " + e.getMessage());
  1686. }
  1687. finally
  1688. {
  1689. CloseUtil.close(con);
  1690. con = null;
  1691. }
  1692. }
  1693.  
  1694. /**
  1695. * Show event html.
  1696. * @param eventPlayer the event player
  1697. * @param objectId the object id
  1698. */
  1699. public static void showEventHtml(L2PcInstance eventPlayer, String objectId)
  1700. {
  1701. try
  1702. {
  1703. NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  1704.  
  1705. TextBuilder replyMSG = new TextBuilder("<html><title>" + _eventName + "</title><body>");
  1706. replyMSG.append("<center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32></center><br1>");
  1707. replyMSG.append("<center><font color=\"3366CC\">Current event:</font></center><br1>");
  1708. replyMSG.append("<center>Name:&nbsp;<font color=\"00FF00\">" + _eventName + "</font></center><br1>");
  1709. replyMSG.append("<center>Description:&nbsp;<font color=\"00FF00\">" + _eventDesc + "</font></center><br><br>");
  1710. replyMSG.append("<center>Event Type:&nbsp;<font color=\"00FF00\"> Full Buff Event!!! </font></center><br><br>");
  1711.  
  1712. // final Vector<L2PcInstance> players = getPlayers();
  1713. synchronized (_players)
  1714. {
  1715.  
  1716. if (!_started && !_joining)
  1717. replyMSG.append("<center>Wait till the admin/gm start the participation.</center>");
  1718. else if (!checkMaxPlayers(_players.size()))
  1719. {
  1720. if (!_started)
  1721. {
  1722. replyMSG.append("Currently participated: <font color=\"00FF00\">" + _players.size() + ".</font><br>");
  1723. replyMSG.append("Max players: <font color=\"00FF00\">" + _maxPlayers + "</font><br><br>");
  1724. replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
  1725. }
  1726. }
  1727. else if (eventPlayer.isCursedWeaponEquiped() && !Config.DM_JOIN_CURSED)
  1728. {
  1729. replyMSG.append("<font color=\"FFFF00\">You can't participate to this event with a cursed Weapon.</font><br>");
  1730. }
  1731. else if (!_started && _joining && eventPlayer.getLevel() >= _minlvl && eventPlayer.getLevel() <= _maxlvl)
  1732. {
  1733. if (_players.contains(eventPlayer))
  1734. {
  1735. replyMSG.append("<center><font color=\"3366CC\">You participated already!</font></center><br><br>");
  1736.  
  1737. replyMSG.append("<center>Joined Players: <font color=\"00FF00\">" + _players.size() + "</font></center><br>");
  1738. replyMSG.append("<table border=\"0\"><tr>");
  1739. replyMSG.append("<td width=\"200\">Wait till event start or</td>");
  1740. replyMSG.append("<td width=\"60\"><center><button value=\"remove\" action=\"bypass -h npc_" + objectId + "_dmevent_player_leave\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></td>");
  1741. replyMSG.append("<td width=\"100\">your participation!</td>");
  1742. replyMSG.append("</tr></table>");
  1743. }
  1744. else
  1745. {
  1746. replyMSG.append("<center>Joined Players: <font color=\"00FF00\">" + _players.size() + "</font></center><br>");
  1747. replyMSG.append("<center><font color=\"3366CC\">You want to participate in the event?</font></center><br>");
  1748. replyMSG.append("<center><td width=\"200\">Min lvl: <font color=\"00FF00\">" + _minlvl + "</font></center></td><br>");
  1749. replyMSG.append("<center><td width=\"200\">Max lvl: <font color=\"00FF00\">" + _maxlvl + "</font></center></td><br><br>");
  1750. replyMSG.append("<center><button value=\"Join\" action=\"bypass -h npc_" + objectId + "_dmevent_player_join\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center><br>");
  1751.  
  1752. }
  1753. }
  1754. else if (_started && !_joining)
  1755. replyMSG.append("<center>" + _eventName + " match is in progress.</center>");
  1756. else if (eventPlayer.getLevel() < _minlvl || eventPlayer.getLevel() > _maxlvl)
  1757. {
  1758. replyMSG.append("Your lvl: <font color=\"00FF00\">" + eventPlayer.getLevel() + "</font><br>");
  1759. replyMSG.append("Min lvl: <font color=\"00FF00\">" + _minlvl + "</font><br>");
  1760. replyMSG.append("Max lvl: <font color=\"00FF00\">" + _maxlvl + "</font><br><br>");
  1761. replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
  1762. }
  1763.  
  1764. }
  1765.  
  1766. replyMSG.append("</body></html>");
  1767. adminReply.setHtml(replyMSG.toString());
  1768. eventPlayer.sendPacket(adminReply);
  1769.  
  1770. // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  1771. eventPlayer.sendPacket(ActionFailed.STATIC_PACKET);
  1772. }
  1773. catch (Exception e) {
  1774. LOGGER.error("", e);
  1775.  
  1776. LOGGER.info(_eventName + " Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception" + e.getMessage());
  1777. }
  1778. }
  1779.  
  1780. /*
  1781. * public static void showEventHtml(L2PcInstance eventPlayer, String objectId) { try { NpcHtmlMessage adminReply = new NpcHtmlMessage(5); TextBuilder replyMSG = new TextBuilder("<html><body>"); replyMSG.append("DM Match<br><br><br>"); replyMSG.append("Current event...<br1>");
  1782. * replyMSG.append(" ... name:&nbsp;<font color=\"00FF00\">" + _eventName + "</font><br1>"); replyMSG.append(" ... description:&nbsp;<font color=\"00FF00\">" + _eventDesc + "</font><br><br>"); if(!_started && !_joining)
  1783. * replyMSG.append("<center>Wait till the admin/gm start the participation.</center>"); else if(!checkMaxPlayers(_players.size())){ if(!DM._started) { replyMSG.append("Currently participated: <font color=\"00FF00\">" + _players.size() + ".</font><br>");
  1784. * replyMSG.append("Max players: <font color=\"00FF00\">" + _maxPlayers + "</font><br><br>"); replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>"); } } else if(!_started && _joining && eventPlayer.getLevel()>=_minlvl && eventPlayer.getLevel()<=_maxlvl) {
  1785. * if(_players.contains(eventPlayer)) { replyMSG.append("You participated already!<br><br>"); replyMSG.append("<table border=\"0\"><tr>"); replyMSG.append("<td width=\"200\">Wait till event start or</td>");
  1786. * replyMSG.append("<td width=\"60\"><center><button value=\"remove\" action=\"bypass -h npc_" + objectId + "_dmevent_player_leave\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></td>"); replyMSG.append("<td width=\"100\">your participation!</td>");
  1787. * replyMSG.append("</tr></table>"); } else { replyMSG.append("You want to participate in the event?<br><br>"); replyMSG.append("<td width=\"200\">Admin set min lvl : <font color=\"00FF00\">" + _minlvl + "</font></td><br>");
  1788. * replyMSG.append("<td width=\"200\">Admin set max lvl : <font color=\"00FF00\">" + _maxlvl + "</font></td><br><br>"); replyMSG.append("<button value=\"Join\" action=\"bypass -h npc_" + objectId + "_dmevent_player_join\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"); } } else
  1789. * if(_started && !_joining) replyMSG.append("<center>"+_eventName+" match is in progress.</center>"); else if(eventPlayer.getLevel() < _minlvl || eventPlayer.getLevel() > _maxlvl) { replyMSG.append("Your lvl: <font color=\"00FF00\">" + eventPlayer.getLevel() + "</font><br>");
  1790. * replyMSG.append("Min lvl: <font color=\"00FF00\">" + _minlvl + "</font><br>"); replyMSG.append("Max lvl: <font color=\"00FF00\">" + _maxlvl + "</font><br><br>"); replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>"); } replyMSG.append("</body></html>");
  1791. * adminReply.setHtml(replyMSG.toString()); eventPlayer.sendPacket(adminReply); // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet eventPlayer.sendPacket( ActionFailed.STATIC_PACKET ); } catch(Exception e) { LOGGER.log(
  1792. * _eventName+" Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception" + e.getMessage()); } }
  1793. */
  1794.  
  1795. /**
  1796. * Adds the player.
  1797. * @param player the player
  1798. */
  1799. public static void addPlayer(L2PcInstance player)
  1800. {
  1801. if (!addPlayerOk(player))
  1802. return;
  1803.  
  1804. synchronized (_players)
  1805. {
  1806. _players.add(player);
  1807. }
  1808.  
  1809. player._inEventDM = true;
  1810. player._countDMkills = 0;
  1811. _savePlayers.add(player.getName());
  1812. player.sendMessage("DM: You successfully registered for the DeathMatch event.");
  1813. }
  1814.  
  1815. /**
  1816. * Removes the player.
  1817. * @param player the player
  1818. */
  1819. public static void removePlayer(L2PcInstance player)
  1820. {
  1821. if (player != null && player._inEventDM)
  1822. {
  1823. if (!_joining)
  1824. {
  1825. player.getAppearance().setNameColor(player._originalNameColorDM);
  1826. player.setTitle(player._originalTitleDM);
  1827. player.setKarma(player._originalKarmaDM);
  1828.  
  1829. player.broadcastUserInfo();
  1830.  
  1831. }
  1832.  
  1833. // after remove, all event data must be cleaned in player
  1834. player._originalNameColorDM = 0;
  1835. player._originalTitleDM = null;
  1836. player._originalKarmaDM = 0;
  1837. player._countDMkills = 0;
  1838. player._inEventDM = false;
  1839.  
  1840. synchronized (_players)
  1841. {
  1842. _players.remove(player);
  1843. }
  1844.  
  1845. player.sendMessage("Your participation in the DeathMatch event has been removed.");
  1846.  
  1847. }
  1848. }
  1849.  
  1850. /**
  1851. * Clean dm.
  1852. */
  1853. public static void cleanDM()
  1854. {
  1855. // final Vector<L2PcInstance> players = getPlayers();
  1856. synchronized (_players)
  1857. {
  1858.  
  1859. for (L2PcInstance player : _players)
  1860. {
  1861. if (player != null)
  1862. {
  1863.  
  1864. cleanEventPlayer(player);
  1865.  
  1866. if (player._inEventDM)
  1867. {
  1868. if (!_joining)
  1869. {
  1870. player.getAppearance().setNameColor(player._originalNameColorDM);
  1871. player.setTitle(player._originalTitleDM);
  1872. player.setKarma(player._originalKarmaDM);
  1873.  
  1874. player.broadcastUserInfo();
  1875.  
  1876. }
  1877.  
  1878. // after remove, all event data must be cleaned in player
  1879. player._originalNameColorDM = 0;
  1880. player._originalTitleDM = null;
  1881. player._originalKarmaDM = 0;
  1882. player._countDMkills = 0;
  1883. player._inEventDM = false;
  1884.  
  1885. // _players.remove(player);
  1886.  
  1887. player.sendMessage("Your participation in the DeathMatch event has been removed.");
  1888.  
  1889. }
  1890.  
  1891. if (_savePlayers.contains(player.getName()))
  1892. _savePlayers.remove(player.getName());
  1893. player._inEventDM = false;
  1894. }
  1895. }
  1896.  
  1897. _players.clear();
  1898.  
  1899. }
  1900.  
  1901. _topKills = 0;
  1902. _savePlayers = new Vector<String>();
  1903. _topPlayers = new ArrayList<L2PcInstance>();
  1904.  
  1905. cleanLocalEventInfo();
  1906.  
  1907. _inProgress = false;
  1908.  
  1909. loadData();
  1910. }
  1911.  
  1912. /**
  1913. * Clean local event info.
  1914. */
  1915. private static void cleanLocalEventInfo()
  1916. {
  1917. // nothing
  1918. }
  1919.  
  1920. /**
  1921. * Clean event player.
  1922. * @param player the player
  1923. */
  1924. private static void cleanEventPlayer(L2PcInstance player)
  1925. {
  1926. // nothing
  1927. }
  1928.  
  1929. /*
  1930. * public static void cleanDM() { synchronized (_players){ for(L2PcInstance player : _players) { removePlayer(player); } _savePlayers = new Vector<String>(); _topPlayer = null; _npcSpawn = null; _joining = false; _teleport = false; _started = false; _inProgress = false; _sitForced = false;
  1931. * _topKills = 0; _players = new Vector<L2PcInstance>(); } }
  1932. */
  1933.  
  1934. /**
  1935. * Adds the disconnected player.
  1936. * @param player the player
  1937. */
  1938. public static void addDisconnectedPlayer(L2PcInstance player)
  1939. {
  1940. // final Vector<L2PcInstance> players = getPlayers();
  1941. synchronized (_players)
  1942. {
  1943.  
  1944. if (!_players.contains(player) && _savePlayers.contains(player.getName()))
  1945. {
  1946. if (Config.DM_ON_START_REMOVE_ALL_EFFECTS)
  1947. {
  1948. player.stopAllEffects();
  1949.  
  1950. }
  1951.  
  1952. _players.add(player);
  1953.  
  1954. player._originalNameColorDM = player.getAppearance().getNameColor();
  1955. player._originalTitleDM = player.getTitle();
  1956. player._originalKarmaDM = player.getKarma();
  1957. player._inEventDM = true;
  1958. player._countDMkills = 0;
  1959. if (_teleport || _started)
  1960. {
  1961. player.setTitle("Kills: " + player._countDMkills);
  1962. player.getAppearance().setNameColor(_playerColors);
  1963. player.setKarma(0);
  1964. player.broadcastUserInfo();
  1965. player.teleToLocation(_playerX + Rnd.get(Config.DM_SPAWN_OFFSET), _playerY + Rnd.get(Config.DM_SPAWN_OFFSET), _playerZ);
  1966. }
  1967. }
  1968. }
  1969. }
  1970.  
  1971. /**
  1972. * Gets the _player colors.
  1973. * @return the _playerColors
  1974. */
  1975. public static int get_playerColors()
  1976. {
  1977. return _playerColors;
  1978. }
  1979.  
  1980. /**
  1981. * Set_player colors.
  1982. * @param _playerColors the _playerColors to set
  1983. * @return true, if successful
  1984. */
  1985. public static boolean set_playerColors(int _playerColors)
  1986. {
  1987. if (!is_inProgress())
  1988. {
  1989. DM._playerColors = _playerColors;
  1990. return true;
  1991. }
  1992. return false;
  1993. }
  1994.  
  1995. /**
  1996. * Reward player.
  1997. */
  1998. public static void rewardPlayer()
  1999. {
  2000. if (_topPlayers.size() > 0)
  2001. {
  2002.  
  2003. for (L2PcInstance _topPlayer : _topPlayers)
  2004. {
  2005. _topPlayer.addItem("DM Event: " + _eventName, _rewardId, _rewardAmount, _topPlayer, true);
  2006.  
  2007. StatusUpdate su = new StatusUpdate(_topPlayer.getObjectId());
  2008. su.addAttribute(StatusUpdate.CUR_LOAD, _topPlayer.getCurrentLoad());
  2009. _topPlayer.sendPacket(su);
  2010.  
  2011. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  2012. TextBuilder replyMSG = new TextBuilder("");
  2013.  
  2014. replyMSG.append("<html><body>You won the event. Look in your inventory for the reward.</body></html>");
  2015.  
  2016. nhm.setHtml(replyMSG.toString());
  2017. _topPlayer.sendPacket(nhm);
  2018.  
  2019. // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  2020. _topPlayer.sendPacket(ActionFailed.STATIC_PACKET);
  2021. }
  2022. }
  2023. /*
  2024. * if(_topPlayer != null) { _topPlayer.addItem("DM Event: " + _eventName, _rewardId, _rewardAmount, _topPlayer, true); StatusUpdate su = new StatusUpdate(_topPlayer.getObjectId()); su.addAttribute(StatusUpdate.CUR_LOAD, _topPlayer.getCurrentLoad()); _topPlayer.sendPacket(su); NpcHtmlMessage
  2025. * nhm = new NpcHtmlMessage(5); TextBuilder replyMSG = new TextBuilder(""); replyMSG.append("<html><body>You won the event. Look in your inventory for the reward.</body></html>"); nhm.setHtml(replyMSG.toString()); _topPlayer.sendPacket(nhm); // Send a Server->Client ActionFailed to the
  2026. * L2PcInstance in order to avoid that the client wait another packet _topPlayer.sendPacket( ActionFailed.STATIC_PACKET ); }
  2027. */
  2028. }
  2029.  
  2030. /**
  2031. * Process top player.
  2032. */
  2033. private static void processTopPlayer()
  2034. {
  2035. // final Vector<L2PcInstance> players = getPlayers();
  2036. synchronized (_players)
  2037. {
  2038.  
  2039. for (L2PcInstance player : _players)
  2040. {
  2041. if (player._countDMkills > _topKills)
  2042. {
  2043. _topPlayers.clear();
  2044. _topPlayers.add(player);
  2045. _topKills = player._countDMkills;
  2046.  
  2047. }
  2048. else if (player._countDMkills == _topKills)
  2049. {
  2050. if (!_topPlayers.contains(player))
  2051. _topPlayers.add(player);
  2052. }
  2053. }
  2054. }
  2055. }
  2056.  
  2057. /**
  2058. * Process top team.
  2059. */
  2060. private static void processTopTeam()
  2061. {
  2062.  
  2063. }
  2064.  
  2065. /**
  2066. * Gets the _players spawn location.
  2067. * @return the _players spawn location
  2068. */
  2069. public static Location get_playersSpawnLocation()
  2070. {
  2071. Location npc_loc = new Location(_playerX + Rnd.get(Config.DM_SPAWN_OFFSET), _playerY + Rnd.get(Config.DM_SPAWN_OFFSET), _playerZ, 0);
  2072.  
  2073. return npc_loc;
  2074. }
  2075.  
  2076. /**
  2077. * Gets the players.
  2078. * @return the players
  2079. */
  2080. /*
  2081. * protected synchronized static Vector<L2PcInstance> getPlayers() { return _players; }
  2082. */
  2083.  
  2084. /**
  2085. * Sets the players pos.
  2086. * @param activeChar the new players pos
  2087. */
  2088. public static void setPlayersPos(L2PcInstance activeChar)
  2089. {
  2090. _playerX = activeChar.getX();
  2091. _playerY = activeChar.getY();
  2092. _playerZ = activeChar.getZ();
  2093. }
  2094.  
  2095. /**
  2096. * Removes the user data.
  2097. */
  2098. public static void removeUserData()
  2099. {
  2100. // final Vector<L2PcInstance> players = getPlayers();
  2101. synchronized (_players)
  2102. {
  2103. for (final L2PcInstance player : _players)
  2104. {
  2105. player.getAppearance().setNameColor(player._originalNameColorDM);
  2106. player.setTitle(player._originalTitleDM);
  2107. player.setKarma(player._originalKarmaDM);
  2108. player._inEventDM = false;
  2109. player._countDMkills = 0;
  2110. player.broadcastUserInfo();
  2111. }
  2112. }
  2113.  
  2114. }
  2115.  
  2116. public static void removeNoneParticipantsInZone()
  2117. {
  2118. for(L2PcInstance p : L2World.getInstance().getAllPlayers())
  2119. {
  2120. if (p.isInsideZone(L2Character.ZONE_DM))
  2121. {
  2122. if (!p.isInLMS())
  2123. {
  2124. p.teleToLocation(MapRegionTable.TeleportWhereType.Town);
  2125. p.sendMessage("This is an Event zone. None participants are not allowed inside.");
  2126. }
  2127. }
  2128. }
  2129. }
  2130.  
  2131. /**
  2132. * just an announcer to send termination messages.
  2133. */
  2134. public static void sendFinalMessages()
  2135. {
  2136. if (!_started && !_aborted)
  2137. Announcements.getInstance().gameAnnounceToAll("Thank you for participating " + ".");
  2138. }
  2139.  
  2140. /**
  2141. * returns the interval between each event.
  2142. * @return the interval between matchs
  2143. */
  2144. public static int getIntervalBetweenMatchs()
  2145. {
  2146. long actualTime = System.currentTimeMillis();
  2147. long totalTime = actualTime + _intervalBetweenMatchs;
  2148. long interval = totalTime - actualTime;
  2149. int seconds = (int) (interval / 1000);
  2150.  
  2151. return seconds / 60;
  2152. }
  2153.  
  2154. /**
  2155. * Sets the event start time.
  2156. * @param newTime the new event start time
  2157. */
  2158. public void setEventStartTime(String newTime)
  2159. {
  2160. startEventTime = newTime;
  2161. }
  2162.  
  2163. /*
  2164. * (non-Javadoc)
  2165. * @see com.l2jfrozen.gameserver.model.entity.event.manager.EventTask#getEventIdentifier()
  2166. */
  2167. @Override
  2168. public String getEventIdentifier()
  2169. {
  2170. return _eventName;
  2171. }
  2172.  
  2173. /*
  2174. * (non-Javadoc)
  2175. * @see java.lang.Runnable#run()
  2176. */
  2177. @Override
  2178. public void run()
  2179. {
  2180. LOGGER.warn("SYS_LOG: "+"DM: Event notification start");
  2181. eventOnceStart();
  2182. }
  2183.  
  2184. /*
  2185. * (non-Javadoc)
  2186. * @see com.l2jfrozen.gameserver.model.entity.event.manager.EventTask#getEventStartTime()
  2187. */
  2188. @Override
  2189. public String getEventStartTime()
  2190. {
  2191. return startEventTime;
  2192. }
  2193.  
  2194. /**
  2195. * On disconnect.
  2196. * @param player the player
  2197. */
  2198. public static void onDisconnect(L2PcInstance player)
  2199. {
  2200. if (player._inEventDM)
  2201. {
  2202. removePlayer(player);
  2203. player.teleToLocation(_npcX, _npcY, _npcZ);
  2204. }
  2205. }
  2206. }
Advertisement
Add Comment
Please, Sign In to add comment