Advertisement
Sarada-L2

Arena 5x5

Apr 26th, 2021
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.83 KB | None | 0 0
  1. +package Dev.Tournament;
  2. +
  3. +import java.util.ArrayList;
  4. +import java.util.HashMap;
  5. +import java.util.List;
  6. +import java.util.Map;
  7. +
  8. +import net.sf.l2j.commons.concurrent.ThreadPool;
  9. +import net.sf.l2j.commons.random.Rnd;
  10. +
  11. +import net.sf.l2j.gameserver.model.L2Effect;
  12. +import net.sf.l2j.gameserver.model.actor.Summon;
  13. +import net.sf.l2j.gameserver.model.actor.instance.Pet;
  14. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  15. +import net.sf.l2j.gameserver.model.base.ClassId;
  16. +import net.sf.l2j.gameserver.model.zone.ZoneId;
  17. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  18. +import net.sf.l2j.gameserver.util.Broadcast;
  19. +
  20. +import Dev.Tournament.properties.ArenaConfig;
  21. +import Dev.Tournament.properties.ArenaTask;
  22. +
  23. +public class Arena5x5 implements Runnable
  24. +{
  25. + // list of participants
  26. + public static List<Pair> registered;
  27. + // number of Arenas
  28. + int free = ArenaConfig.ARENA_EVENT_COUNT_5X5;
  29. + // Arenas
  30. + Arena[] arenas = new Arena[ArenaConfig.ARENA_EVENT_COUNT_5X5];
  31. + // list of fights going on
  32. + Map<Integer, String> fights = new HashMap<>(ArenaConfig.ARENA_EVENT_COUNT_5X5);
  33. +
  34. + public Arena5x5()
  35. + {
  36. + registered = new ArrayList<>();
  37. + int[] coord;
  38. + for (int i = 0; i < ArenaConfig.ARENA_EVENT_COUNT_5X5; i++)
  39. + {
  40. + coord = ArenaConfig.ARENA_EVENT_LOCS_5X5[i];
  41. + arenas[i] = new Arena(i, coord[0], coord[1], coord[2]);
  42. + }
  43. + }
  44. +
  45. + public static Arena5x5 getInstance()
  46. + {
  47. + return SingletonHolder.INSTANCE;
  48. + }
  49. +
  50. + public boolean register(Player player, Player assist, Player assist2, Player assist3, Player assist4)
  51. + {
  52. + for (Pair p : registered)
  53. + {
  54. + if (p.getLeader() == player || p.getAssist() == player)
  55. + {
  56. + player.sendMessage("Tournament: You already registered!");
  57. + return false;
  58. + }
  59. + else if (p.getLeader() == assist || p.getAssist() == assist)
  60. + {
  61. + player.sendMessage("Tournament: " + assist.getName() + " already registered!");
  62. + return false;
  63. + }
  64. + else if (p.getLeader() == assist2 || p.getAssist2() == assist2)
  65. + {
  66. + player.sendMessage("Tournament: " + assist2.getName() + " already registered!");
  67. + return false;
  68. + }
  69. + else if (p.getLeader() == assist3 || p.getAssist3() == assist3)
  70. + {
  71. + player.sendMessage("Tournament: " + assist3.getName() + " already registered!");
  72. + return false;
  73. + }
  74. + else if (p.getLeader() == assist4 || p.getAssist4() == assist4)
  75. + {
  76. + player.sendMessage("Tournament: " + assist4.getName() + " already registered!");
  77. + return false;
  78. + }
  79. + }
  80. + return registered.add(new Pair(player, assist, assist2, assist3, assist4));
  81. + }
  82. +
  83. + public boolean isRegistered(Player player)
  84. + {
  85. + for (Pair p : registered)
  86. + {
  87. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player || p.getAssist3() == player || p.getAssist4() == player)
  88. + {
  89. + return true;
  90. + }
  91. + }
  92. + return false;
  93. + }
  94. +
  95. + public Map<Integer, String> getFights()
  96. + {
  97. + return fights;
  98. + }
  99. +
  100. + public boolean remove(Player player)
  101. + {
  102. + for (Pair p : registered)
  103. + {
  104. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player || p.getAssist3() == player || p.getAssist4() == player)
  105. + {
  106. + p.removeMessage();
  107. + registered.remove(p);
  108. + return true;
  109. + }
  110. + }
  111. + return false;
  112. + }
  113. +
  114. + @Override
  115. + public synchronized void run()
  116. + {
  117. + boolean load = true;
  118. +
  119. + // while server is running
  120. + while (load)
  121. + {
  122. + if (!ArenaTask.is_started())
  123. + load = false;
  124. +
  125. + // if no have participants or arenas are busy wait 1 minute
  126. + if (registered.size() < 2 || free == 0)
  127. + {
  128. + try
  129. + {
  130. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  131. + }
  132. + catch (InterruptedException e)
  133. + {
  134. + }
  135. + continue;
  136. + }
  137. + List<Pair> opponents = selectOpponents();
  138. + if (opponents != null && opponents.size() == 2)
  139. + {
  140. + Thread T = new Thread(new EvtArenaTask(opponents));
  141. + T.setDaemon(true);
  142. + T.start();
  143. + }
  144. + // wait 1 minute for not stress server
  145. + try
  146. + {
  147. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  148. + }
  149. + catch (InterruptedException e)
  150. + {
  151. + }
  152. + }
  153. + }
  154. +
  155. + private List<Pair> selectOpponents()
  156. + {
  157. + List<Pair> opponents = new ArrayList<>();
  158. + Pair pairOne = null, pairTwo = null;
  159. + int tries = 3;
  160. + do
  161. + {
  162. + int first = 0, second = 0;
  163. + if (getRegisteredCount() < 2)
  164. + return opponents;
  165. +
  166. + if (pairOne == null)
  167. + {
  168. + first = Rnd.get(getRegisteredCount());
  169. + pairOne = registered.get(first);
  170. + if (pairOne.check())
  171. + {
  172. + opponents.add(0, pairOne);
  173. + registered.remove(first);
  174. + }
  175. + else
  176. + {
  177. + pairOne = null;
  178. + registered.remove(first);
  179. + return null;
  180. + }
  181. +
  182. + }
  183. + if (pairTwo == null)
  184. + {
  185. + second = Rnd.get(getRegisteredCount());
  186. + pairTwo = registered.get(second);
  187. + if (pairTwo.check())
  188. + {
  189. + opponents.add(1, pairTwo);
  190. + registered.remove(second);
  191. + }
  192. + else
  193. + {
  194. + pairTwo = null;
  195. + registered.remove(second);
  196. + return null;
  197. + }
  198. +
  199. + }
  200. + }
  201. + while ((pairOne == null || pairTwo == null) && --tries > 0);
  202. + return opponents;
  203. + }
  204. +
  205. + public void clear()
  206. + {
  207. + registered.clear();
  208. + }
  209. +
  210. + public int getRegisteredCount()
  211. + {
  212. + return registered.size();
  213. + }
  214. +
  215. + private class Pair
  216. + {
  217. + private Player leader, assist, assist2, assist3, assist4;
  218. +
  219. + public Pair(Player leader, Player assist, Player assist2, Player assist3, Player assist4)
  220. + {
  221. + this.leader = leader;
  222. + this.assist = assist;
  223. + this.assist2 = assist2;
  224. + this.assist3 = assist3;
  225. + this.assist4 = assist4;
  226. + }
  227. +
  228. + public Player getAssist()
  229. + {
  230. + return assist;
  231. + }
  232. +
  233. + public Player getAssist2()
  234. + {
  235. + return assist2;
  236. + }
  237. +
  238. + public Player getAssist3()
  239. + {
  240. + return assist3;
  241. + }
  242. +
  243. + public Player getAssist4()
  244. + {
  245. + return assist4;
  246. + }
  247. +
  248. + public Player getLeader()
  249. + {
  250. + return leader;
  251. + }
  252. +
  253. + public boolean check()
  254. + {
  255. + if ((leader == null || !leader.isOnline()))
  256. + {
  257. + if (assist != null || assist.isOnline())
  258. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  259. +
  260. + if (assist2 != null || assist2.isOnline())
  261. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  262. +
  263. + if (assist3 != null || assist3.isOnline())
  264. + assist3.sendMessage("Tournament: You participation in Event was Canceled.");
  265. +
  266. + if (assist4 != null || assist4.isOnline())
  267. + assist4.sendMessage("Tournament: You participation in Event was Canceled.");
  268. +
  269. + return false;
  270. + }
  271. +
  272. + else if (((assist == null || !assist.isOnline()) || (assist2 == null || !assist2.isOnline()) || (assist3 == null || !assist3.isOnline()) || (assist4 == null || !assist4.isOnline()) && (leader != null || leader.isOnline())))
  273. + {
  274. + leader.sendMessage("Tournament: You participation in Event was Canceled.");
  275. +
  276. + if (assist != null || assist.isOnline())
  277. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  278. +
  279. + if (assist2 != null || assist2.isOnline())
  280. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  281. +
  282. + if (assist3 != null || assist3.isOnline())
  283. + assist3.sendMessage("Tournament: You participation in Event was Canceled.");
  284. +
  285. + if (assist4 != null || assist4.isOnline())
  286. + assist4.sendMessage("Tournament: You participation in Event was Canceled.");
  287. +
  288. + return false;
  289. + }
  290. + return true;
  291. + }
  292. +
  293. + public boolean isDead()
  294. + {
  295. + if (ArenaConfig.ARENA_PROTECT)
  296. + {
  297. + if (leader != null && leader.isOnline() && leader.isArenaAttack() && !leader.isDead() && !leader.isInsideZone(ZoneId.ARENA_EVENT))
  298. + leader.logout();
  299. + if (assist != null && assist.isOnline() && assist.isArenaAttack() && !assist.isDead() && !assist.isInsideZone(ZoneId.ARENA_EVENT))
  300. + assist.logout();
  301. + if (assist2 != null && assist2.isOnline() && assist2.isArenaAttack() && !assist2.isDead() && !assist2.isInsideZone(ZoneId.ARENA_EVENT))
  302. + assist2.logout();
  303. + if (assist3 != null && assist3.isOnline() && assist3.isArenaAttack() && !assist3.isDead() && !assist3.isInsideZone(ZoneId.ARENA_EVENT))
  304. + assist3.logout();
  305. + if (assist4 != null && assist4.isOnline() && assist4.isArenaAttack() && !assist4.isDead() && !assist4.isInsideZone(ZoneId.ARENA_EVENT))
  306. + assist4.logout();
  307. + }
  308. +
  309. + if ((leader == null || leader.isDead() || !leader.isOnline() || !leader.isInsideZone(ZoneId.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !assist.isOnline() || !assist.isInsideZone(ZoneId.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !assist2.isOnline() || !assist2.isInsideZone(ZoneId.ARENA_EVENT) || !assist2.isArenaAttack()) && (assist3 == null || assist3.isDead() || !assist3.isOnline() || !assist3.isInsideZone(ZoneId.ARENA_EVENT) || !assist3.isArenaAttack()) && (assist4 == null || assist4.isDead() || !assist4.isOnline() || !assist4.isInsideZone(ZoneId.ARENA_EVENT)))
  310. + return false;
  311. +
  312. + return !(leader.isDead() && assist.isDead() && assist2.isDead() && assist3.isDead() && assist4.isDead());
  313. + }
  314. +
  315. + public boolean isAlive()
  316. + {
  317. + if ((leader == null || leader.isDead() || !leader.isOnline() || !leader.isInsideZone(ZoneId.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !assist.isOnline() || !assist.isInsideZone(ZoneId.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !assist2.isOnline() || !assist2.isInsideZone(ZoneId.ARENA_EVENT) || !assist2.isArenaAttack()) && (assist3 == null || assist3.isDead() || !assist3.isOnline() || !assist3.isInsideZone(ZoneId.ARENA_EVENT) || !assist3.isArenaAttack()) && (assist4 == null || assist4.isDead() || !assist4.isOnline() || !assist4.isInsideZone(ZoneId.ARENA_EVENT)))
  318. + return false;
  319. +
  320. + return !(leader.isDead() && assist.isDead() && assist2.isDead() && assist3.isDead() && assist4.isDead());
  321. + }
  322. +
  323. + public void teleportTo(int x, int y, int z)
  324. + {
  325. + if (leader != null && leader.isOnline())
  326. + {
  327. + leader.getAppearance().setInvisible();
  328. + leader.setCurrentCp(leader.getMaxCp());
  329. + leader.setCurrentHp(leader.getMaxHp());
  330. + leader.setCurrentMp(leader.getMaxMp());
  331. +
  332. + /*
  333. + if (leader.isInObserverMode())
  334. + {
  335. + leader.setLastCords(x, y, z);
  336. + leader.leaveOlympiadObserverMode();
  337. + }
  338. + */
  339. + if (!leader.isInJail())
  340. + leader.teleToLocation(x, y, z, 0);
  341. +
  342. + leader.broadcastUserInfo();
  343. +
  344. + }
  345. + if (assist != null && assist.isOnline())
  346. + {
  347. + assist.getAppearance().setInvisible();
  348. + assist.setCurrentCp(assist.getMaxCp());
  349. + assist.setCurrentHp(assist.getMaxHp());
  350. + assist.setCurrentMp(assist.getMaxMp());
  351. +
  352. + /*
  353. + if (assist.isInObserverMode())
  354. + {
  355. + assist.setLastCords(x, y + 200, z);
  356. + assist.leaveOlympiadObserverMode();
  357. + }
  358. + */
  359. + if (!assist.isInJail())
  360. + assist.teleToLocation(x, y + 200, z, 0);
  361. +
  362. + assist.broadcastUserInfo();
  363. + }
  364. + if (assist2 != null && assist2.isOnline())
  365. + {
  366. + assist2.getAppearance().setInvisible();
  367. + assist2.setCurrentCp(assist2.getMaxCp());
  368. + assist2.setCurrentHp(assist2.getMaxHp());
  369. + assist2.setCurrentMp(assist2.getMaxMp());
  370. +
  371. + /*
  372. + if (assist2.isInObserverMode())
  373. + {
  374. + assist2.setLastCords(x, y + 150, z);
  375. + assist2.leaveOlympiadObserverMode();
  376. + }
  377. + */
  378. + if (!assist2.isInJail())
  379. + assist2.teleToLocation(x, y + 150, z, 0);
  380. +
  381. + assist2.broadcastUserInfo();
  382. + }
  383. + if (assist3 != null && assist3.isOnline())
  384. + {
  385. + assist3.getAppearance().setInvisible();
  386. + assist3.setCurrentCp(assist3.getMaxCp());
  387. + assist3.setCurrentHp(assist3.getMaxHp());
  388. + assist3.setCurrentMp(assist3.getMaxMp());
  389. +
  390. + /*
  391. + if (assist3.isInObserverMode())
  392. + {
  393. + assist3.setLastCords(x, y + 100, z);
  394. + assist3.leaveOlympiadObserverMode();
  395. + }
  396. + */
  397. + if (!assist3.isInJail())
  398. + assist3.teleToLocation(x, y + 100, z, 0);
  399. +
  400. + assist3.broadcastUserInfo();
  401. + }
  402. + if (assist4 != null && assist4.isOnline())
  403. + {
  404. + assist4.getAppearance().setInvisible();
  405. + assist4.setCurrentCp(assist4.getMaxCp());
  406. + assist4.setCurrentHp(assist4.getMaxHp());
  407. + assist4.setCurrentMp(assist4.getMaxMp());
  408. +
  409. + /*
  410. + if (assist4.isInObserverMode())
  411. + {
  412. + assist4.setLastCords(x, y + 50, z);
  413. + assist4.leaveOlympiadObserverMode();
  414. + }
  415. + */
  416. + if (!assist4.isInJail())
  417. + assist4.teleToLocation(x, y + 50, z, 0);
  418. +
  419. + assist4.broadcastUserInfo();
  420. + }
  421. + }
  422. +
  423. + public void EventTitle(String title, String color)
  424. + {
  425. + if (leader != null && leader.isOnline())
  426. + {
  427. + leader.setTitle(title);
  428. + leader.getAppearance().setTitleColor(Integer.decode("0x" + color));
  429. + leader.broadcastUserInfo();
  430. + leader.broadcastTitleInfo();
  431. + }
  432. +
  433. + if (assist != null && assist.isOnline())
  434. + {
  435. + assist.setTitle(title);
  436. + assist.getAppearance().setTitleColor(Integer.decode("0x" + color));
  437. + assist.broadcastUserInfo();
  438. + assist.broadcastTitleInfo();
  439. + }
  440. + if (assist2 != null && assist2.isOnline())
  441. + {
  442. + assist2.setTitle(title);
  443. + assist2.getAppearance().setTitleColor(Integer.decode("0x" + color));
  444. + assist2.broadcastUserInfo();
  445. + assist2.broadcastTitleInfo();
  446. + }
  447. + if (assist3 != null && assist3.isOnline())
  448. + {
  449. + assist3.setTitle(title);
  450. + assist3.getAppearance().setTitleColor(Integer.decode("0x" + color));
  451. + assist3.broadcastUserInfo();
  452. + assist3.broadcastTitleInfo();
  453. + }
  454. + if (assist4 != null && assist4.isOnline())
  455. + {
  456. + assist4.setTitle(title);
  457. + assist4.getAppearance().setTitleColor(Integer.decode("0x" + color));
  458. + assist4.broadcastUserInfo();
  459. + assist4.broadcastTitleInfo();
  460. + }
  461. + }
  462. +
  463. + public void saveTitle()
  464. + {
  465. + if (leader != null && leader.isOnline())
  466. + {
  467. + leader._originalTitleColorTournament = leader.getAppearance().getTitleColor();
  468. + leader._originalTitleTournament = leader.getTitle();
  469. + }
  470. +
  471. + if (assist != null && assist.isOnline())
  472. + {
  473. + assist._originalTitleColorTournament = assist.getAppearance().getTitleColor();
  474. + assist._originalTitleTournament = assist.getTitle();
  475. + }
  476. +
  477. + if (assist2 != null && assist2.isOnline())
  478. + {
  479. + assist2._originalTitleColorTournament = assist2.getAppearance().getTitleColor();
  480. + assist2._originalTitleTournament = assist2.getTitle();
  481. + }
  482. +
  483. + if (assist3 != null && assist3.isOnline())
  484. + {
  485. + assist3._originalTitleColorTournament = assist3.getAppearance().getTitleColor();
  486. + assist3._originalTitleTournament = assist3.getTitle();
  487. + }
  488. +
  489. + if (assist4 != null && assist4.isOnline())
  490. + {
  491. + assist4._originalTitleColorTournament = assist4.getAppearance().getTitleColor();
  492. + assist4._originalTitleTournament = assist4.getTitle();
  493. + }
  494. + }
  495. +
  496. + public void backTitle()
  497. + {
  498. + if (leader != null && leader.isOnline())
  499. + {
  500. + leader.setTitle(leader._originalTitleTournament);
  501. + leader.getAppearance().setTitleColor(leader._originalTitleColorTournament);
  502. + leader.broadcastUserInfo();
  503. + leader.broadcastTitleInfo();
  504. + }
  505. +
  506. + if (assist != null && assist.isOnline())
  507. + {
  508. + assist.setTitle(assist._originalTitleTournament);
  509. + assist.getAppearance().setTitleColor(assist._originalTitleColorTournament);
  510. + assist.broadcastUserInfo();
  511. + assist.broadcastTitleInfo();
  512. + }
  513. +
  514. + if (assist2 != null && assist2.isOnline())
  515. + {
  516. + assist2.setTitle(assist2._originalTitleTournament);
  517. + assist2.getAppearance().setTitleColor(assist2._originalTitleColorTournament);
  518. + assist2.broadcastUserInfo();
  519. + assist2.broadcastTitleInfo();
  520. + }
  521. +
  522. + if (assist3 != null && assist3.isOnline())
  523. + {
  524. + assist3.setTitle(assist3._originalTitleTournament);
  525. + assist3.getAppearance().setTitleColor(assist3._originalTitleColorTournament);
  526. + assist3.broadcastUserInfo();
  527. + assist3.broadcastTitleInfo();
  528. + }
  529. +
  530. + if (assist4 != null && assist4.isOnline())
  531. + {
  532. + assist4.setTitle(assist4._originalTitleTournament);
  533. + assist4.getAppearance().setTitleColor(assist4._originalTitleColorTournament);
  534. + assist4.broadcastUserInfo();
  535. + assist4.broadcastTitleInfo();
  536. + }
  537. + }
  538. +
  539. + public void setArenaInstance()
  540. + {
  541. + if (leader != null && leader.isOnline())
  542. + leader.setInstanceId(3, true); //3x3 Tournament Instance
  543. +
  544. + if (assist != null && assist.isOnline())
  545. + assist.setInstanceId(3, true); //3x3 Tournament Instance
  546. +
  547. + if (assist2 != null && assist2.isOnline())
  548. + assist2.setInstanceId(3, true); //3x3 Tournament Instance
  549. +
  550. + if (assist3 != null && assist3.isOnline())
  551. + assist3.setInstanceId(3, true); //3x3 Tournament Instance
  552. +
  553. + if (assist4 != null && assist4.isOnline())
  554. + assist4.setInstanceId(3, true); //3x3 Tournament Instance
  555. + }
  556. +
  557. + public void setRealInstance()
  558. + {
  559. + if (leader != null && leader.isOnline())
  560. + leader.setInstanceId(0, true);
  561. +
  562. + if (assist != null && assist.isOnline())
  563. + assist.setInstanceId(0, true);
  564. +
  565. + if (assist2 != null && assist2.isOnline())
  566. + assist2.setInstanceId(0, true);
  567. +
  568. + if (assist3 != null && assist3.isOnline())
  569. + assist3.setInstanceId(0, true);
  570. +
  571. + if (assist4 != null && assist4.isOnline())
  572. + assist4.setInstanceId(0, true);
  573. + }
  574. +
  575. + public void rewards()
  576. + {
  577. + if (leader != null && leader.isOnline())
  578. + {
  579. + if (leader.isVip())
  580. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  581. + else
  582. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, leader, true);
  583. + }
  584. +
  585. + if (assist != null && assist.isOnline())
  586. + {
  587. + if (assist.isVip())
  588. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  589. + else
  590. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist, true);
  591. + }
  592. +
  593. + if (assist2 != null && assist2.isOnline())
  594. + {
  595. + if (assist2.isVip())
  596. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  597. + else
  598. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist2, true);
  599. + }
  600. +
  601. + if (assist3 != null && assist3.isOnline())
  602. + {
  603. + if (assist3.isVip())
  604. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist3, true);
  605. + else
  606. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist3, true);
  607. + }
  608. +
  609. + if (assist4 != null && assist4.isOnline())
  610. + {
  611. + if (assist4.isVip())
  612. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist4, true);
  613. + else
  614. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist4, true);
  615. + }
  616. +
  617. + sendPacket("Congratulations, your team won the event!", 5);
  618. + }
  619. +
  620. + public void rewardsLost()
  621. + {
  622. + if (leader != null && leader.isOnline())
  623. + {
  624. + if (leader.isVip())
  625. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  626. + else
  627. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, leader, true);
  628. + }
  629. +
  630. + if (assist != null && assist.isOnline())
  631. + {
  632. + if (assist.isVip())
  633. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  634. + else
  635. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist, true);
  636. + }
  637. + if (assist2 != null && assist2.isOnline())
  638. + {
  639. + if (assist2.isVip())
  640. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  641. + else
  642. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist2, true);
  643. + }
  644. + if (assist3 != null && assist3.isOnline())
  645. + {
  646. + if (assist3.isVip())
  647. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist3, true);
  648. + else
  649. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist3, true);
  650. + }
  651. +
  652. + if (assist4 != null && assist4.isOnline())
  653. + {
  654. + if (assist4.isVip())
  655. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist4, true);
  656. + else
  657. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist4, true);
  658. + }
  659. +
  660. + sendPacket("your team lost the event! =(", 5);
  661. + }
  662. +
  663. + public void setInTournamentEvent(boolean val)
  664. + {
  665. + if (leader != null && leader.isOnline())
  666. + leader.setInArenaEvent(val);
  667. +
  668. + if (assist != null && assist.isOnline())
  669. + assist.setInArenaEvent(val);
  670. +
  671. + if (assist2 != null && assist2.isOnline())
  672. + assist2.setInArenaEvent(val);
  673. +
  674. + if (assist3 != null && assist3.isOnline())
  675. + assist3.setInArenaEvent(val);
  676. +
  677. + if (assist4 != null && assist4.isOnline())
  678. + assist4.setInArenaEvent(val);
  679. + }
  680. +
  681. + public void removeMessage()
  682. + {
  683. + if (leader != null && leader.isOnline())
  684. + {
  685. + leader.sendMessage("Tournament: Your participation has been removed.");
  686. + leader.setArenaProtection(false);
  687. + leader.setArena5x5(false);
  688. + }
  689. +
  690. + if (assist != null && assist.isOnline())
  691. + {
  692. + assist.sendMessage("Tournament: Your participation has been removed.");
  693. + assist.setArenaProtection(false);
  694. + assist.setArena5x5(false);
  695. + }
  696. +
  697. + if (assist2 != null && assist2.isOnline())
  698. + {
  699. + assist2.sendMessage("Tournament: Your participation has been removed.");
  700. + assist2.setArenaProtection(false);
  701. + assist2.setArena5x5(false);
  702. + }
  703. +
  704. + if (assist3 != null && assist3.isOnline())
  705. + {
  706. + assist3.sendMessage("Tournament: Your participation has been removed.");
  707. + assist3.setArenaProtection(false);
  708. + assist3.setArena5x5(false);
  709. + }
  710. +
  711. + if (assist4 != null && assist4.isOnline())
  712. + {
  713. + assist4.sendMessage("Tournament: Your participation has been removed.");
  714. + assist4.setArenaProtection(false);
  715. + assist4.setArena5x5(false);
  716. + }
  717. + }
  718. +
  719. + public void setArenaProtection(boolean val)
  720. + {
  721. + if (leader != null && leader.isOnline())
  722. + {
  723. + leader.setArenaProtection(val);
  724. + leader.setArena5x5(val);
  725. + }
  726. +
  727. + if (assist != null && assist.isOnline())
  728. + {
  729. + assist.setArenaProtection(val);
  730. + assist.setArena5x5(val);
  731. + }
  732. + if (assist2 != null && assist2.isOnline())
  733. + {
  734. + assist2.setArenaProtection(val);
  735. + assist2.setArena5x5(val);
  736. + }
  737. +
  738. + if (assist3 != null && assist3.isOnline())
  739. + {
  740. + assist3.setArenaProtection(val);
  741. + assist3.setArena5x5(val);
  742. + }
  743. +
  744. + if (assist4 != null && assist4.isOnline())
  745. + {
  746. + assist4.setArenaProtection(val);
  747. + assist4.setArena5x5(val);
  748. + }
  749. + }
  750. +
  751. + public void revive()
  752. + {
  753. + if (leader != null && leader.isOnline() && leader.isDead())
  754. + leader.doRevive();
  755. +
  756. + if (assist != null && assist.isOnline() && assist.isDead())
  757. + assist.doRevive();
  758. +
  759. + if (assist2 != null && assist2.isOnline() && assist2.isDead())
  760. + assist2.doRevive();
  761. +
  762. + if (assist3 != null && assist3.isOnline() && assist3.isDead())
  763. + assist3.doRevive();
  764. +
  765. + if (assist4 != null && assist4.isOnline() && assist4.isDead())
  766. + assist4.doRevive();
  767. + }
  768. +
  769. + public void setImobilised(boolean val)
  770. + {
  771. + if (leader != null && leader.isOnline())
  772. + {
  773. + leader.setIsInvul(val);
  774. + leader.setStopArena(val);
  775. + }
  776. + if (assist != null && assist.isOnline())
  777. + {
  778. + assist.setIsInvul(val);
  779. + assist.setStopArena(val);
  780. + }
  781. + if (assist2 != null && assist2.isOnline())
  782. + {
  783. + assist2.setIsInvul(val);
  784. + assist2.setStopArena(val);
  785. + }
  786. + if (assist3 != null && assist3.isOnline())
  787. + {
  788. + assist3.setIsInvul(val);
  789. + assist3.setStopArena(val);
  790. + }
  791. + if (assist4 != null && assist4.isOnline())
  792. + {
  793. + assist4.setIsInvul(val);
  794. + assist4.setStopArena(val);
  795. + }
  796. + }
  797. +
  798. + public void setArenaAttack(boolean val)
  799. + {
  800. + if (leader != null && leader.isOnline())
  801. + {
  802. + leader.setArenaAttack(val);
  803. + leader.broadcastUserInfo();
  804. + }
  805. +
  806. + if (assist != null && assist.isOnline())
  807. + {
  808. + assist.setArenaAttack(val);
  809. + assist.broadcastUserInfo();
  810. + }
  811. +
  812. + if (assist2 != null && assist2.isOnline())
  813. + {
  814. + assist2.setArenaAttack(val);
  815. + assist2.broadcastUserInfo();
  816. + }
  817. +
  818. + if (assist3 != null && assist3.isOnline())
  819. + {
  820. + assist3.setArenaAttack(val);
  821. + assist3.broadcastUserInfo();
  822. + }
  823. +
  824. + if (assist4 != null && assist4.isOnline())
  825. + {
  826. + assist4.setArenaAttack(val);
  827. + assist4.broadcastUserInfo();
  828. + }
  829. + }
  830. +
  831. + public void removePet()
  832. + {
  833. + if (leader != null && leader.isOnline())
  834. + {
  835. + // Remove Summon's buffs
  836. + if (leader.getPet() != null)
  837. + {
  838. + Summon summon = leader.getPet();
  839. + if (summon != null)
  840. + summon.unSummon(summon.getOwner());
  841. +
  842. + if (summon instanceof Pet)
  843. + summon.unSummon(leader);
  844. + }
  845. +
  846. + if (leader.getMountType() == 1 || leader.getMountType() == 2)
  847. + leader.dismount();
  848. + }
  849. +
  850. + if (assist != null && assist.isOnline())
  851. + {
  852. + // Remove Summon's buffs
  853. + if (assist.getPet() != null)
  854. + {
  855. + Summon summon = assist.getPet();
  856. + if (summon != null)
  857. + summon.unSummon(summon.getOwner());
  858. +
  859. + if (summon instanceof Pet)
  860. + summon.unSummon(assist);
  861. + }
  862. +
  863. + if (assist.getMountType() == 1 || assist.getMountType() == 2)
  864. + assist.dismount();
  865. +
  866. + }
  867. +
  868. + if (assist2 != null && assist2.isOnline())
  869. + {
  870. + // Remove Summon's buffs
  871. + if (assist2.getPet() != null)
  872. + {
  873. + Summon summon = assist2.getPet();
  874. + if (summon != null)
  875. + summon.unSummon(summon.getOwner());
  876. +
  877. + if (summon instanceof Pet)
  878. + summon.unSummon(assist2);
  879. +
  880. + }
  881. +
  882. + if (assist2.getMountType() == 1 || assist2.getMountType() == 2)
  883. + assist2.dismount();
  884. +
  885. + }
  886. +
  887. + if (assist3 != null && assist3.isOnline())
  888. + {
  889. + // Remove Summon's buffs
  890. + if (assist3.getPet() != null)
  891. + {
  892. + Summon summon = assist3.getPet();
  893. + if (summon != null)
  894. + summon.unSummon(summon.getOwner());
  895. +
  896. + if (summon instanceof Pet)
  897. + summon.unSummon(assist3);
  898. + }
  899. +
  900. + if (assist3.getMountType() == 1 || assist3.getMountType() == 2)
  901. + assist3.dismount();
  902. +
  903. + }
  904. +
  905. + if (assist4 != null && assist4.isOnline())
  906. + {
  907. + // Remove Summon's buffs
  908. + if (assist4.getPet() != null)
  909. + {
  910. + Summon summon = assist4.getPet();
  911. + if (summon != null)
  912. + summon.unSummon(summon.getOwner());
  913. +
  914. + if (summon instanceof Pet)
  915. + summon.unSummon(assist4);
  916. +
  917. + }
  918. +
  919. + if (assist4.getMountType() == 1 || assist4.getMountType() == 2)
  920. + assist4.dismount();
  921. +
  922. + }
  923. + }
  924. +
  925. + public void removeSkills()
  926. + {
  927. + if (!(leader.getClassId() == ClassId.SHILLIEN_ELDER || leader.getClassId() == ClassId.SHILLIEN_SAINT || leader.getClassId() == ClassId.BISHOP || leader.getClassId() == ClassId.CARDINAL || leader.getClassId() == ClassId.ELVEN_ELDER || leader.getClassId() == ClassId.EVAS_SAINT))
  928. + {
  929. + for (L2Effect effect : leader.getAllEffects())
  930. + {
  931. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  932. + leader.stopSkillEffects(effect.getSkill().getId());
  933. + }
  934. + }
  935. +
  936. + if (!(assist.getClassId() == ClassId.SHILLIEN_ELDER || assist.getClassId() == ClassId.SHILLIEN_SAINT || assist.getClassId() == ClassId.BISHOP || assist.getClassId() == ClassId.CARDINAL || assist.getClassId() == ClassId.ELVEN_ELDER || assist.getClassId() == ClassId.EVAS_SAINT))
  937. + {
  938. + for (L2Effect effect : assist.getAllEffects())
  939. + {
  940. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  941. + assist.stopSkillEffects(effect.getSkill().getId());
  942. + }
  943. + }
  944. +
  945. + if (!(assist2.getClassId() == ClassId.SHILLIEN_ELDER || assist2.getClassId() == ClassId.SHILLIEN_SAINT || assist2.getClassId() == ClassId.BISHOP || assist2.getClassId() == ClassId.CARDINAL || assist2.getClassId() == ClassId.ELVEN_ELDER || assist2.getClassId() == ClassId.EVAS_SAINT))
  946. + {
  947. + for (L2Effect effect : assist2.getAllEffects())
  948. + {
  949. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  950. + assist2.stopSkillEffects(effect.getSkill().getId());
  951. + }
  952. + }
  953. +
  954. + if (!(assist3.getClassId() == ClassId.SHILLIEN_ELDER || assist3.getClassId() == ClassId.SHILLIEN_SAINT || assist3.getClassId() == ClassId.BISHOP || assist3.getClassId() == ClassId.CARDINAL || assist3.getClassId() == ClassId.ELVEN_ELDER || assist3.getClassId() == ClassId.EVAS_SAINT))
  955. + {
  956. + for (L2Effect effect : assist3.getAllEffects())
  957. + {
  958. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  959. + assist3.stopSkillEffects(effect.getSkill().getId());
  960. + }
  961. + }
  962. +
  963. + if (!(assist4.getClassId() == ClassId.SHILLIEN_ELDER || assist4.getClassId() == ClassId.SHILLIEN_SAINT || assist4.getClassId() == ClassId.BISHOP || assist4.getClassId() == ClassId.CARDINAL || assist4.getClassId() == ClassId.ELVEN_ELDER || assist4.getClassId() == ClassId.EVAS_SAINT))
  964. + {
  965. + for (L2Effect effect : assist4.getAllEffects())
  966. + {
  967. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  968. + assist4.stopSkillEffects(effect.getSkill().getId());
  969. + }
  970. + }
  971. + }
  972. +
  973. + public void sendPacket(String message, int duration)
  974. + {
  975. + if (leader != null && leader.isOnline())
  976. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  977. +
  978. + if (assist != null && assist.isOnline())
  979. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  980. +
  981. + if (assist2 != null && assist2.isOnline())
  982. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  983. +
  984. + if (assist3 != null && assist3.isOnline())
  985. + assist3.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  986. +
  987. + if (assist4 != null && assist4.isOnline())
  988. + assist4.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  989. +
  990. + }
  991. +
  992. + public void inicarContagem(int duration)
  993. + {
  994. + if (leader != null && leader.isOnline())
  995. + ThreadPool.schedule(new countdown(leader, duration), 0);
  996. +
  997. + if (assist != null && assist.isOnline())
  998. + ThreadPool.schedule(new countdown(assist, duration), 0);
  999. +
  1000. + if (assist2 != null && assist2.isOnline())
  1001. + ThreadPool.schedule(new countdown(assist2, duration), 0);
  1002. +
  1003. + if (assist3 != null && assist3.isOnline())
  1004. + ThreadPool.schedule(new countdown(assist3, duration), 0);
  1005. +
  1006. + if (assist4 != null && assist4.isOnline())
  1007. + ThreadPool.schedule(new countdown(assist4, duration), 0);
  1008. + }
  1009. +
  1010. + public void sendPacketinit(String message, int duration)
  1011. + {
  1012. + if (leader != null && leader.isOnline())
  1013. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1014. +
  1015. + if (assist != null && assist.isOnline())
  1016. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1017. +
  1018. + if (assist2 != null && assist2.isOnline())
  1019. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1020. +
  1021. + if (assist3 != null && assist3.isOnline())
  1022. + assist3.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1023. +
  1024. + if (assist4 != null && assist4.isOnline())
  1025. + assist4.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1026. +
  1027. + }
  1028. + }
  1029. +
  1030. + private class EvtArenaTask implements Runnable
  1031. + {
  1032. + private final Pair pairOne;
  1033. + private final Pair pairTwo;
  1034. + private final int pOneX, pOneY, pOneZ, pTwoX, pTwoY, pTwoZ;
  1035. + private Arena arena;
  1036. +
  1037. + public EvtArenaTask(List<Pair> opponents)
  1038. + {
  1039. + pairOne = opponents.get(0);
  1040. + pairTwo = opponents.get(1);
  1041. + Player leader = pairOne.getLeader();
  1042. + pOneX = leader.getX();
  1043. + pOneY = leader.getY();
  1044. + pOneZ = leader.getZ();
  1045. + leader = pairTwo.getLeader();
  1046. + pTwoX = leader.getX();
  1047. + pTwoY = leader.getY();
  1048. + pTwoZ = leader.getZ();
  1049. + }
  1050. +
  1051. + @Override
  1052. + public void run()
  1053. + {
  1054. + free--;
  1055. + pairOne.saveTitle();
  1056. + pairTwo.saveTitle();
  1057. + portPairsToArena();
  1058. + pairOne.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_5X5);
  1059. + pairTwo.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_5X5);
  1060. + try
  1061. + {
  1062. + Thread.sleep(ArenaConfig.ARENA_WAIT_INTERVAL_5X5 * 1000);
  1063. + }
  1064. + catch (InterruptedException e1)
  1065. + {
  1066. + }
  1067. + pairOne.sendPacketinit("Started. Good Fight!", 3);
  1068. + pairTwo.sendPacketinit("Started. Good Fight!", 3);
  1069. + pairOne.EventTitle(ArenaConfig.MSG_TEAM1, ArenaConfig.TITLE_COLOR_TEAM1);
  1070. + pairTwo.EventTitle(ArenaConfig.MSG_TEAM2, ArenaConfig.TITLE_COLOR_TEAM2);
  1071. + pairOne.setImobilised(false);
  1072. + pairTwo.setImobilised(false);
  1073. + pairOne.setArenaAttack(true);
  1074. + pairTwo.setArenaAttack(true);
  1075. +
  1076. + while (check())
  1077. + {
  1078. + // check players status each seconds
  1079. + try
  1080. + {
  1081. + Thread.sleep(ArenaConfig.ARENA_CHECK_INTERVAL);
  1082. + }
  1083. + catch (InterruptedException e)
  1084. + {
  1085. + break;
  1086. + }
  1087. + }
  1088. + finishDuel();
  1089. + free++;
  1090. + }
  1091. +
  1092. + private void finishDuel()
  1093. + {
  1094. + fights.remove(arena.id);
  1095. + rewardWinner();
  1096. + pairOne.revive();
  1097. + pairTwo.revive();
  1098. + pairOne.teleportTo(pOneX, pOneY, pOneZ);
  1099. + pairTwo.teleportTo(pTwoX, pTwoY, pTwoZ);
  1100. + pairOne.backTitle();
  1101. + pairTwo.backTitle();
  1102. + pairOne.setRealInstance();
  1103. + pairTwo.setRealInstance();
  1104. + pairOne.setInTournamentEvent(false);
  1105. + pairTwo.setInTournamentEvent(false);
  1106. + pairOne.setArenaProtection(false);
  1107. + pairTwo.setArenaProtection(false);
  1108. + pairOne.setArenaAttack(false);
  1109. + pairTwo.setArenaAttack(false);
  1110. + arena.setFree(true);
  1111. + }
  1112. +
  1113. + private void rewardWinner()
  1114. + {
  1115. + if (pairOne.isAlive() && !pairTwo.isAlive())
  1116. + {
  1117. + Player leader1 = pairOne.getLeader();
  1118. + Player leader2 = pairTwo.getLeader();
  1119. +
  1120. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  1121. + Broadcast.gameAnnounceToOnlinePlayers("(5X5):(" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  1122. +
  1123. + pairOne.rewards();
  1124. + pairTwo.rewardsLost();
  1125. + }
  1126. + else if (pairTwo.isAlive() && !pairOne.isAlive())
  1127. + {
  1128. + Player leader1 = pairTwo.getLeader();
  1129. + Player leader2 = pairOne.getLeader();
  1130. +
  1131. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  1132. + Broadcast.gameAnnounceToOnlinePlayers("(5X5):(" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  1133. +
  1134. + pairTwo.rewards();
  1135. + pairOne.rewardsLost();
  1136. + }
  1137. + }
  1138. +
  1139. + private boolean check()
  1140. + {
  1141. + return (pairOne.isDead() && pairTwo.isDead());
  1142. + }
  1143. +
  1144. + private void portPairsToArena()
  1145. + {
  1146. + for (Arena arena : arenas)
  1147. + {
  1148. + if (arena.isFree)
  1149. + {
  1150. + this.arena = arena;
  1151. + arena.setFree(false);
  1152. + pairOne.removePet();
  1153. + pairTwo.removePet();
  1154. + pairOne.setArenaInstance();
  1155. + pairTwo.setArenaInstance();
  1156. + pairOne.teleportTo(arena.x - 850, arena.y, arena.z);
  1157. + pairTwo.teleportTo(arena.x + 850, arena.y, arena.z);
  1158. + pairOne.setImobilised(true);
  1159. + pairTwo.setImobilised(true);
  1160. + pairOne.setInTournamentEvent(true);
  1161. + pairTwo.setInTournamentEvent(true);
  1162. + pairOne.removeSkills();
  1163. + pairTwo.removeSkills();
  1164. + fights.put(this.arena.id, pairOne.getLeader().getName() + " vs " + pairTwo.getLeader().getName());
  1165. + break;
  1166. + }
  1167. + }
  1168. + }
  1169. + }
  1170. +
  1171. + private class Arena
  1172. + {
  1173. + protected int x, y, z;
  1174. + protected boolean isFree = true;
  1175. + int id;
  1176. +
  1177. + public Arena(int id, int x, int y, int z)
  1178. + {
  1179. + this.id = id;
  1180. + this.x = x;
  1181. + this.y = y;
  1182. + this.z = z;
  1183. + }
  1184. +
  1185. + public void setFree(boolean val)
  1186. + {
  1187. + isFree = val;
  1188. + }
  1189. + }
  1190. +
  1191. + protected class countdown implements Runnable
  1192. + {
  1193. + private final Player _player;
  1194. + private int _time;
  1195. +
  1196. + public countdown(Player player, int time)
  1197. + {
  1198. + _time = time;
  1199. + _player = player;
  1200. + }
  1201. +
  1202. + @Override
  1203. + public void run()
  1204. + {
  1205. + if (_player.isOnline())
  1206. + {
  1207. +
  1208. + switch (_time)
  1209. + {
  1210. + case 300:
  1211. + case 240:
  1212. + case 180:
  1213. + case 120:
  1214. + case 57:
  1215. + if (_player.isOnline())
  1216. + {
  1217. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 60 second(s)..", 4000));
  1218. + _player.sendMessage("60 second(s) to start the battle.");
  1219. + }
  1220. + break;
  1221. + case 45:
  1222. + if (_player.isOnline())
  1223. + {
  1224. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  1225. + _player.sendMessage(_time + " second(s) to start the battle!");
  1226. + }
  1227. + break;
  1228. + case 27:
  1229. + if (_player.isOnline())
  1230. + {
  1231. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 30 second(s)..", 4000));
  1232. + _player.sendMessage("30 second(s) to start the battle.");
  1233. + }
  1234. + break;
  1235. + case 20:
  1236. + if (_player.isOnline())
  1237. + {
  1238. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  1239. + _player.sendMessage(_time + " second(s) to start the battle!");
  1240. + }
  1241. + break;
  1242. + case 15:
  1243. + if (_player.isOnline())
  1244. + {
  1245. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  1246. + _player.sendMessage(_time + " second(s) to start the battle!");
  1247. + }
  1248. + break;
  1249. + case 10:
  1250. + if (_player.isOnline())
  1251. + _player.sendMessage(_time + " second(s) to start the battle!");
  1252. + break;
  1253. + case 5:
  1254. + if (_player.isOnline())
  1255. + _player.sendMessage(_time + " second(s) to start the battle!");
  1256. + break;
  1257. + case 4:
  1258. + if (_player.isOnline())
  1259. + _player.sendMessage(_time + " second(s) to start the battle!");
  1260. + break;
  1261. + case 3:
  1262. + if (_player.isOnline())
  1263. + _player.sendMessage(_time + " second(s) to start the battle!");
  1264. + break;
  1265. + case 2:
  1266. + if (_player.isOnline())
  1267. + _player.sendMessage(_time + " second(s) to start the battle!");
  1268. + break;
  1269. + case 1:
  1270. + if (_player.isOnline())
  1271. + _player.sendMessage(_time + " second(s) to start the battle!");
  1272. + break;
  1273. + }
  1274. + if (_time > 1)
  1275. + {
  1276. + ThreadPool.schedule(new countdown(_player, _time - 1), 1000);
  1277. + }
  1278. + }
  1279. + }
  1280. + }
  1281. +
  1282. + private static class SingletonHolder
  1283. + {
  1284. + protected static final Arena5x5 INSTANCE = new Arena5x5();
  1285. + }
  1286. +}
  1287. +
  1288.  
  1289. ArenaTask.java
  1290.  
  1291. Arena3x3.getInstance().clear();
  1292. +Arena5x5.getInstance().clear();
  1293.  
  1294.  
  1295. ThreadPool.schedule(Arena1x1.getInstance(), 5000);
  1296. ThreadPool.schedule(Arena3x3.getInstance(), 5000);
  1297. +ThreadPool.schedule(Arena5x5.getInstance(), 5000);
  1298.  
  1299.  
  1300.  
  1301. if (player.isArena1x1())
  1302. Arena1x1.getInstance().remove(player);
  1303. if (player.isArena3x3())
  1304. Arena3x3.getInstance().remove(player);
  1305. +if (player.isArena5x5())
  1306. +Arena5x5.getInstance().remove(player);
  1307.  
  1308.  
  1309.  
  1310.  
  1311. Tournament.java
  1312.  
  1313. else if (Arena3x3.registered.size() == 7)
  1314. html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_7_over\" fore=\"L2UI_CH3.calculate1_7\">");
  1315. else if (Arena3x3.registered.size() == 8)
  1316. html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_8_over\" fore=\"L2UI_CH3.calculate1_8\">");
  1317. else if (Arena3x3.registered.size() >= 9)
  1318. html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_9_over\" fore=\"L2UI_CH3.calculate1_9\">");
  1319.  
  1320. +if (Arena5x5.registered.size() == 0)
  1321. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_0_over\" fore=\"L2UI_CH3.calculate1_0\">");
  1322. +else if (Arena5x5.registered.size() == 1)
  1323. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_1_over\" fore=\"L2UI_CH3.calculate1_1\">");
  1324. +else if (Arena5x5.registered.size() == 2)
  1325. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_2_over\" fore=\"L2UI_CH3.calculate1_2\">");
  1326. +else if (Arena5x5.registered.size() == 3)
  1327. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_3_over\" fore=\"L2UI_CH3.calculate1_3\">");
  1328. +else if (Arena5x5.registered.size() == 4)
  1329. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_4_over\" fore=\"L2UI_CH3.calculate1_4\">");
  1330. +else if (Arena5x5.registered.size() == 5)
  1331. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_5_over\" fore=\"L2UI_CH3.calculate1_5\">");
  1332. +else if (Arena5x5.registered.size() == 6)
  1333. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_6_over\" fore=\"L2UI_CH3.calculate1_6\">");
  1334. +else if (Arena5x5.registered.size() == 7)
  1335. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_7_over\" fore=\"L2UI_CH3.calculate1_7\">");
  1336. +else if (Arena5x5.registered.size() == 8)
  1337. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_8_over\" fore=\"L2UI_CH3.calculate1_8\">");
  1338. +else if (Arena5x5.registered.size() >= 9)
  1339. +html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_9_over\" fore=\"L2UI_CH3.calculate1_9\">");
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345. else if (player.titan_cont > ArenaConfig.titan_COUNT_5X5)
  1346. {
  1347. player.sendMessage("Tournament: Only " + ArenaConfig.titan_COUNT_5X5 + " Titan's allowed per party.");
  1348. player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.titan_COUNT_5X5 + " Titan's allowed per party.", 6 * 1000));
  1349. clean(player);
  1350. return;
  1351. }
  1352. else if (player.dominator_cont > ArenaConfig.dominator_COUNT_5X5)
  1353. {
  1354. player.sendMessage("Tournament: Only " + ArenaConfig.dominator_COUNT_5X5 + " Dominator's or " + ArenaConfig.dominator_COUNT_5X5 + " Doomcryer's allowed per party.");
  1355. player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.dominator_COUNT_5X5 + " Dominator's or " + ArenaConfig.dominator_COUNT_5X5 + " Doomcryer's allowed per party.", 6 * 1000));
  1356. clean(player);
  1357. return;
  1358. }
  1359. +else if (Arena5x5.getInstance().register(player, assist1, assist2, assist3, assist4) && (player.getParty().getMembers().get(1) != null && player.getParty().getMembers().get(2) != null && player.getParty().getMembers().get(3) != null && player.getParty().getMembers().get(4) != null))
  1360. +{
  1361. +player.sendMessage("Tournament: Your participation has been approved.");
  1362. +assist1.sendMessage("Tournament: Your participation has been approved.");
  1363. +assist2.sendMessage("Tournament: Your participation has been approved.");
  1364. +assist3.sendMessage("Tournament: Your participation has been approved.");
  1365. +assist4.sendMessage("Tournament: Your participation has been approved.");
  1366. +
  1367. +player.setArenaProtection(true);
  1368. +assist1.setArenaProtection(true);
  1369. +assist2.setArenaProtection(true);
  1370. +assist3.setArenaProtection(true);
  1371. +assist4.setArenaProtection(true);
  1372. +
  1373. +player.setArena5x5(true);
  1374. +assist1.setArena5x5(true);
  1375. +assist2.setArena5x5(true);
  1376. +assist3.setArena5x5(true);
  1377. +assist4.setArena5x5(true);
  1378. +clean(player);
  1379. +showChatWindow(player);
  1380. +}
  1381. +else
  1382. +player.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  1383. +}
  1384. if (command.startsWith("9x9"))
  1385.  
  1386.  
  1387.  
  1388. if (player.isArena1x1())
  1389. Arena1x1.getInstance().remove(player);
  1390. if (player.isArena3x3())
  1391. Arena3x3.getInstance().remove(player);
  1392. +if (player.isArena5x5())
  1393. +Arena5x5.getInstance().remove(player);
  1394.  
  1395.  
  1396. Creature.java
  1397.  
  1398.  
  1399. public boolean isArena3x3()
  1400. {
  1401. return _Arena3x3;
  1402. }
  1403.  
  1404. + private boolean _Arena5x5;
  1405. +
  1406. + public void setArena5x5(boolean comm)
  1407. + {
  1408. + _Arena5x5 = comm;
  1409. + }
  1410. +
  1411. + public boolean isArena5x5()
  1412. + {
  1413. + return _Arena5x5;
  1414. + }
  1415.  
  1416.  
  1417. Playable.java
  1418. Troca a linha que ta só outros por essa
  1419.  
  1420. +else if (Config.LEAVE_BUFFS_ON_DIE || (isArenaAttack() && (isArena9x9() || (isArena5x5() && ArenaConfig.ALLOW_5X5_LOSTBUFF))) || (CTF.is_started() && _inEventCTF && Config.CTF_REMOVE_BUFFS_ON_DIE))
  1421. stopAllEffectsExceptThoseThatLastThroughDeath();
  1422.  
  1423.  
  1424. Player.java
  1425.  
  1426.  
  1427. // Can't use Hero and resurrect skills during Olympiad
  1428. if (isInOlympiadMode() && (skill.isHeroSkill() || skill.getSkillType() == L2SkillType.RESURRECT))
  1429. {
  1430. sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_SKILL_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
  1431. return false;
  1432. }
  1433.  
  1434. + if (isArenaProtection() && ((isArena5x5() && ArenaConfig.bs_COUNT_5X5 == 0) || isArena3x3()) && (skill.getSkillType() == L2SkillType.RESURRECT))
  1435. + {
  1436. + sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED).addSkillName(skill));
  1437. + return false;
  1438. + }
  1439. +
  1440. + if (isArenaProtection() && !isArena5x5() && !isArena9x9() && ArenaConfig.ARENA_SKILL_LIST.contains(skill.getId()))
  1441. + {
  1442. + sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED).addSkillName(skill));
  1443. + return false;
  1444. + }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement