Sarada-L2

Tournament Frozen Yo: Sarada

Mar 7th, 2021 (edited)
1,131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 299.05 KB | None | 0 0
  1. diff --git a/config/CustomMods/Events/Tournament.ini b/config/CustomMods/Events/Tournament.ini
  2. new file mode 100644
  3. index 0000000..d8c3339
  4. --- /dev/null
  5. +++ b/config/CustomMods/Events/Tournament.ini
  6. @@ -0,0 +1,160 @@
  7. +TournamentStartOn = True
  8. +TournamentAutoEvent = True
  9. +TournamenAnnounce = True
  10. +TournamentSummon = False
  11. +
  12. +# ArenaStartTime= 15:30,22:30
  13. +TournamentStartTime = 14:00,22:18
  14. +TournamentEventTime = 45
  15. +
  16. +TitleColorTeam_1 = 00ff00
  17. +TitleColorTeam_2 = FFFF00
  18. +
  19. +# ID do NPC de Registro
  20. +NPCRegister = 10006
  21. +
  22. +# Local do NPC de Registro.
  23. +Locx = -20168
  24. +Locy = -21048
  25. +Locz = -3024
  26. +Heading = 32381
  27. +
  28. +# Local do NPC de Registro.
  29. +Locx2 = -21463
  30. +Locy2 = -21014
  31. +Locz2 = -3023
  32. +Heading2 = 776
  33. +
  34. +TournamentLocx = -20808
  35. +TournamentLocy = -21032
  36. +TournamentLocz = -3024
  37. +
  38. +Allow1x1Register = True
  39. +Allow3x3Register = True
  40. +Allow5x5Register = True
  41. +Allow9x9Register = True
  42. +
  43. +Allow5x5LostBuff = false
  44. +
  45. +ScreenArenaMessageEnable = True
  46. +ScreenArenaMessageText = Tournament Event
  47. +ScreenArenaMessageTime = 6
  48. +
  49. +Allow_Same_HWID_On_Tournament = True
  50. +
  51. +# Arenas Location 1x1
  52. +# e.g: 149360, 46594, -3415; x, y, z; x1, y1, z1
  53. +ArenasLoc1x1 = -120280,-225003,-3327;-102487,-209004,-3327;-120247,-207371,-3327;-87512,-224987,-3327;-81737,-213211,-3327;-87472,-207354,-3327;-93802,-218254,-3327;-77112,-218700,-3327;-69719,-209034,-3327;-76824,-201226,-3327;-109880,-218699,-3327;-126584,-218251,-3327;-109592,-201227,-3327;-87480,-240142,-3327;-81752,-245964,-3327;-77111,-251482,-3327;-69719,-241771,-3327;-76823,-233995,-3327;-93815,-251034,-3327;-87512,-257787,-3327;-114536,-213194,-3327;
  54. +
  55. +# Arenas Location 3x3
  56. +# e.g: 149360, 46594, -3415; x, y, z; x1, y1, z1
  57. +ArenasLoc3x3 = -120280,-225003,-3327;-102487,-209004,-3327;-120247,-207371,-3327;-87512,-224987,-3327;-81737,-213211,-3327;-87472,-207354,-3327;-93802,-218254,-3327;-77112,-218700,-3327;-69719,-209034,-3327;-76824,-201226,-3327;-109880,-218699,-3327;-126584,-218251,-3327;-109592,-201227,-3327;-87480,-240142,-3327;-81752,-245964,-3327;-77111,-251482,-3327;-69719,-241771,-3327;-76823,-233995,-3327;-93815,-251034,-3327;-87512,-257787,-3327;-114536,-213194,-3327;
  58. +
  59. +# Arenas Location 5x5
  60. +# e.g: 149360, 46594, -3415; x, y, z; x1, y1, z1
  61. +Arenas5x5Loc = -120280,-225003,-3327;-102487,-209004,-3327;-120247,-207371,-3327;-87512,-224987,-3327;-81737,-213211,-3327;-87472,-207354,-3327;-93802,-218254,-3327;-77112,-218700,-3327;-69719,-209034,-3327;-76824,-201226,-3327;-109880,-218699,-3327;-126584,-218251,-3327;-109592,-201227,-3327;-87480,-240142,-3327;-81752,-245964,-3327;-77111,-251482,-3327;-69719,-241771,-3327;-76823,-233995,-3327;-93815,-251034,-3327;-87512,-257787,-3327;-114536,-213194,-3327;
  62. +
  63. +# Arenas Location 9x9
  64. +# e.g: 149360, 46594, -3415; x, y, z; x1, y1, z1
  65. +Arenas9x9Loc = -120280,-225003,-3327;-102487,-209004,-3327;-120247,-207371,-3327;-87512,-224987,-3327;-81737,-213211,-3327;-87472,-207354,-3327;-93802,-218254,-3327;-77112,-218700,-3327;-69719,-209034,-3327;-76824,-201226,-3327;-109880,-218699,-3327;-126584,-218251,-3327;-109592,-201227,-3327;-87480,-240142,-3327;-81752,-245964,-3327;-77111,-251482,-3327;-69719,-241771,-3327;-76823,-233995,-3327;-93815,-251034,-3327;-87512,-257787,-3327;-114536,-213194,-3327;
  66. +
  67. +#===========================
  68. +# Class amount Arena 5x5 #
  69. +#===========================
  70. +bs_amount_5x5 = 0
  71. +archer_amount_5x5 = 3
  72. +dominator_amount_5x5 = 1
  73. +duelist_amount_5x5 = 1
  74. +dreadnought_amount_5x5 = 1
  75. +tanker_amount_5x5 = 1
  76. +dagger_amount_5x5 = 2
  77. +archmage_amount_5x5 = 3
  78. +soultaker_amount_5x5 = 3
  79. +mysticMuse_amount_5x5 = 3
  80. +stormScreamer_amount_5x5 = 3
  81. +titan_amount_5x5 = 1
  82. +grandKhauatari_amount_5x5 = 1
  83. +doomcryer_amount_5x5 = 1
  84. +
  85. +#===========================
  86. +# Class amount Arena 9x9 #
  87. +#===========================
  88. +bs_amount_9x9 = 2
  89. +archer_amount_9x9 = 9
  90. +dominator_amount_9x9 = 2
  91. +duelist_amount_9x9 = 1
  92. +dreadnought_amount_9x9 = 1
  93. +tanker_amount_9x9 = 1
  94. +dagger_amount_9x9 = 2
  95. +archmage_amount_9x9 = 9
  96. +soultaker_amount_9x9 = 9
  97. +mysticMuse_amount_9x9 = 9
  98. +stormScreamer_amount_9x9 = 9
  99. +titan_amount_9x9 = 1
  100. +grandKhauatari_amount_9x9 = 1
  101. +doomcryer_amount_9x9 = 2
  102. +
  103. +# Rate Drop VIP Winners
  104. +ArenaRateDropVIP = 1
  105. +# item to give to winners
  106. +ArenaRewardId = 57
  107. +
  108. +# Count of item to give to winners
  109. +ArenaWinRewardCount1x1 = 3
  110. +
  111. +# Count of item to give to losers
  112. +ArenaLostRewardCount1x1 = 0
  113. +
  114. +# Count of item to give to winners
  115. +ArenaWinRewardCount3x3 = 5
  116. +
  117. +# Count of item to give to losers
  118. +ArenaLostRewardCount3x3 = 0
  119. +
  120. +# Count of item to give to winners
  121. +ArenaWinRewardCount5x5 = 10
  122. +
  123. +# Count of item to give to losers
  124. +ArenaLostRewardCount5x5 = 2
  125. +
  126. +# Count of item to give to winners
  127. +ArenaWinRewardCount9x9 = 15
  128. +
  129. +# Count of item to give to losers
  130. +ArenaLostRewardCount9x9 = 3
  131. +
  132. +# Time between check players status [in seconds]
  133. +ArenaBattleCheckInterval = 5
  134. +
  135. +# Time between Call registered players [in seconds]
  136. +ArenaBattleCallInterval = 2
  137. +
  138. +# Time to start battle after players are called [in seconds]
  139. +ArenaBattleWaitInterval1x1 = 15
  140. +
  141. +ArenaBattleWaitInterval3x3 = 15
  142. +
  143. +ArenaBattleWaitInterval5x5 = 15
  144. +
  145. +ArenaBattleWaitInterval9x9 = 30
  146. +
  147. +# Tournament Restriction Items
  148. +# format: id,id,id
  149. +ItemsRestriction = 737,3936,3959,8627,8639,6387
  150. +
  151. +# Remover efeito e desativar Skill em Arena
  152. +ArenaSkillProtect = True
  153. +
  154. +#Lista de Skill Proibidas
  155. +ArenaDisableSkillList = 1410,438,1016,1254,3160,1410,3123
  156. +
  157. +#desativar skill ao iniciar
  158. +ArenaDisableSkillList_noStart = 313,420,176,139,406
  159. +
  160. +#Remover efeito das skills
  161. +ArenaStopSkillList = 420,406,176,139,1410,438,313,5105,5104
  162. +
  163. +DebugArena = False
  164. +
  165. +#Desativar permanentement
  166. +DisableSkillList = 395,1419,458,457,454,460,459,1423,1424,1426,455,1421,1428,1420,456,1427
  167. diff --git a/head-src/Dev/Tournament/Arena1x1.java b/head-src/Dev/Tournament/Arena1x1.java
  168. new file mode 100644
  169. index 0000000..7b44a28
  170. --- /dev/null
  171. +++ b/head-src/Dev/Tournament/Arena1x1.java
  172. @@ -0,0 +1,684 @@
  173. +package Dev.Tournament;
  174. +
  175. +import com.l2jfrozen.gameserver.model.L2Character;
  176. +import com.l2jfrozen.gameserver.model.L2Effect;
  177. +import com.l2jfrozen.gameserver.model.L2Summon;
  178. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  179. +import com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance;
  180. +import com.l2jfrozen.gameserver.model.base.ClassId;
  181. +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
  182. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  183. +import com.l2jfrozen.gameserver.util.Broadcast;
  184. +import com.l2jfrozen.util.random.Rnd;
  185. +import java.util.ArrayList;
  186. +import java.util.HashMap;
  187. +import java.util.List;
  188. +import java.util.Map;
  189. +
  190. +import Dev.Tournament.properties.ArenaConfig;
  191. +import Dev.Tournament.properties.ArenaTask;
  192. +
  193. +public class Arena1x1 implements Runnable
  194. +{
  195. + // list of participants
  196. + public static List<Pair> registered;
  197. + // number of Arenas
  198. + int free = ArenaConfig.ARENA_EVENT_COUNT_1X1;
  199. + // Arenas
  200. + Arena[] arenas = new Arena[ArenaConfig.ARENA_EVENT_COUNT_1X1];
  201. + // list of fights going on
  202. + Map<Integer, String> fights = new HashMap<>(ArenaConfig.ARENA_EVENT_COUNT_1X1);
  203. +
  204. + public Arena1x1()
  205. + {
  206. + registered = new ArrayList<>();
  207. + int[] coord;
  208. + for (int i = 0; i < ArenaConfig.ARENA_EVENT_COUNT_1X1; i++)
  209. + {
  210. + coord = ArenaConfig.ARENA_EVENT_LOCS_1X1[i];
  211. + arenas[i] = new Arena(i, coord[0], coord[1], coord[2]);
  212. + }
  213. + }
  214. +
  215. + public static Arena1x1 getInstance()
  216. + {
  217. + return SingletonHolder.INSTANCE;
  218. + }
  219. +
  220. + public boolean register(L2PcInstance player)
  221. + {
  222. + for (Pair p : registered)
  223. + {
  224. + if (p.getLeader() == player)
  225. + {
  226. + player.sendMessage("Tournament: You already registered!");
  227. + return false;
  228. + }
  229. + }
  230. + return registered.add(new Pair(player));
  231. + }
  232. +
  233. + public boolean isRegistered(L2PcInstance player)
  234. + {
  235. + for (Pair p : registered)
  236. + {
  237. + if (p.getLeader() == player)
  238. + {
  239. + return true;
  240. + }
  241. + }
  242. + return false;
  243. + }
  244. +
  245. + public Map<Integer, String> getFights()
  246. + {
  247. + return fights;
  248. + }
  249. +
  250. + public boolean remove(L2PcInstance player)
  251. + {
  252. + for (Pair p : registered)
  253. + {
  254. + if (p.getLeader() == player)
  255. + {
  256. + p.removeMessage();
  257. + registered.remove(p);
  258. + return true;
  259. + }
  260. + }
  261. + return false;
  262. + }
  263. +
  264. + @Override
  265. + public synchronized void run()
  266. + {
  267. + boolean load = true;
  268. +
  269. + // while server is running
  270. + while (load)
  271. + {
  272. + if (!ArenaTask.is_started())
  273. + load = false;
  274. +
  275. + // if no have participants or arenas are busy wait 1 minute
  276. + if (registered.size() < 2 || free == 0)
  277. + {
  278. + try
  279. + {
  280. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  281. + }
  282. + catch (InterruptedException e)
  283. + {
  284. + }
  285. + continue;
  286. + }
  287. + List<Pair> opponents = selectOpponents();
  288. + if (opponents != null && opponents.size() == 2)
  289. + {
  290. + Thread T = new Thread(new EvtArenaTask(opponents));
  291. + T.setDaemon(true);
  292. + T.start();
  293. + }
  294. + // wait 1 minute for not stress server
  295. + try
  296. + {
  297. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  298. + }
  299. + catch (InterruptedException e)
  300. + {
  301. + }
  302. + }
  303. + }
  304. +
  305. + @SuppressWarnings("null")
  306. + private List<Pair> selectOpponents()
  307. + {
  308. + List<Pair> opponents = new ArrayList<>();
  309. + Pair pairOne = null, pairTwo = null;
  310. + int tries = 3;
  311. + do
  312. + {
  313. + int first = 0, second = 0;
  314. + if (getRegisteredCount() < 2)
  315. + return opponents;
  316. +
  317. + if (pairOne == null)
  318. + {
  319. + first = Rnd.get(getRegisteredCount());
  320. + pairOne = registered.get(first);
  321. + if (pairOne.check())
  322. + {
  323. + opponents.add(0, pairOne);
  324. + registered.remove(first);
  325. + }
  326. + else
  327. + {
  328. + pairOne = null;
  329. + registered.remove(first);
  330. + return null;
  331. + }
  332. +
  333. + }
  334. + if (pairTwo == null)
  335. + {
  336. + second = Rnd.get(getRegisteredCount());
  337. + pairTwo = registered.get(second);
  338. + if (pairTwo.check())
  339. + {
  340. + opponents.add(1, pairTwo);
  341. + registered.remove(second);
  342. + }
  343. + else
  344. + {
  345. + pairTwo = null;
  346. + registered.remove(second);
  347. + return null;
  348. + }
  349. +
  350. + }
  351. + }
  352. + while ((pairOne == null || pairTwo == null) && --tries > 0);
  353. + return opponents;
  354. + }
  355. +
  356. + public void clear()
  357. + {
  358. + registered.clear();
  359. + }
  360. +
  361. + public static int getRegisteredCount()
  362. + {
  363. + return registered.size();
  364. + }
  365. +
  366. + private class Pair
  367. + {
  368. + private L2PcInstance leader;
  369. +
  370. + public Pair(L2PcInstance leader)
  371. + {
  372. + this.leader = leader;
  373. + }
  374. +
  375. + public L2PcInstance getLeader()
  376. + {
  377. + return leader;
  378. + }
  379. +
  380. + public boolean check()
  381. + {
  382. + if ((!(leader == null || leader.isOnline() == 1)))
  383. + return false;
  384. +
  385. + return true;
  386. + }
  387. +
  388. + public boolean isDead()
  389. + {
  390. + if (ArenaConfig.ARENA_PROTECT)
  391. + {
  392. + if (leader != null && leader.isOnline() == 1 && leader.isArenaAttack() && !leader.isDead() && !leader.isInsideZone(L2Character.ARENA_EVENT))
  393. + leader.logout();
  394. + }
  395. +
  396. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()))
  397. + return false;
  398. +
  399. + return !(leader.isDead());
  400. + }
  401. +
  402. + public boolean isAlive()
  403. + {
  404. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()))
  405. + return false;
  406. +
  407. + return !(leader.isDead());
  408. + }
  409. +
  410. + public void teleportTo(int x, int y, int z)
  411. + {
  412. + if (leader != null && leader.isOnline() == 1)
  413. + {
  414. + //leader.getAppearance().setInvisible();
  415. + leader.setCurrentCp(leader.getMaxCp());
  416. + leader.setCurrentHp(leader.getMaxHp());
  417. + leader.setCurrentMp(leader.getMaxMp());
  418. +
  419. + /*
  420. + if (leader.isInObserverMode())
  421. + {
  422. + leader.setLastCords(x, y, z);
  423. + leader.leaveOlympiadObserverMode();
  424. + }
  425. + */
  426. + if (!leader.isInJail())
  427. + leader.teleToLocation(x, y, z);
  428. +
  429. + leader.broadcastUserInfo();
  430. + }
  431. + }
  432. +
  433. + public void EventTitle(String title, String color)
  434. + {
  435. + if (leader != null && leader.isOnline() == 1)
  436. + {
  437. + leader.setTitle(title);
  438. + leader.getAppearance().setTitleColor(Integer.decode("0x" + color));
  439. + leader.broadcastUserInfo();
  440. + leader.broadcastTitleInfo();
  441. + }
  442. + }
  443. +
  444. + public void saveTitle()
  445. + {
  446. + if (leader != null && leader.isOnline() == 1)
  447. + {
  448. + leader._originalTitleColorTournament = leader.getAppearance().getTitleColor();
  449. + leader._originalTitleTournament = leader.getTitle();
  450. + }
  451. + }
  452. +
  453. + public void backTitle()
  454. + {
  455. + if (leader != null && leader.isOnline() == 1)
  456. + {
  457. + leader.setTitle(leader._originalTitleTournament);
  458. + leader.getAppearance().setTitleColor(leader._originalTitleColorTournament);
  459. + leader.broadcastUserInfo();
  460. + leader.broadcastTitleInfo();
  461. + }
  462. + }
  463. +
  464. + public void setArenaInstance()
  465. + {
  466. + if (leader != null && leader.isOnline() == 1)
  467. + leader.setInstanceId(1); //1x1 Tournament Instance
  468. + }
  469. +
  470. + public void setRealInstance()
  471. + {
  472. + if (leader != null && leader.isOnline() == 1)
  473. + leader.setInstanceId(0);
  474. + }
  475. +
  476. + public void rewards()
  477. + {
  478. + if (leader != null && leader.isOnline() == 1)
  479. + {
  480. + if (leader.isVip())
  481. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_1X1 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  482. + else
  483. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_1X1, leader, true);
  484. + }
  485. +
  486. + sendPacket("Congratulations, your team won the event!", 5);
  487. + }
  488. +
  489. + public void rewardsLost()
  490. + {
  491. + if (leader != null && leader.isOnline() == 1)
  492. + {
  493. + if (leader.isVip())
  494. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_1X1 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  495. + else
  496. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_1X1, leader, true);
  497. + }
  498. +
  499. + sendPacket("your team lost the event! =(", 5);
  500. + }
  501. +
  502. + public void setInTournamentEvent(boolean val)
  503. + {
  504. + if (leader != null && leader.isOnline() == 1)
  505. + leader.setInArenaEvent(val);
  506. + }
  507. +
  508. + public void removeMessage()
  509. + {
  510. + if (leader != null && leader.isOnline() == 1)
  511. + {
  512. + leader.sendMessage("Tournament: Your participation has been removed.");
  513. + leader.setArenaProtection(false);
  514. + leader.setArena1x1(false);
  515. + }
  516. + }
  517. +
  518. + public void setArenaProtection(boolean val)
  519. + {
  520. + if (leader != null && leader.isOnline() == 1)
  521. + {
  522. + leader.setArenaProtection(val);
  523. + leader.setArena1x1(val);
  524. + }
  525. + }
  526. +
  527. + public void revive()
  528. + {
  529. + if (leader != null && leader.isOnline() == 1 && leader.isDead())
  530. + leader.doRevive();
  531. + }
  532. +
  533. + public void setImobilised(boolean val)
  534. + {
  535. + if (leader != null && leader.isOnline() == 1)
  536. + {
  537. + leader.setIsInvul(val);
  538. + leader.setStopArena(val);
  539. + }
  540. + }
  541. +
  542. + public void setArenaAttack(boolean val)
  543. + {
  544. + if (leader != null && leader.isOnline() == 1)
  545. + {
  546. + leader.setArenaAttack(val);
  547. + leader.broadcastUserInfo();
  548. + }
  549. + }
  550. +
  551. + public void removePet()
  552. + {
  553. + if (leader != null && leader.isOnline() == 1)
  554. + {
  555. + // Remove Summon's buffs
  556. + if (leader.getPet() != null)
  557. + {
  558. + L2Summon summon = leader.getPet();
  559. + if (summon != null)
  560. + summon.unSummon(summon.getOwner());
  561. +
  562. + if (summon instanceof L2PetInstance)
  563. + summon.unSummon(leader);
  564. + }
  565. +
  566. + if (leader.getMountType() == 1 || leader.getMountType() == 2)
  567. + leader.dismount();
  568. + }
  569. + }
  570. +
  571. + public void removeSkills()
  572. + {
  573. + if (!(leader.getClassId() == ClassId.shillenElder || leader.getClassId() == ClassId.shillienSaint || leader.getClassId() == ClassId.bishop || leader.getClassId() == ClassId.cardinal || leader.getClassId() == ClassId.elder || leader.getClassId() == ClassId.evaSaint))
  574. + {
  575. + for (L2Effect effect : leader.getAllEffects())
  576. + {
  577. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  578. + leader.stopSkillEffects(effect.getSkill().getId());
  579. + }
  580. + }
  581. + }
  582. +
  583. + public void sendPacket(String message, int duration)
  584. + {
  585. + if (leader != null && leader.isOnline() == 1)
  586. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  587. + }
  588. +
  589. + public void inicarContagem(int duration)
  590. + {
  591. + if (leader != null && leader.isOnline() == 1)
  592. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(leader, duration), 0);
  593. + }
  594. +
  595. + public void sendPacketinit(String message, int duration)
  596. + {
  597. + if (leader != null && leader.isOnline() == 1)
  598. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  599. + }
  600. + }
  601. +
  602. + private class EvtArenaTask implements Runnable
  603. + {
  604. + private final Pair pairOne;
  605. + private final Pair pairTwo;
  606. + private final int pOneX, pOneY, pOneZ, pTwoX, pTwoY, pTwoZ;
  607. + private Arena arena;
  608. +
  609. + public EvtArenaTask(List<Pair> opponents)
  610. + {
  611. + pairOne = opponents.get(0);
  612. + pairTwo = opponents.get(1);
  613. + L2PcInstance leader = pairOne.getLeader();
  614. + pOneX = leader.getX();
  615. + pOneY = leader.getY();
  616. + pOneZ = leader.getZ();
  617. + leader = pairTwo.getLeader();
  618. + pTwoX = leader.getX();
  619. + pTwoY = leader.getY();
  620. + pTwoZ = leader.getZ();
  621. + }
  622. +
  623. + @Override
  624. + public void run()
  625. + {
  626. + free--;
  627. + pairOne.saveTitle();
  628. + pairTwo.saveTitle();
  629. + portPairsToArena();
  630. + pairOne.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_1X1);
  631. + pairTwo.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_1X1);
  632. + try
  633. + {
  634. + Thread.sleep(ArenaConfig.ARENA_WAIT_INTERVAL_1X1 * 1000);
  635. + }
  636. + catch (InterruptedException e1)
  637. + {
  638. + }
  639. + pairOne.sendPacketinit("Started. Good Fight!", 3);
  640. + pairTwo.sendPacketinit("Started. Good Fight!", 3);
  641. + pairOne.EventTitle(ArenaConfig.MSG_TEAM1, ArenaConfig.TITLE_COLOR_TEAM1);
  642. + pairTwo.EventTitle(ArenaConfig.MSG_TEAM2, ArenaConfig.TITLE_COLOR_TEAM2);
  643. + pairOne.setImobilised(false);
  644. + pairTwo.setImobilised(false);
  645. + pairOne.setArenaAttack(true);
  646. + pairTwo.setArenaAttack(true);
  647. +
  648. + while (check())
  649. + {
  650. + // check players status each seconds
  651. + try
  652. + {
  653. + Thread.sleep(ArenaConfig.ARENA_CHECK_INTERVAL);
  654. + }
  655. + catch (InterruptedException e)
  656. + {
  657. + break;
  658. + }
  659. + }
  660. + finishDuel();
  661. + free++;
  662. + }
  663. +
  664. + private void finishDuel()
  665. + {
  666. + fights.remove(arena.id);
  667. + rewardWinner();
  668. + pairOne.revive();
  669. + pairTwo.revive();
  670. + pairOne.teleportTo(pOneX, pOneY, pOneZ);
  671. + pairTwo.teleportTo(pTwoX, pTwoY, pTwoZ);
  672. + pairOne.backTitle();
  673. + pairTwo.backTitle();
  674. + pairOne.setRealInstance();
  675. + pairTwo.setRealInstance();
  676. + pairOne.setInTournamentEvent(false);
  677. + pairTwo.setInTournamentEvent(false);
  678. + pairOne.setArenaProtection(false);
  679. + pairTwo.setArenaProtection(false);
  680. + pairOne.setArenaAttack(false);
  681. + pairTwo.setArenaAttack(false);
  682. + arena.setFree(true);
  683. + }
  684. +
  685. + private void rewardWinner()
  686. + {
  687. + L2PcInstance leader1 = pairOne.getLeader();
  688. + L2PcInstance leader2 = pairTwo.getLeader();
  689. +
  690. + if (pairOne.isAlive() && !pairTwo.isAlive())
  691. + {
  692. + if (ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  693. + Broadcast.gameAnnounceToOnlinePlayers("(1X1): (" + leader1.getName() + " VS " + leader2.getName() + ") ~> " + leader1.getName() + " win!");
  694. +
  695. + pairOne.rewards();
  696. + pairTwo.rewardsLost();
  697. + }
  698. +
  699. + if (pairTwo.isAlive() && !pairOne.isAlive())
  700. + {
  701. + if (ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  702. + Broadcast.gameAnnounceToOnlinePlayers("(1X1): (" + leader1.getName() + " VS " + leader2.getName() + ") ~> " + leader2.getName() + " win!");
  703. +
  704. + pairTwo.rewards();
  705. + pairOne.rewardsLost();
  706. + }
  707. + }
  708. +
  709. + private boolean check()
  710. + {
  711. + return (pairOne.isDead() && pairTwo.isDead());
  712. + }
  713. +
  714. + private void portPairsToArena()
  715. + {
  716. + for (Arena arena : arenas)
  717. + {
  718. + if (arena.isFree)
  719. + {
  720. + this.arena = arena;
  721. + arena.setFree(false);
  722. + pairOne.removePet();
  723. + pairTwo.removePet();
  724. + pairOne.setArenaInstance();
  725. + pairTwo.setArenaInstance();
  726. + pairOne.teleportTo(arena.x - 850, arena.y, arena.z);
  727. + pairTwo.teleportTo(arena.x + 850, arena.y, arena.z);
  728. + pairOne.setImobilised(true);
  729. + pairTwo.setImobilised(true);
  730. + pairOne.setInTournamentEvent(true);
  731. + pairTwo.setInTournamentEvent(true);
  732. + pairOne.removeSkills();
  733. + pairTwo.removeSkills();
  734. + fights.put(this.arena.id, pairOne.getLeader().getName() + " vs " + pairTwo.getLeader().getName());
  735. + break;
  736. + }
  737. + }
  738. + }
  739. + }
  740. +
  741. + private class Arena
  742. + {
  743. + protected int x, y, z;
  744. + protected boolean isFree = true;
  745. + int id;
  746. +
  747. + public Arena(int id, int x, int y, int z)
  748. + {
  749. + this.id = id;
  750. + this.x = x;
  751. + this.y = y;
  752. + this.z = z;
  753. + }
  754. +
  755. + public void setFree(boolean val)
  756. + {
  757. + isFree = val;
  758. + }
  759. + }
  760. +
  761. + protected class countdown implements Runnable
  762. + {
  763. + private final L2PcInstance _player;
  764. + private int _time;
  765. +
  766. + public countdown(L2PcInstance player, int time)
  767. + {
  768. + _time = time;
  769. + _player = player;
  770. + }
  771. +
  772. + @Override
  773. + public void run()
  774. + {
  775. + if (_player.isOnline() == 1)
  776. + {
  777. +
  778. + switch (_time)
  779. + {
  780. + case 300:
  781. + case 240:
  782. + case 180:
  783. + case 120:
  784. + case 57:
  785. + if (_player.isOnline() == 1)
  786. + {
  787. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 60 second(s)..", 4000));
  788. + _player.sendMessage("60 second(s) to start the battle.");
  789. + }
  790. + break;
  791. + case 45:
  792. + if (_player.isOnline() == 1)
  793. + {
  794. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  795. + _player.sendMessage(_time + " second(s) to start the battle!");
  796. + }
  797. + break;
  798. + case 27:
  799. + if (_player.isOnline() == 1)
  800. + {
  801. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 30 second(s)..", 4000));
  802. + _player.sendMessage("30 second(s) to start the battle.");
  803. + }
  804. + break;
  805. + case 20:
  806. + if (_player.isOnline() == 1)
  807. + {
  808. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  809. + _player.sendMessage(_time + " second(s) to start the battle!");
  810. + }
  811. + break;
  812. + case 15:
  813. + if (_player.isOnline() == 1)
  814. + {
  815. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  816. + _player.sendMessage(_time + " second(s) to start the battle!");
  817. + }
  818. + break;
  819. + case 10:
  820. + if (_player.isOnline() == 1)
  821. + _player.sendMessage(_time + " second(s) to start the battle!");
  822. + break;
  823. + case 5:
  824. + if (_player.isOnline() == 1)
  825. + _player.sendMessage(_time + " second(s) to start the battle!");
  826. + break;
  827. + case 4:
  828. + if (_player.isOnline() == 1)
  829. + _player.sendMessage(_time + " second(s) to start the battle!");
  830. + break;
  831. + case 3:
  832. + if (_player.isOnline() == 1)
  833. + _player.sendMessage(_time + " second(s) to start the battle!");
  834. + break;
  835. + case 2:
  836. + if (_player.isOnline() == 1)
  837. + _player.sendMessage(_time + " second(s) to start the battle!");
  838. + break;
  839. + case 1:
  840. + if (_player.isOnline() == 1)
  841. + _player.sendMessage(_time + " second(s) to start the battle!");
  842. + break;
  843. + }
  844. + if (_time > 1)
  845. + {
  846. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(_player, _time - 1), 1000);
  847. + }
  848. + }
  849. + }
  850. + }
  851. +
  852. + private static class SingletonHolder
  853. + {
  854. + protected static final Arena1x1 INSTANCE = new Arena1x1();
  855. + }
  856. +}
  857. \ No newline at end of file
  858. diff --git a/head-src/Dev/Tournament/Arena3x3.java b/head-src/Dev/Tournament/Arena3x3.java
  859. new file mode 100644
  860. index 0000000..b8ea57a
  861. --- /dev/null
  862. +++ b/head-src/Dev/Tournament/Arena3x3.java
  863. @@ -0,0 +1,988 @@
  864. +package Dev.Tournament;
  865. +
  866. +import com.l2jfrozen.gameserver.model.L2Character;
  867. +import com.l2jfrozen.gameserver.model.L2Effect;
  868. +import com.l2jfrozen.gameserver.model.L2Summon;
  869. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  870. +import com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance;
  871. +import com.l2jfrozen.gameserver.model.base.ClassId;
  872. +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
  873. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  874. +import com.l2jfrozen.gameserver.util.Broadcast;
  875. +import com.l2jfrozen.util.random.Rnd;
  876. +
  877. +import java.util.ArrayList;
  878. +import java.util.HashMap;
  879. +import java.util.List;
  880. +import java.util.Map;
  881. +
  882. +import Dev.Tournament.properties.ArenaConfig;
  883. +import Dev.Tournament.properties.ArenaTask;
  884. +
  885. +public class Arena3x3 implements Runnable
  886. +{
  887. + // list of participants
  888. + public static List<Pair> registered;
  889. + // number of Arenas
  890. + int free = ArenaConfig.ARENA_EVENT_COUNT_3X3;
  891. + // Arenas
  892. + Arena[] arenas = new Arena[ArenaConfig.ARENA_EVENT_COUNT_3X3];
  893. + // list of fights going on
  894. + Map<Integer, String> fights = new HashMap<>(ArenaConfig.ARENA_EVENT_COUNT_3X3);
  895. +
  896. + public Arena3x3()
  897. + {
  898. + registered = new ArrayList<>();
  899. + int[] coord;
  900. + for (int i = 0; i < ArenaConfig.ARENA_EVENT_COUNT_3X3; i++)
  901. + {
  902. + coord = ArenaConfig.ARENA_EVENT_LOCS_3X3[i];
  903. + arenas[i] = new Arena(i, coord[0], coord[1], coord[2]);
  904. + }
  905. + }
  906. +
  907. + public static Arena3x3 getInstance()
  908. + {
  909. + return SingletonHolder.INSTANCE;
  910. + }
  911. +
  912. + public boolean register(L2PcInstance player, L2PcInstance assist, L2PcInstance assist2)
  913. + {
  914. + for (Pair p : registered)
  915. + {
  916. + if (p.getLeader() == player || p.getAssist() == player)
  917. + {
  918. + player.sendMessage("Tournament: You already registered!");
  919. + return false;
  920. + }
  921. + else if (p.getLeader() == assist || p.getAssist() == assist)
  922. + {
  923. + player.sendMessage("Tournament: " + assist.getName() + " already registered!");
  924. + return false;
  925. + }
  926. + else if (p.getLeader() == assist2 || p.getAssist2() == assist2)
  927. + {
  928. + player.sendMessage("Tournament: " + assist2.getName() + " already registered!");
  929. + return false;
  930. + }
  931. + }
  932. + return registered.add(new Pair(player, assist, assist2));
  933. + }
  934. +
  935. + public boolean isRegistered(L2PcInstance player)
  936. + {
  937. + for (Pair p : registered)
  938. + {
  939. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player)
  940. + {
  941. + return true;
  942. + }
  943. + }
  944. + return false;
  945. + }
  946. +
  947. + public Map<Integer, String> getFights()
  948. + {
  949. + return fights;
  950. + }
  951. +
  952. + public boolean remove(L2PcInstance player)
  953. + {
  954. + for (Pair p : registered)
  955. + {
  956. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player)
  957. + {
  958. + p.removeMessage();
  959. + registered.remove(p);
  960. + return true;
  961. + }
  962. + }
  963. + return false;
  964. + }
  965. +
  966. + @Override
  967. + public synchronized void run()
  968. + {
  969. + boolean load = true;
  970. +
  971. + // while server is running
  972. + while (load)
  973. + {
  974. + if (!ArenaTask.is_started())
  975. + load = false;
  976. +
  977. + // if no have participants or arenas are busy wait 1 minute
  978. + if (registered.size() < 2 || free == 0)
  979. + {
  980. + try
  981. + {
  982. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  983. + }
  984. + catch (InterruptedException e)
  985. + {
  986. + }
  987. + continue;
  988. + }
  989. + List<Pair> opponents = selectOpponents();
  990. + if (opponents != null && opponents.size() == 2)
  991. + {
  992. + Thread T = new Thread(new EvtArenaTask(opponents));
  993. + T.setDaemon(true);
  994. + T.start();
  995. + }
  996. + // wait 1 minute for not stress server
  997. + try
  998. + {
  999. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  1000. + }
  1001. + catch (InterruptedException e)
  1002. + {
  1003. + }
  1004. + }
  1005. + }
  1006. +
  1007. + @SuppressWarnings("null")
  1008. + private List<Pair> selectOpponents()
  1009. + {
  1010. + List<Pair> opponents = new ArrayList<>();
  1011. + Pair pairOne = null, pairTwo = null;
  1012. + int tries = 3;
  1013. + do
  1014. + {
  1015. + int first = 0, second = 0;
  1016. + if (getRegisteredCount() < 2)
  1017. + return opponents;
  1018. +
  1019. + if (pairOne == null)
  1020. + {
  1021. + first = Rnd.get(getRegisteredCount());
  1022. + pairOne = registered.get(first);
  1023. + if (pairOne.check())
  1024. + {
  1025. + opponents.add(0, pairOne);
  1026. + registered.remove(first);
  1027. + }
  1028. + else
  1029. + {
  1030. + pairOne = null;
  1031. + registered.remove(first);
  1032. + return null;
  1033. + }
  1034. +
  1035. + }
  1036. + if (pairTwo == null)
  1037. + {
  1038. + second = Rnd.get(getRegisteredCount());
  1039. + pairTwo = registered.get(second);
  1040. + if (pairTwo.check())
  1041. + {
  1042. + opponents.add(1, pairTwo);
  1043. + registered.remove(second);
  1044. + }
  1045. + else
  1046. + {
  1047. + pairTwo = null;
  1048. + registered.remove(second);
  1049. + return null;
  1050. + }
  1051. +
  1052. + }
  1053. + }
  1054. + while ((pairOne == null || pairTwo == null) && --tries > 0);
  1055. + return opponents;
  1056. + }
  1057. +
  1058. + public void clear()
  1059. + {
  1060. + registered.clear();
  1061. + }
  1062. +
  1063. + public int getRegisteredCount()
  1064. + {
  1065. + return registered.size();
  1066. + }
  1067. +
  1068. + private class Pair
  1069. + {
  1070. + private L2PcInstance leader, assist, assist2;
  1071. +
  1072. + public Pair(L2PcInstance leader, L2PcInstance assist, L2PcInstance assist2)
  1073. + {
  1074. + this.leader = leader;
  1075. + this.assist = assist;
  1076. + this.assist2 = assist2;
  1077. + }
  1078. +
  1079. + public L2PcInstance getAssist()
  1080. + {
  1081. + return assist;
  1082. + }
  1083. +
  1084. + public L2PcInstance getAssist2()
  1085. + {
  1086. + return assist2;
  1087. + }
  1088. +
  1089. + public L2PcInstance getLeader()
  1090. + {
  1091. + return leader;
  1092. + }
  1093. +
  1094. + public boolean check()
  1095. + {
  1096. + if ((leader == null || !(leader.isOnline() == 1)))
  1097. + {
  1098. + if (assist != null || assist.isOnline() == 1)
  1099. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  1100. +
  1101. + if (assist2 != null || assist2.isOnline() == 1)
  1102. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  1103. +
  1104. + return false;
  1105. + }
  1106. +
  1107. + else if (((assist == null || !(assist.isOnline() == 1) || (assist2 == null || !(assist2.isOnline() == 1)) && (leader != null || leader.isOnline() == 1))))
  1108. + {
  1109. + leader.sendMessage("Tournament: You participation in Event was Canceled.");
  1110. +
  1111. + if (assist != null || assist.isOnline() == 1)
  1112. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  1113. +
  1114. + if (assist2 != null || assist2.isOnline() ==1)
  1115. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  1116. +
  1117. + return false;
  1118. + }
  1119. + return true;
  1120. + }
  1121. +
  1122. + public boolean isDead()
  1123. + {
  1124. + if (ArenaConfig.ARENA_PROTECT)
  1125. + {
  1126. + if (leader != null && leader.isOnline() == 1 && leader.isArenaAttack() && !leader.isDead() && !leader.isInsideZone(L2Character.ARENA_EVENT))
  1127. + leader.logout();
  1128. + if (assist != null && assist.isOnline() == 1 && assist.isArenaAttack() && !assist.isDead() && !assist.isInsideZone(L2Character.ARENA_EVENT))
  1129. + assist.logout();
  1130. + if (assist2 != null && assist2.isOnline() == 1 && assist2.isArenaAttack() && !assist2.isDead() && !assist2.isInsideZone(L2Character.ARENA_EVENT))
  1131. + assist2.logout();
  1132. + }
  1133. +
  1134. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !(assist.isOnline() == 1) || !assist.isInsideZone(L2Character.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !(assist2.isOnline() == 1) || !assist2.isInsideZone(L2Character.ARENA_EVENT)))
  1135. + return false;
  1136. +
  1137. + return !(leader.isDead() && assist.isDead() && assist2.isDead());
  1138. + }
  1139. +
  1140. + public boolean isAlive()
  1141. + {
  1142. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !(assist.isOnline() == 1) || !assist.isInsideZone(L2Character.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !(assist2.isOnline() == 1) || !assist2.isInsideZone(L2Character.ARENA_EVENT)))
  1143. + return false;
  1144. +
  1145. + return !(leader.isDead() && assist.isDead() && assist2.isDead());
  1146. + }
  1147. +
  1148. + public void teleportTo(int x, int y, int z)
  1149. + {
  1150. + if (leader != null && leader.isOnline() == 1)
  1151. + {
  1152. + //leader.getAppearance().setInvisible();
  1153. + leader.setCurrentCp(leader.getMaxCp());
  1154. + leader.setCurrentHp(leader.getMaxHp());
  1155. + leader.setCurrentMp(leader.getMaxMp());
  1156. +
  1157. + /*
  1158. + if (leader.isInObserverMode())
  1159. + {
  1160. + leader.setLastCords(x, y, z);
  1161. + leader.leaveOlympiadObserverMode();
  1162. + }
  1163. + */
  1164. + if (!leader.isInJail())
  1165. + leader.teleToLocation(x, y, z);
  1166. +
  1167. + leader.broadcastUserInfo();
  1168. +
  1169. + }
  1170. + if (assist != null && assist.isOnline() == 1)
  1171. + {
  1172. + //assist.getAppearance().setInvisible();
  1173. + assist.setCurrentCp(assist.getMaxCp());
  1174. + assist.setCurrentHp(assist.getMaxHp());
  1175. + assist.setCurrentMp(assist.getMaxMp());
  1176. +
  1177. + /*
  1178. + if (assist.isInObserverMode())
  1179. + {
  1180. + assist.setLastCords(x, y + 200, z);
  1181. + assist.leaveOlympiadObserverMode();
  1182. + }
  1183. + */
  1184. + if (!assist.isInJail())
  1185. + assist.teleToLocation(x, y + 200, z);
  1186. +
  1187. + assist.broadcastUserInfo();
  1188. + }
  1189. + if (assist2 != null && assist2.isOnline() == 1)
  1190. + {
  1191. + //assist2.getAppearance().setInvisible();
  1192. + assist2.setCurrentCp(assist2.getMaxCp());
  1193. + assist2.setCurrentHp(assist2.getMaxHp());
  1194. + assist2.setCurrentMp(assist2.getMaxMp());
  1195. +
  1196. + /*
  1197. + if (assist2.isInObserverMode())
  1198. + {
  1199. + assist2.setLastCords(x, y + 150, z);
  1200. + assist2.leaveOlympiadObserverMode();
  1201. + }
  1202. + */
  1203. + if (!assist2.isInJail())
  1204. + assist2.teleToLocation(x, y + 150, z);
  1205. +
  1206. + assist2.broadcastUserInfo();
  1207. + }
  1208. + }
  1209. +
  1210. + public void EventTitle(String title, String color)
  1211. + {
  1212. + if (leader != null && leader.isOnline() == 1)
  1213. + {
  1214. + leader.setTitle(title);
  1215. + leader.getAppearance().setTitleColor(Integer.decode("0x" + color));
  1216. + leader.broadcastUserInfo();
  1217. + leader.broadcastTitleInfo();
  1218. + }
  1219. +
  1220. + if (assist != null && assist.isOnline() == 1)
  1221. + {
  1222. + assist.setTitle(title);
  1223. + assist.getAppearance().setTitleColor(Integer.decode("0x" + color));
  1224. + assist.broadcastUserInfo();
  1225. + assist.broadcastTitleInfo();
  1226. + }
  1227. + if (assist2 != null && assist2.isOnline() == 1)
  1228. + {
  1229. + assist2.setTitle(title);
  1230. + assist2.getAppearance().setTitleColor(Integer.decode("0x" + color));
  1231. + assist2.broadcastUserInfo();
  1232. + assist2.broadcastTitleInfo();
  1233. + }
  1234. + }
  1235. +
  1236. + public void saveTitle()
  1237. + {
  1238. + if (leader != null && leader.isOnline() == 1)
  1239. + {
  1240. + leader._originalTitleColorTournament = leader.getAppearance().getTitleColor();
  1241. + leader._originalTitleTournament = leader.getTitle();
  1242. + }
  1243. +
  1244. + if (assist != null && assist.isOnline() == 1)
  1245. + {
  1246. + assist._originalTitleColorTournament = assist.getAppearance().getTitleColor();
  1247. + assist._originalTitleTournament = assist.getTitle();
  1248. + }
  1249. +
  1250. + if (assist2 != null && assist2.isOnline() == 1)
  1251. + {
  1252. + assist2._originalTitleColorTournament = assist2.getAppearance().getTitleColor();
  1253. + assist2._originalTitleTournament = assist2.getTitle();
  1254. + }
  1255. + }
  1256. +
  1257. + public void backTitle()
  1258. + {
  1259. + if (leader != null && leader.isOnline() == 1)
  1260. + {
  1261. + leader.setTitle(leader._originalTitleTournament);
  1262. + leader.getAppearance().setTitleColor(leader._originalTitleColorTournament);
  1263. + leader.broadcastUserInfo();
  1264. + leader.broadcastTitleInfo();
  1265. + }
  1266. +
  1267. + if (assist != null && assist.isOnline() == 1)
  1268. + {
  1269. + assist.setTitle(assist._originalTitleTournament);
  1270. + assist.getAppearance().setTitleColor(assist._originalTitleColorTournament);
  1271. + assist.broadcastUserInfo();
  1272. + assist.broadcastTitleInfo();
  1273. + }
  1274. +
  1275. + if (assist2 != null && assist2.isOnline() == 1)
  1276. + {
  1277. + assist2.setTitle(assist2._originalTitleTournament);
  1278. + assist2.getAppearance().setTitleColor(assist2._originalTitleColorTournament);
  1279. + assist2.broadcastUserInfo();
  1280. + assist2.broadcastTitleInfo();
  1281. + }
  1282. + }
  1283. +
  1284. + public void setArenaInstance()
  1285. + {
  1286. + if (leader != null && leader.isOnline() == 1)
  1287. + leader.setInstanceId(2); //3x3 Tournament Instance
  1288. +
  1289. + if (assist != null && assist.isOnline() == 1)
  1290. + assist.setInstanceId(2); //3x3 Tournament Instance
  1291. +
  1292. + if (assist2 != null && assist2.isOnline() == 1)
  1293. + assist2.setInstanceId(2); //3x3 Tournament Instance
  1294. + }
  1295. +
  1296. + public void setRealInstance()
  1297. + {
  1298. + if (leader != null && leader.isOnline() == 1)
  1299. + leader.setInstanceId(0);
  1300. +
  1301. + if (assist != null && assist.isOnline() == 1)
  1302. + assist.setInstanceId(0);
  1303. +
  1304. + if (assist2 != null && assist2.isOnline() == 1)
  1305. + assist2.setInstanceId(0);
  1306. + }
  1307. +
  1308. + public void rewards()
  1309. + {
  1310. + if (leader != null && leader.isOnline() == 1)
  1311. + {
  1312. + if (leader.isVip())
  1313. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_3X3 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  1314. + else
  1315. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_3X3, leader, true);
  1316. + }
  1317. +
  1318. + if (assist != null && assist.isOnline() == 1)
  1319. + {
  1320. + if (assist.isVip())
  1321. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_3X3 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  1322. + else
  1323. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_3X3, assist, true);
  1324. + }
  1325. +
  1326. + if (assist2 != null && assist2.isOnline() == 1)
  1327. + {
  1328. + if (assist2.isVip())
  1329. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_3X3 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  1330. + else
  1331. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_3X3, assist2, true);
  1332. + }
  1333. +
  1334. + sendPacket("Congratulations, your team won the event!", 5);
  1335. + }
  1336. +
  1337. + public void rewardsLost()
  1338. + {
  1339. + if (leader != null && leader.isOnline() == 1)
  1340. + {
  1341. + if (leader.isVip())
  1342. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_3X3 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  1343. + else
  1344. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_3X3, leader, true);
  1345. + }
  1346. +
  1347. + if (assist != null && assist.isOnline() == 1)
  1348. + {
  1349. + if (assist.isVip())
  1350. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_3X3 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  1351. + else
  1352. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_3X3, assist, true);
  1353. + }
  1354. + if (assist2 != null && assist2.isOnline() == 1)
  1355. + {
  1356. + if (assist2.isVip())
  1357. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_3X3 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  1358. + else
  1359. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_3X3, assist2, true);
  1360. + }
  1361. +
  1362. + sendPacket("your team lost the event! =(", 5);
  1363. + }
  1364. +
  1365. + public void setInTournamentEvent(boolean val)
  1366. + {
  1367. + if (leader != null && leader.isOnline() == 1)
  1368. + leader.setInArenaEvent(val);
  1369. +
  1370. + if (assist != null && assist.isOnline() == 1)
  1371. + assist.setInArenaEvent(val);
  1372. +
  1373. + if (assist2 != null && assist2.isOnline() == 1)
  1374. + assist2.setInArenaEvent(val);
  1375. + }
  1376. +
  1377. + public void removeMessage()
  1378. + {
  1379. + if (leader != null && leader.isOnline() == 1)
  1380. + {
  1381. + leader.sendMessage("Tournament: Your participation has been removed.");
  1382. + leader.setArenaProtection(false);
  1383. + leader.setArena3x3(false);
  1384. + }
  1385. +
  1386. + if (assist != null && assist.isOnline() == 1)
  1387. + {
  1388. + assist.sendMessage("Tournament: Your participation has been removed.");
  1389. + assist.setArenaProtection(false);
  1390. + assist.setArena3x3(false);
  1391. + }
  1392. +
  1393. + if (assist2 != null && assist2.isOnline() == 1)
  1394. + {
  1395. + assist2.sendMessage("Tournament: Your participation has been removed.");
  1396. + assist2.setArenaProtection(false);
  1397. + assist2.setArena3x3(false);
  1398. + }
  1399. + }
  1400. +
  1401. + public void setArenaProtection(boolean val)
  1402. + {
  1403. + if (leader != null && leader.isOnline() == 1)
  1404. + {
  1405. + leader.setArenaProtection(val);
  1406. + leader.setArena3x3(val);
  1407. + }
  1408. +
  1409. + if (assist != null && assist.isOnline() == 1)
  1410. + {
  1411. + assist.setArenaProtection(val);
  1412. + assist.setArena3x3(val);
  1413. + }
  1414. + if (assist2 != null && assist2.isOnline() == 1)
  1415. + {
  1416. + assist2.setArenaProtection(val);
  1417. + assist2.setArena3x3(val);
  1418. + }
  1419. + }
  1420. +
  1421. + public void revive()
  1422. + {
  1423. + if (leader != null && leader.isOnline() == 1 && leader.isDead())
  1424. + leader.doRevive();
  1425. +
  1426. + if (assist != null && assist.isOnline() == 1 && assist.isDead())
  1427. + assist.doRevive();
  1428. +
  1429. + if (assist2 != null && assist2.isOnline() == 1 && assist2.isDead())
  1430. + assist2.doRevive();
  1431. + }
  1432. +
  1433. + public void setImobilised(boolean val)
  1434. + {
  1435. + if (leader != null && leader.isOnline() == 1)
  1436. + {
  1437. + leader.setIsInvul(val);
  1438. + leader.setStopArena(val);
  1439. + }
  1440. + if (assist != null && assist.isOnline() == 1)
  1441. + {
  1442. + assist.setIsInvul(val);
  1443. + assist.setStopArena(val);
  1444. + }
  1445. + if (assist2 != null && assist2.isOnline() == 1)
  1446. + {
  1447. + assist2.setIsInvul(val);
  1448. + assist2.setStopArena(val);
  1449. + }
  1450. + }
  1451. +
  1452. + public void setArenaAttack(boolean val)
  1453. + {
  1454. + if (leader != null && leader.isOnline() == 1)
  1455. + {
  1456. + leader.setArenaAttack(val);
  1457. + leader.broadcastUserInfo();
  1458. + }
  1459. +
  1460. + if (assist != null && assist.isOnline() == 1)
  1461. + {
  1462. + assist.setArenaAttack(val);
  1463. + assist.broadcastUserInfo();
  1464. + }
  1465. +
  1466. + if (assist2 != null && assist2.isOnline() == 1)
  1467. + {
  1468. + assist2.setArenaAttack(val);
  1469. + assist2.broadcastUserInfo();
  1470. + }
  1471. + }
  1472. +
  1473. + public void removePet()
  1474. + {
  1475. + if (leader != null && leader.isOnline() == 1)
  1476. + {
  1477. + // Remove Summon's buffs
  1478. + if (leader.getPet() != null)
  1479. + {
  1480. + L2Summon summon = leader.getPet();
  1481. + if (summon != null)
  1482. + summon.unSummon(summon.getOwner());
  1483. +
  1484. + if (summon instanceof L2PetInstance)
  1485. + summon.unSummon(leader);
  1486. + }
  1487. +
  1488. + if (leader.getMountType() == 1 || leader.getMountType() == 2)
  1489. + leader.dismount();
  1490. + }
  1491. +
  1492. + if (assist != null && assist.isOnline() == 1)
  1493. + {
  1494. + // Remove Summon's buffs
  1495. + if (assist.getPet() != null)
  1496. + {
  1497. + L2Summon summon = assist.getPet();
  1498. + if (summon != null)
  1499. + summon.unSummon(summon.getOwner());
  1500. +
  1501. + if (summon instanceof L2PetInstance)
  1502. + summon.unSummon(assist);
  1503. + }
  1504. +
  1505. + if (assist.getMountType() == 1 || assist.getMountType() == 2)
  1506. + assist.dismount();
  1507. + }
  1508. +
  1509. + if (assist2 != null && assist2.isOnline() == 1)
  1510. + {
  1511. + // Remove Summon's buffs
  1512. + if (assist2.getPet() != null)
  1513. + {
  1514. + L2Summon summon = assist2.getPet();
  1515. + if (summon != null)
  1516. + summon.unSummon(summon.getOwner());
  1517. +
  1518. + if (summon instanceof L2PetInstance)
  1519. + summon.unSummon(assist2);
  1520. +
  1521. + }
  1522. +
  1523. + if (assist2.getMountType() == 1 || assist2.getMountType() == 2)
  1524. + assist2.dismount();
  1525. + }
  1526. + }
  1527. +
  1528. + public void removeSkills()
  1529. + {
  1530. + if (!(leader.getClassId() == ClassId.shillenElder || leader.getClassId() == ClassId.shillienSaint || leader.getClassId() == ClassId.bishop || leader.getClassId() == ClassId.cardinal || leader.getClassId() == ClassId.elder || leader.getClassId() == ClassId.evaSaint))
  1531. + {
  1532. + for (L2Effect effect : leader.getAllEffects())
  1533. + {
  1534. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  1535. + leader.stopSkillEffects(effect.getSkill().getId());
  1536. + }
  1537. + }
  1538. +
  1539. + if (!(assist.getClassId() == ClassId.shillenElder || assist.getClassId() == ClassId.shillienSaint || assist.getClassId() == ClassId.bishop || assist.getClassId() == ClassId.cardinal || assist.getClassId() == ClassId.elder || assist.getClassId() == ClassId.evaSaint))
  1540. + {
  1541. + for (L2Effect effect : assist.getAllEffects())
  1542. + {
  1543. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  1544. + assist.stopSkillEffects(effect.getSkill().getId());
  1545. + }
  1546. + }
  1547. +
  1548. + if (!(assist2.getClassId() == ClassId.shillenElder || assist2.getClassId() == ClassId.shillienSaint || assist2.getClassId() == ClassId.bishop || assist2.getClassId() == ClassId.cardinal || assist2.getClassId() == ClassId.elder || assist2.getClassId() == ClassId.evaSaint))
  1549. + {
  1550. + for (L2Effect effect : assist2.getAllEffects())
  1551. + {
  1552. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  1553. + assist2.stopSkillEffects(effect.getSkill().getId());
  1554. + }
  1555. + }
  1556. + }
  1557. +
  1558. + public void sendPacket(String message, int duration)
  1559. + {
  1560. + if (leader != null && leader.isOnline() == 1)
  1561. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  1562. +
  1563. + if (assist != null && assist.isOnline() == 1)
  1564. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  1565. +
  1566. + if (assist2 != null && assist2.isOnline() == 1)
  1567. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  1568. + }
  1569. +
  1570. + public void inicarContagem(int duration)
  1571. + {
  1572. + if (leader != null && leader.isOnline() == 1)
  1573. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(leader, duration), 0);
  1574. +
  1575. + if (assist != null && assist.isOnline() == 1)
  1576. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist, duration), 0);
  1577. +
  1578. + if (assist2 != null && assist2.isOnline() == 1)
  1579. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist2, duration), 0);
  1580. + }
  1581. +
  1582. + public void sendPacketinit(String message, int duration)
  1583. + {
  1584. + if (leader != null && leader.isOnline() == 1)
  1585. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1586. +
  1587. + if (assist != null && assist.isOnline() == 1)
  1588. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1589. +
  1590. + if (assist2 != null && assist2.isOnline() == 1)
  1591. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  1592. + }
  1593. + }
  1594. +
  1595. + private class EvtArenaTask implements Runnable
  1596. + {
  1597. + private final Pair pairOne;
  1598. + private final Pair pairTwo;
  1599. + private final int pOneX, pOneY, pOneZ, pTwoX, pTwoY, pTwoZ;
  1600. + private Arena arena;
  1601. +
  1602. + public EvtArenaTask(List<Pair> opponents)
  1603. + {
  1604. + pairOne = opponents.get(0);
  1605. + pairTwo = opponents.get(1);
  1606. + L2PcInstance leader = pairOne.getLeader();
  1607. + pOneX = leader.getX();
  1608. + pOneY = leader.getY();
  1609. + pOneZ = leader.getZ();
  1610. + leader = pairTwo.getLeader();
  1611. + pTwoX = leader.getX();
  1612. + pTwoY = leader.getY();
  1613. + pTwoZ = leader.getZ();
  1614. + }
  1615. +
  1616. + @Override
  1617. + public void run()
  1618. + {
  1619. + free--;
  1620. + pairOne.saveTitle();
  1621. + pairTwo.saveTitle();
  1622. + portPairsToArena();
  1623. + pairOne.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_3X3);
  1624. + pairTwo.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_3X3);
  1625. + try
  1626. + {
  1627. + Thread.sleep(ArenaConfig.ARENA_WAIT_INTERVAL_3X3 * 1000);
  1628. + }
  1629. + catch (InterruptedException e1)
  1630. + {
  1631. + }
  1632. + pairOne.sendPacketinit("Started. Good Fight!", 3);
  1633. + pairTwo.sendPacketinit("Started. Good Fight!", 3);
  1634. + pairOne.EventTitle(ArenaConfig.MSG_TEAM1, ArenaConfig.TITLE_COLOR_TEAM1);
  1635. + pairTwo.EventTitle(ArenaConfig.MSG_TEAM2, ArenaConfig.TITLE_COLOR_TEAM2);
  1636. + pairOne.setImobilised(false);
  1637. + pairTwo.setImobilised(false);
  1638. + pairOne.setArenaAttack(true);
  1639. + pairTwo.setArenaAttack(true);
  1640. +
  1641. + while (check())
  1642. + {
  1643. + // check players status each seconds
  1644. + try
  1645. + {
  1646. + Thread.sleep(ArenaConfig.ARENA_CHECK_INTERVAL);
  1647. + }
  1648. + catch (InterruptedException e)
  1649. + {
  1650. + break;
  1651. + }
  1652. + }
  1653. + finishDuel();
  1654. + free++;
  1655. + }
  1656. +
  1657. + private void finishDuel()
  1658. + {
  1659. + fights.remove(arena.id);
  1660. + rewardWinner();
  1661. + pairOne.revive();
  1662. + pairTwo.revive();
  1663. + pairOne.teleportTo(pOneX, pOneY, pOneZ);
  1664. + pairTwo.teleportTo(pTwoX, pTwoY, pTwoZ);
  1665. + pairOne.backTitle();
  1666. + pairTwo.backTitle();
  1667. + pairOne.setRealInstance();
  1668. + pairTwo.setRealInstance();
  1669. + pairOne.setInTournamentEvent(false);
  1670. + pairTwo.setInTournamentEvent(false);
  1671. + pairOne.setArenaProtection(false);
  1672. + pairTwo.setArenaProtection(false);
  1673. + pairOne.setArenaAttack(false);
  1674. + pairTwo.setArenaAttack(false);
  1675. + arena.setFree(true);
  1676. + }
  1677. +
  1678. + private void rewardWinner()
  1679. + {
  1680. + if (pairOne.isAlive() && !pairTwo.isAlive())
  1681. + {
  1682. + L2PcInstance leader1 = pairOne.getLeader();
  1683. + L2PcInstance leader2 = pairTwo.getLeader();
  1684. +
  1685. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  1686. + Broadcast.gameAnnounceToOnlinePlayers("(3X3): (" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  1687. +
  1688. + pairOne.rewards();
  1689. + pairTwo.rewardsLost();
  1690. + }
  1691. + else if (pairTwo.isAlive() && !pairOne.isAlive())
  1692. + {
  1693. + L2PcInstance leader1 = pairTwo.getLeader();
  1694. + L2PcInstance leader2 = pairOne.getLeader();
  1695. +
  1696. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  1697. + Broadcast.gameAnnounceToOnlinePlayers("(3X3): (" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  1698. +
  1699. + pairTwo.rewards();
  1700. + pairOne.rewardsLost();
  1701. + }
  1702. + }
  1703. +
  1704. + private boolean check()
  1705. + {
  1706. + return (pairOne.isDead() && pairTwo.isDead());
  1707. + }
  1708. +
  1709. + private void portPairsToArena()
  1710. + {
  1711. + for (Arena arena : arenas)
  1712. + {
  1713. + if (arena.isFree)
  1714. + {
  1715. + this.arena = arena;
  1716. + arena.setFree(false);
  1717. + pairOne.removePet();
  1718. + pairTwo.removePet();
  1719. + pairOne.setArenaInstance();
  1720. + pairTwo.setArenaInstance();
  1721. + pairOne.teleportTo(arena.x - 850, arena.y, arena.z);
  1722. + pairTwo.teleportTo(arena.x + 850, arena.y, arena.z);
  1723. + pairOne.setImobilised(true);
  1724. + pairTwo.setImobilised(true);
  1725. + pairOne.setInTournamentEvent(true);
  1726. + pairTwo.setInTournamentEvent(true);
  1727. + pairOne.removeSkills();
  1728. + pairTwo.removeSkills();
  1729. + fights.put(this.arena.id, pairOne.getLeader().getName() + " vs " + pairTwo.getLeader().getName());
  1730. + break;
  1731. + }
  1732. + }
  1733. + }
  1734. + }
  1735. +
  1736. + private class Arena
  1737. + {
  1738. + protected int x, y, z;
  1739. + protected boolean isFree = true;
  1740. + int id;
  1741. +
  1742. + public Arena(int id, int x, int y, int z)
  1743. + {
  1744. + this.id = id;
  1745. + this.x = x;
  1746. + this.y = y;
  1747. + this.z = z;
  1748. + }
  1749. +
  1750. + public void setFree(boolean val)
  1751. + {
  1752. + isFree = val;
  1753. + }
  1754. + }
  1755. +
  1756. + protected class countdown implements Runnable
  1757. + {
  1758. + private final L2PcInstance _player;
  1759. + private int _time;
  1760. +
  1761. + public countdown(L2PcInstance player, int time)
  1762. + {
  1763. + _time = time;
  1764. + _player = player;
  1765. + }
  1766. +
  1767. + @Override
  1768. + public void run()
  1769. + {
  1770. + if (_player.isOnline() == 1)
  1771. + {
  1772. +
  1773. + switch (_time)
  1774. + {
  1775. + case 300:
  1776. + case 240:
  1777. + case 180:
  1778. + case 120:
  1779. + case 57:
  1780. + if (_player.isOnline() == 1)
  1781. + {
  1782. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 60 second(s)..", 4000));
  1783. + _player.sendMessage("60 second(s) to start the battle.");
  1784. + }
  1785. + break;
  1786. + case 45:
  1787. + if (_player.isOnline() == 1)
  1788. + {
  1789. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  1790. + _player.sendMessage(_time + " second(s) to start the battle!");
  1791. + }
  1792. + break;
  1793. + case 27:
  1794. + if (_player.isOnline() == 1)
  1795. + {
  1796. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 30 second(s)..", 4000));
  1797. + _player.sendMessage("30 second(s) to start the battle.");
  1798. + }
  1799. + break;
  1800. + case 20:
  1801. + if (_player.isOnline() == 1)
  1802. + {
  1803. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  1804. + _player.sendMessage(_time + " second(s) to start the battle!");
  1805. + }
  1806. + break;
  1807. + case 15:
  1808. + if (_player.isOnline() == 1)
  1809. + {
  1810. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  1811. + _player.sendMessage(_time + " second(s) to start the battle!");
  1812. + }
  1813. + break;
  1814. + case 10:
  1815. + if (_player.isOnline() == 1)
  1816. + _player.sendMessage(_time + " second(s) to start the battle!");
  1817. + break;
  1818. + case 5:
  1819. + if (_player.isOnline() == 1)
  1820. + _player.sendMessage(_time + " second(s) to start the battle!");
  1821. + break;
  1822. + case 4:
  1823. + if (_player.isOnline() == 1)
  1824. + _player.sendMessage(_time + " second(s) to start the battle!");
  1825. + break;
  1826. + case 3:
  1827. + if (_player.isOnline() == 1)
  1828. + _player.sendMessage(_time + " second(s) to start the battle!");
  1829. + break;
  1830. + case 2:
  1831. + if (_player.isOnline() == 1)
  1832. + _player.sendMessage(_time + " second(s) to start the battle!");
  1833. + break;
  1834. + case 1:
  1835. + if (_player.isOnline() == 1)
  1836. + _player.sendMessage(_time + " second(s) to start the battle!");
  1837. + break;
  1838. + }
  1839. + if (_time > 1)
  1840. + {
  1841. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(_player, _time - 1), 1000);
  1842. + }
  1843. + }
  1844. + }
  1845. + }
  1846. +
  1847. + private static class SingletonHolder
  1848. + {
  1849. + protected static final Arena3x3 INSTANCE = new Arena3x3();
  1850. + }
  1851. +}
  1852. \ No newline at end of file
  1853. diff --git a/head-src/Dev/Tournament/Arena5x5.java b/head-src/Dev/Tournament/Arena5x5.java
  1854. new file mode 100644
  1855. index 0000000..2c49141
  1856. --- /dev/null
  1857. +++ b/head-src/Dev/Tournament/Arena5x5.java
  1858. @@ -0,0 +1,1286 @@
  1859. +package Dev.Tournament;
  1860. +
  1861. +import com.l2jfrozen.gameserver.model.L2Character;
  1862. +import com.l2jfrozen.gameserver.model.L2Effect;
  1863. +import com.l2jfrozen.gameserver.model.L2Summon;
  1864. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  1865. +import com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance;
  1866. +import com.l2jfrozen.gameserver.model.base.ClassId;
  1867. +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
  1868. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  1869. +import com.l2jfrozen.gameserver.util.Broadcast;
  1870. +import com.l2jfrozen.util.random.Rnd;
  1871. +
  1872. +import java.util.ArrayList;
  1873. +import java.util.HashMap;
  1874. +import java.util.List;
  1875. +import java.util.Map;
  1876. +
  1877. +import Dev.Tournament.properties.ArenaConfig;
  1878. +import Dev.Tournament.properties.ArenaTask;
  1879. +
  1880. +public class Arena5x5 implements Runnable
  1881. +{
  1882. + // list of participants
  1883. + public static List<Pair> registered;
  1884. + // number of Arenas
  1885. + int free = ArenaConfig.ARENA_EVENT_COUNT_5X5;
  1886. + // Arenas
  1887. + Arena[] arenas = new Arena[ArenaConfig.ARENA_EVENT_COUNT_5X5];
  1888. + // list of fights going on
  1889. + Map<Integer, String> fights = new HashMap<>(ArenaConfig.ARENA_EVENT_COUNT_5X5);
  1890. +
  1891. + public Arena5x5()
  1892. + {
  1893. + registered = new ArrayList<>();
  1894. + int[] coord;
  1895. + for (int i = 0; i < ArenaConfig.ARENA_EVENT_COUNT_5X5; i++)
  1896. + {
  1897. + coord = ArenaConfig.ARENA_EVENT_LOCS_5X5[i];
  1898. + arenas[i] = new Arena(i, coord[0], coord[1], coord[2]);
  1899. + }
  1900. + }
  1901. +
  1902. + public static Arena5x5 getInstance()
  1903. + {
  1904. + return SingletonHolder.INSTANCE;
  1905. + }
  1906. +
  1907. + public boolean register(L2PcInstance player, L2PcInstance assist, L2PcInstance assist2, L2PcInstance assist3, L2PcInstance assist4)
  1908. + {
  1909. + for (Pair p : registered)
  1910. + {
  1911. + if (p.getLeader() == player || p.getAssist() == player)
  1912. + {
  1913. + player.sendMessage("Tournament: You already registered!");
  1914. + return false;
  1915. + }
  1916. + else if (p.getLeader() == assist || p.getAssist() == assist)
  1917. + {
  1918. + player.sendMessage("Tournament: " + assist.getName() + " already registered!");
  1919. + return false;
  1920. + }
  1921. + else if (p.getLeader() == assist2 || p.getAssist2() == assist2)
  1922. + {
  1923. + player.sendMessage("Tournament: " + assist2.getName() + " already registered!");
  1924. + return false;
  1925. + }
  1926. + else if (p.getLeader() == assist3 || p.getAssist3() == assist3)
  1927. + {
  1928. + player.sendMessage("Tournament: " + assist3.getName() + " already registered!");
  1929. + return false;
  1930. + }
  1931. + else if (p.getLeader() == assist4 || p.getAssist4() == assist4)
  1932. + {
  1933. + player.sendMessage("Tournament: " + assist4.getName() + " already registered!");
  1934. + return false;
  1935. + }
  1936. + }
  1937. + return registered.add(new Pair(player, assist, assist2, assist3, assist4));
  1938. + }
  1939. +
  1940. + public boolean isRegistered(L2PcInstance player)
  1941. + {
  1942. + for (Pair p : registered)
  1943. + {
  1944. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player || p.getAssist3() == player || p.getAssist4() == player)
  1945. + {
  1946. + return true;
  1947. + }
  1948. + }
  1949. + return false;
  1950. + }
  1951. +
  1952. + public Map<Integer, String> getFights()
  1953. + {
  1954. + return fights;
  1955. + }
  1956. +
  1957. + public boolean remove(L2PcInstance player)
  1958. + {
  1959. + for (Pair p : registered)
  1960. + {
  1961. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player || p.getAssist3() == player || p.getAssist4() == player)
  1962. + {
  1963. + p.removeMessage();
  1964. + registered.remove(p);
  1965. + return true;
  1966. + }
  1967. + }
  1968. + return false;
  1969. + }
  1970. +
  1971. + @Override
  1972. + public synchronized void run()
  1973. + {
  1974. + boolean load = true;
  1975. +
  1976. + // while server is running
  1977. + while (load)
  1978. + {
  1979. + if (!ArenaTask.is_started())
  1980. + load = false;
  1981. +
  1982. + // if no have participants or arenas are busy wait 1 minute
  1983. + if (registered.size() < 2 || free == 0)
  1984. + {
  1985. + try
  1986. + {
  1987. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  1988. + }
  1989. + catch (InterruptedException e)
  1990. + {
  1991. + }
  1992. + continue;
  1993. + }
  1994. + List<Pair> opponents = selectOpponents();
  1995. + if (opponents != null && opponents.size() == 2)
  1996. + {
  1997. + Thread T = new Thread(new EvtArenaTask(opponents));
  1998. + T.setDaemon(true);
  1999. + T.start();
  2000. + }
  2001. + // wait 1 minute for not stress server
  2002. + try
  2003. + {
  2004. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  2005. + }
  2006. + catch (InterruptedException e)
  2007. + {
  2008. + }
  2009. + }
  2010. + }
  2011. +
  2012. + @SuppressWarnings("null")
  2013. + private List<Pair> selectOpponents()
  2014. + {
  2015. + List<Pair> opponents = new ArrayList<>();
  2016. + Pair pairOne = null, pairTwo = null;
  2017. + int tries = 3;
  2018. + do
  2019. + {
  2020. + int first = 0, second = 0;
  2021. + if (getRegisteredCount() < 2)
  2022. + return opponents;
  2023. +
  2024. + if (pairOne == null)
  2025. + {
  2026. + first = Rnd.get(getRegisteredCount());
  2027. + pairOne = registered.get(first);
  2028. + if (pairOne.check())
  2029. + {
  2030. + opponents.add(0, pairOne);
  2031. + registered.remove(first);
  2032. + }
  2033. + else
  2034. + {
  2035. + pairOne = null;
  2036. + registered.remove(first);
  2037. + return null;
  2038. + }
  2039. +
  2040. + }
  2041. + if (pairTwo == null)
  2042. + {
  2043. + second = Rnd.get(getRegisteredCount());
  2044. + pairTwo = registered.get(second);
  2045. + if (pairTwo.check())
  2046. + {
  2047. + opponents.add(1, pairTwo);
  2048. + registered.remove(second);
  2049. + }
  2050. + else
  2051. + {
  2052. + pairTwo = null;
  2053. + registered.remove(second);
  2054. + return null;
  2055. + }
  2056. +
  2057. + }
  2058. + }
  2059. + while ((pairOne == null || pairTwo == null) && --tries > 0);
  2060. + return opponents;
  2061. + }
  2062. +
  2063. + public void clear()
  2064. + {
  2065. + registered.clear();
  2066. + }
  2067. +
  2068. + public int getRegisteredCount()
  2069. + {
  2070. + return registered.size();
  2071. + }
  2072. +
  2073. + private class Pair
  2074. + {
  2075. + private L2PcInstance leader, assist, assist2, assist3, assist4;
  2076. +
  2077. + public Pair(L2PcInstance leader, L2PcInstance assist, L2PcInstance assist2, L2PcInstance assist3, L2PcInstance assist4)
  2078. + {
  2079. + this.leader = leader;
  2080. + this.assist = assist;
  2081. + this.assist2 = assist2;
  2082. + this.assist3 = assist3;
  2083. + this.assist4 = assist4;
  2084. + }
  2085. +
  2086. + public L2PcInstance getAssist()
  2087. + {
  2088. + return assist;
  2089. + }
  2090. +
  2091. + public L2PcInstance getAssist2()
  2092. + {
  2093. + return assist2;
  2094. + }
  2095. +
  2096. + public L2PcInstance getAssist3()
  2097. + {
  2098. + return assist3;
  2099. + }
  2100. +
  2101. + public L2PcInstance getAssist4()
  2102. + {
  2103. + return assist4;
  2104. + }
  2105. +
  2106. + public L2PcInstance getLeader()
  2107. + {
  2108. + return leader;
  2109. + }
  2110. +
  2111. + public boolean check()
  2112. + {
  2113. + if ((leader == null || !(leader.isOnline() == 1)))
  2114. + {
  2115. + if (assist != null || assist.isOnline() == 1)
  2116. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  2117. +
  2118. + if (assist2 != null || assist2.isOnline() == 1)
  2119. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  2120. +
  2121. + if (assist3 != null || assist3.isOnline() == 1)
  2122. + assist3.sendMessage("Tournament: You participation in Event was Canceled.");
  2123. +
  2124. + if (assist4 != null || assist4.isOnline() == 1)
  2125. + assist4.sendMessage("Tournament: You participation in Event was Canceled.");
  2126. +
  2127. + return false;
  2128. + }
  2129. +
  2130. + else if (((assist == null || !(assist.isOnline() == 1)) || (assist2 == null || !(assist2.isOnline() == 1)) || (assist3 == null || !(assist3.isOnline() == 1)) || (assist4 == null || !(assist4.isOnline() == 1)) && (leader != null || leader.isOnline() == 1)))
  2131. + {
  2132. + leader.sendMessage("Tournament: You participation in Event was Canceled.");
  2133. +
  2134. + if (assist != null || assist.isOnline() == 1)
  2135. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  2136. +
  2137. + if (assist2 != null || assist2.isOnline() == 1)
  2138. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  2139. +
  2140. + if (assist3 != null || assist3.isOnline() == 1)
  2141. + assist3.sendMessage("Tournament: You participation in Event was Canceled.");
  2142. +
  2143. + if (assist4 != null || assist4.isOnline() == 1)
  2144. + assist4.sendMessage("Tournament: You participation in Event was Canceled.");
  2145. +
  2146. + return false;
  2147. + }
  2148. + return true;
  2149. + }
  2150. +
  2151. + public boolean isDead()
  2152. + {
  2153. + if (ArenaConfig.ARENA_PROTECT)
  2154. + {
  2155. + if (leader != null && leader.isOnline() == 1 && leader.isArenaAttack() && !leader.isDead() && !leader.isInsideZone(L2Character.ARENA_EVENT))
  2156. + leader.logout();
  2157. + if (assist != null && assist.isOnline() == 1 && assist.isArenaAttack() && !assist.isDead() && !assist.isInsideZone(L2Character.ARENA_EVENT))
  2158. + assist.logout();
  2159. + if (assist2 != null && assist2.isOnline() == 1 && assist2.isArenaAttack() && !assist2.isDead() && !assist2.isInsideZone(L2Character.ARENA_EVENT))
  2160. + assist2.logout();
  2161. + if (assist3 != null && assist3.isOnline() == 1 && assist3.isArenaAttack() && !assist3.isDead() && !assist3.isInsideZone(L2Character.ARENA_EVENT))
  2162. + assist3.logout();
  2163. + if (assist4 != null && assist4.isOnline() == 1 && assist4.isArenaAttack() && !assist4.isDead() && !assist4.isInsideZone(L2Character.ARENA_EVENT))
  2164. + assist4.logout();
  2165. + }
  2166. +
  2167. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !(assist.isOnline() == 1) || !assist.isInsideZone(L2Character.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !(assist2.isOnline() == 1) || !assist2.isInsideZone(L2Character.ARENA_EVENT) || !assist2.isArenaAttack()) && (assist3 == null || assist3.isDead() || !(assist3.isOnline() == 1) || !assist3.isInsideZone(L2Character.ARENA_EVENT) || !assist3.isArenaAttack()) && (assist4 == null || assist4.isDead() || !(assist4.isOnline() == 1) || !assist4.isInsideZone(L2Character.ARENA_EVENT)))
  2168. + return false;
  2169. +
  2170. + return !(leader.isDead() && assist.isDead() && assist2.isDead() && assist3.isDead() && assist4.isDead());
  2171. + }
  2172. +
  2173. + public boolean isAlive()
  2174. + {
  2175. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !(assist.isOnline() == 1) || !assist.isInsideZone(L2Character.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !(assist2.isOnline() == 1) || !assist2.isInsideZone(L2Character.ARENA_EVENT) || !assist2.isArenaAttack()) && (assist3 == null || assist3.isDead() || !(assist3.isOnline() == 1) || !assist3.isInsideZone(L2Character.ARENA_EVENT) || !assist3.isArenaAttack()) && (assist4 == null || assist4.isDead() || !(assist4.isOnline() == 1) || !assist4.isInsideZone(L2Character.ARENA_EVENT)))
  2176. + return false;
  2177. +
  2178. + return !(leader.isDead() && assist.isDead() && assist2.isDead() && assist3.isDead() && assist4.isDead());
  2179. + }
  2180. +
  2181. + public void teleportTo(int x, int y, int z)
  2182. + {
  2183. + if (leader != null && leader.isOnline() == 1)
  2184. + {
  2185. + //leader.getAppearance().setInvisible();
  2186. + leader.setCurrentCp(leader.getMaxCp());
  2187. + leader.setCurrentHp(leader.getMaxHp());
  2188. + leader.setCurrentMp(leader.getMaxMp());
  2189. +
  2190. + /*
  2191. + if (leader.isInObserverMode())
  2192. + {
  2193. + leader.setLastCords(x, y, z);
  2194. + leader.leaveOlympiadObserverMode();
  2195. + }
  2196. + */
  2197. + if (!leader.isInJail())
  2198. + leader.teleToLocation(x, y, z);
  2199. +
  2200. + leader.broadcastUserInfo();
  2201. +
  2202. + }
  2203. + if (assist != null && assist.isOnline() == 1)
  2204. + {
  2205. + //assist.getAppearance().setInvisible();
  2206. + assist.setCurrentCp(assist.getMaxCp());
  2207. + assist.setCurrentHp(assist.getMaxHp());
  2208. + assist.setCurrentMp(assist.getMaxMp());
  2209. +
  2210. + /*
  2211. + if (assist.isInObserverMode())
  2212. + {
  2213. + assist.setLastCords(x, y + 200, z);
  2214. + assist.leaveOlympiadObserverMode();
  2215. + }
  2216. + */
  2217. + if (!assist.isInJail())
  2218. + assist.teleToLocation(x, y + 200, z);
  2219. +
  2220. + assist.broadcastUserInfo();
  2221. + }
  2222. + if (assist2 != null && assist2.isOnline() == 1)
  2223. + {
  2224. + //assist2.getAppearance().setInvisible();
  2225. + assist2.setCurrentCp(assist2.getMaxCp());
  2226. + assist2.setCurrentHp(assist2.getMaxHp());
  2227. + assist2.setCurrentMp(assist2.getMaxMp());
  2228. +
  2229. + /*
  2230. + if (assist2.isInObserverMode())
  2231. + {
  2232. + assist2.setLastCords(x, y + 150, z);
  2233. + assist2.leaveOlympiadObserverMode();
  2234. + }
  2235. + */
  2236. + if (!assist2.isInJail())
  2237. + assist2.teleToLocation(x, y + 150, z);
  2238. +
  2239. + assist2.broadcastUserInfo();
  2240. + }
  2241. + if (assist3 != null && assist3.isOnline() == 1)
  2242. + {
  2243. + //assist3.getAppearance().setInvisible();
  2244. + assist3.setCurrentCp(assist3.getMaxCp());
  2245. + assist3.setCurrentHp(assist3.getMaxHp());
  2246. + assist3.setCurrentMp(assist3.getMaxMp());
  2247. +
  2248. + /*
  2249. + if (assist3.isInObserverMode())
  2250. + {
  2251. + assist3.setLastCords(x, y + 100, z);
  2252. + assist3.leaveOlympiadObserverMode();
  2253. + }
  2254. + */
  2255. + if (!assist3.isInJail())
  2256. + assist3.teleToLocation(x, y + 100, z);
  2257. +
  2258. + assist3.broadcastUserInfo();
  2259. + }
  2260. + if (assist4 != null && assist4.isOnline() == 1)
  2261. + {
  2262. + //assist4.getAppearance().setInvisible();
  2263. + assist4.setCurrentCp(assist4.getMaxCp());
  2264. + assist4.setCurrentHp(assist4.getMaxHp());
  2265. + assist4.setCurrentMp(assist4.getMaxMp());
  2266. +
  2267. + /*
  2268. + if (assist4.isInObserverMode())
  2269. + {
  2270. + assist4.setLastCords(x, y + 50, z);
  2271. + assist4.leaveOlympiadObserverMode();
  2272. + }
  2273. + */
  2274. + if (!assist4.isInJail())
  2275. + assist4.teleToLocation(x, y + 50, z);
  2276. +
  2277. + assist4.broadcastUserInfo();
  2278. + }
  2279. + }
  2280. +
  2281. + public void EventTitle(String title, String color)
  2282. + {
  2283. + if (leader != null && leader.isOnline() == 1)
  2284. + {
  2285. + leader.setTitle(title);
  2286. + leader.getAppearance().setTitleColor(Integer.decode("0x" + color));
  2287. + leader.broadcastUserInfo();
  2288. + leader.broadcastTitleInfo();
  2289. + }
  2290. +
  2291. + if (assist != null && assist.isOnline() == 1)
  2292. + {
  2293. + assist.setTitle(title);
  2294. + assist.getAppearance().setTitleColor(Integer.decode("0x" + color));
  2295. + assist.broadcastUserInfo();
  2296. + assist.broadcastTitleInfo();
  2297. + }
  2298. + if (assist2 != null && assist2.isOnline() == 1)
  2299. + {
  2300. + assist2.setTitle(title);
  2301. + assist2.getAppearance().setTitleColor(Integer.decode("0x" + color));
  2302. + assist2.broadcastUserInfo();
  2303. + assist2.broadcastTitleInfo();
  2304. + }
  2305. + if (assist3 != null && assist3.isOnline() == 1)
  2306. + {
  2307. + assist3.setTitle(title);
  2308. + assist3.getAppearance().setTitleColor(Integer.decode("0x" + color));
  2309. + assist3.broadcastUserInfo();
  2310. + assist3.broadcastTitleInfo();
  2311. + }
  2312. + if (assist4 != null && assist4.isOnline() == 1)
  2313. + {
  2314. + assist4.setTitle(title);
  2315. + assist4.getAppearance().setTitleColor(Integer.decode("0x" + color));
  2316. + assist4.broadcastUserInfo();
  2317. + assist4.broadcastTitleInfo();
  2318. + }
  2319. + }
  2320. +
  2321. + public void saveTitle()
  2322. + {
  2323. + if (leader != null && leader.isOnline() == 1)
  2324. + {
  2325. + leader._originalTitleColorTournament = leader.getAppearance().getTitleColor();
  2326. + leader._originalTitleTournament = leader.getTitle();
  2327. + }
  2328. +
  2329. + if (assist != null && assist.isOnline() == 1)
  2330. + {
  2331. + assist._originalTitleColorTournament = assist.getAppearance().getTitleColor();
  2332. + assist._originalTitleTournament = assist.getTitle();
  2333. + }
  2334. +
  2335. + if (assist2 != null && assist2.isOnline() == 1)
  2336. + {
  2337. + assist2._originalTitleColorTournament = assist2.getAppearance().getTitleColor();
  2338. + assist2._originalTitleTournament = assist2.getTitle();
  2339. + }
  2340. +
  2341. + if (assist3 != null && assist3.isOnline() == 1)
  2342. + {
  2343. + assist3._originalTitleColorTournament = assist3.getAppearance().getTitleColor();
  2344. + assist3._originalTitleTournament = assist3.getTitle();
  2345. + }
  2346. +
  2347. + if (assist4 != null && assist4.isOnline() == 1)
  2348. + {
  2349. + assist4._originalTitleColorTournament = assist4.getAppearance().getTitleColor();
  2350. + assist4._originalTitleTournament = assist4.getTitle();
  2351. + }
  2352. + }
  2353. +
  2354. + public void backTitle()
  2355. + {
  2356. + if (leader != null && leader.isOnline() == 1)
  2357. + {
  2358. + leader.setTitle(leader._originalTitleTournament);
  2359. + leader.getAppearance().setTitleColor(leader._originalTitleColorTournament);
  2360. + leader.broadcastUserInfo();
  2361. + leader.broadcastTitleInfo();
  2362. + }
  2363. +
  2364. + if (assist != null && assist.isOnline() == 1)
  2365. + {
  2366. + assist.setTitle(assist._originalTitleTournament);
  2367. + assist.getAppearance().setTitleColor(assist._originalTitleColorTournament);
  2368. + assist.broadcastUserInfo();
  2369. + assist.broadcastTitleInfo();
  2370. + }
  2371. +
  2372. + if (assist2 != null && assist2.isOnline() == 1)
  2373. + {
  2374. + assist2.setTitle(assist2._originalTitleTournament);
  2375. + assist2.getAppearance().setTitleColor(assist2._originalTitleColorTournament);
  2376. + assist2.broadcastUserInfo();
  2377. + assist2.broadcastTitleInfo();
  2378. + }
  2379. +
  2380. + if (assist3 != null && assist3.isOnline() == 1)
  2381. + {
  2382. + assist3.setTitle(assist3._originalTitleTournament);
  2383. + assist3.getAppearance().setTitleColor(assist3._originalTitleColorTournament);
  2384. + assist3.broadcastUserInfo();
  2385. + assist3.broadcastTitleInfo();
  2386. + }
  2387. +
  2388. + if (assist4 != null && assist4.isOnline() == 1)
  2389. + {
  2390. + assist4.setTitle(assist4._originalTitleTournament);
  2391. + assist4.getAppearance().setTitleColor(assist4._originalTitleColorTournament);
  2392. + assist4.broadcastUserInfo();
  2393. + assist4.broadcastTitleInfo();
  2394. + }
  2395. + }
  2396. +
  2397. + public void setArenaInstance()
  2398. + {
  2399. + if (leader != null && leader.isOnline() == 1)
  2400. + leader.setInstanceId(3); //3x3 Tournament Instance
  2401. +
  2402. + if (assist != null && assist.isOnline() == 1)
  2403. + assist.setInstanceId(3); //3x3 Tournament Instance
  2404. +
  2405. + if (assist2 != null && assist2.isOnline() == 1)
  2406. + assist2.setInstanceId(3); //3x3 Tournament Instance
  2407. +
  2408. + if (assist3 != null && assist3.isOnline() == 1)
  2409. + assist3.setInstanceId(3); //3x3 Tournament Instance
  2410. +
  2411. + if (assist4 != null && assist4.isOnline() == 1)
  2412. + assist4.setInstanceId(3); //3x3 Tournament Instance
  2413. + }
  2414. +
  2415. + public void setRealInstance()
  2416. + {
  2417. + if (leader != null && leader.isOnline() == 1)
  2418. + leader.setInstanceId(0);
  2419. +
  2420. + if (assist != null && assist.isOnline() == 1)
  2421. + assist.setInstanceId(0);
  2422. +
  2423. + if (assist2 != null && assist2.isOnline() == 1)
  2424. + assist2.setInstanceId(0);
  2425. +
  2426. + if (assist3 != null && assist3.isOnline() == 1)
  2427. + assist3.setInstanceId(0);
  2428. +
  2429. + if (assist4 != null && assist4.isOnline() == 1)
  2430. + assist4.setInstanceId(0);
  2431. + }
  2432. +
  2433. + public void rewards()
  2434. + {
  2435. + if (leader != null && leader.isOnline() == 1)
  2436. + {
  2437. + if (leader.isVip())
  2438. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  2439. + else
  2440. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, leader, true);
  2441. + }
  2442. +
  2443. + if (assist != null && assist.isOnline() == 1)
  2444. + {
  2445. + if (assist.isVip())
  2446. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  2447. + else
  2448. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist, true);
  2449. + }
  2450. +
  2451. + if (assist2 != null && assist2.isOnline() == 1)
  2452. + {
  2453. + if (assist2.isVip())
  2454. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  2455. + else
  2456. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist2, true);
  2457. + }
  2458. +
  2459. + if (assist3 != null && assist3.isOnline() == 1)
  2460. + {
  2461. + if (assist3.isVip())
  2462. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist3, true);
  2463. + else
  2464. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist3, true);
  2465. + }
  2466. +
  2467. + if (assist4 != null && assist4.isOnline() == 1)
  2468. + {
  2469. + if (assist4.isVip())
  2470. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist4, true);
  2471. + else
  2472. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_5X5, assist4, true);
  2473. + }
  2474. +
  2475. + sendPacket("Congratulations, your team won the event!", 5);
  2476. + }
  2477. +
  2478. + public void rewardsLost()
  2479. + {
  2480. + if (leader != null && leader.isOnline() == 1)
  2481. + {
  2482. + if (leader.isVip())
  2483. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  2484. + else
  2485. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, leader, true);
  2486. + }
  2487. +
  2488. + if (assist != null && assist.isOnline() == 1)
  2489. + {
  2490. + if (assist.isVip())
  2491. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  2492. + else
  2493. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist, true);
  2494. + }
  2495. + if (assist2 != null && assist2.isOnline() == 1)
  2496. + {
  2497. + if (assist2.isVip())
  2498. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  2499. + else
  2500. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist2, true);
  2501. + }
  2502. + if (assist3 != null && assist3.isOnline() == 1)
  2503. + {
  2504. + if (assist3.isVip())
  2505. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist3, true);
  2506. + else
  2507. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist3, true);
  2508. + }
  2509. +
  2510. + if (assist4 != null && assist4.isOnline() == 1)
  2511. + {
  2512. + if (assist4.isVip())
  2513. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5 * ArenaConfig.ARENA_VIP_DROP_RATE, assist4, true);
  2514. + else
  2515. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_5X5, assist4, true);
  2516. + }
  2517. +
  2518. + sendPacket("your team lost the event! =(", 5);
  2519. + }
  2520. +
  2521. + public void setInTournamentEvent(boolean val)
  2522. + {
  2523. + if (leader != null && leader.isOnline() == 1)
  2524. + leader.setInArenaEvent(val);
  2525. +
  2526. + if (assist != null && assist.isOnline() == 1)
  2527. + assist.setInArenaEvent(val);
  2528. +
  2529. + if (assist2 != null && assist2.isOnline() == 1)
  2530. + assist2.setInArenaEvent(val);
  2531. +
  2532. + if (assist3 != null && assist3.isOnline() == 1)
  2533. + assist3.setInArenaEvent(val);
  2534. +
  2535. + if (assist4 != null && assist4.isOnline() == 1)
  2536. + assist4.setInArenaEvent(val);
  2537. + }
  2538. +
  2539. + public void removeMessage()
  2540. + {
  2541. + if (leader != null && leader.isOnline() == 1)
  2542. + {
  2543. + leader.sendMessage("Tournament: Your participation has been removed.");
  2544. + leader.setArenaProtection(false);
  2545. + leader.setArena5x5(false);
  2546. + }
  2547. +
  2548. + if (assist != null && assist.isOnline() == 1)
  2549. + {
  2550. + assist.sendMessage("Tournament: Your participation has been removed.");
  2551. + assist.setArenaProtection(false);
  2552. + assist.setArena5x5(false);
  2553. + }
  2554. +
  2555. + if (assist2 != null && assist2.isOnline() == 1)
  2556. + {
  2557. + assist2.sendMessage("Tournament: Your participation has been removed.");
  2558. + assist2.setArenaProtection(false);
  2559. + assist2.setArena5x5(false);
  2560. + }
  2561. +
  2562. + if (assist3 != null && assist3.isOnline() == 1)
  2563. + {
  2564. + assist3.sendMessage("Tournament: Your participation has been removed.");
  2565. + assist3.setArenaProtection(false);
  2566. + assist3.setArena5x5(false);
  2567. + }
  2568. +
  2569. + if (assist4 != null && assist4.isOnline() == 1)
  2570. + {
  2571. + assist4.sendMessage("Tournament: Your participation has been removed.");
  2572. + assist4.setArenaProtection(false);
  2573. + assist4.setArena5x5(false);
  2574. + }
  2575. + }
  2576. +
  2577. + public void setArenaProtection(boolean val)
  2578. + {
  2579. + if (leader != null && leader.isOnline() == 1)
  2580. + {
  2581. + leader.setArenaProtection(val);
  2582. + leader.setArena5x5(val);
  2583. + }
  2584. +
  2585. + if (assist != null && assist.isOnline() == 1)
  2586. + {
  2587. + assist.setArenaProtection(val);
  2588. + assist.setArena5x5(val);
  2589. + }
  2590. + if (assist2 != null && assist2.isOnline() == 1)
  2591. + {
  2592. + assist2.setArenaProtection(val);
  2593. + assist2.setArena5x5(val);
  2594. + }
  2595. +
  2596. + if (assist3 != null && assist3.isOnline() == 1)
  2597. + {
  2598. + assist3.setArenaProtection(val);
  2599. + assist3.setArena5x5(val);
  2600. + }
  2601. +
  2602. + if (assist4 != null && assist4.isOnline() == 1)
  2603. + {
  2604. + assist4.setArenaProtection(val);
  2605. + assist4.setArena5x5(val);
  2606. + }
  2607. + }
  2608. +
  2609. + public void revive()
  2610. + {
  2611. + if (leader != null && leader.isOnline() == 1 && leader.isDead())
  2612. + leader.doRevive();
  2613. +
  2614. + if (assist != null && assist.isOnline() == 1 && assist.isDead())
  2615. + assist.doRevive();
  2616. +
  2617. + if (assist2 != null && assist2.isOnline() == 1 && assist2.isDead())
  2618. + assist2.doRevive();
  2619. +
  2620. + if (assist3 != null && assist3.isOnline() == 1 && assist3.isDead())
  2621. + assist3.doRevive();
  2622. +
  2623. + if (assist4 != null && assist4.isOnline() == 1 && assist4.isDead())
  2624. + assist4.doRevive();
  2625. + }
  2626. +
  2627. + public void setImobilised(boolean val)
  2628. + {
  2629. + if (leader != null && leader.isOnline() == 1)
  2630. + {
  2631. + leader.setIsInvul(val);
  2632. + leader.setStopArena(val);
  2633. + }
  2634. + if (assist != null && assist.isOnline() == 1)
  2635. + {
  2636. + assist.setIsInvul(val);
  2637. + assist.setStopArena(val);
  2638. + }
  2639. + if (assist2 != null && assist2.isOnline() == 1)
  2640. + {
  2641. + assist2.setIsInvul(val);
  2642. + assist2.setStopArena(val);
  2643. + }
  2644. + if (assist3 != null && assist3.isOnline() == 1)
  2645. + {
  2646. + assist3.setIsInvul(val);
  2647. + assist3.setStopArena(val);
  2648. + }
  2649. + if (assist4 != null && assist4.isOnline() == 1)
  2650. + {
  2651. + assist4.setIsInvul(val);
  2652. + assist4.setStopArena(val);
  2653. + }
  2654. + }
  2655. +
  2656. + public void setArenaAttack(boolean val)
  2657. + {
  2658. + if (leader != null && leader.isOnline() == 1)
  2659. + {
  2660. + leader.setArenaAttack(val);
  2661. + leader.broadcastUserInfo();
  2662. + }
  2663. +
  2664. + if (assist != null && assist.isOnline() == 1)
  2665. + {
  2666. + assist.setArenaAttack(val);
  2667. + assist.broadcastUserInfo();
  2668. + }
  2669. +
  2670. + if (assist2 != null && assist2.isOnline() == 1)
  2671. + {
  2672. + assist2.setArenaAttack(val);
  2673. + assist2.broadcastUserInfo();
  2674. + }
  2675. +
  2676. + if (assist3 != null && assist3.isOnline() == 1)
  2677. + {
  2678. + assist3.setArenaAttack(val);
  2679. + assist3.broadcastUserInfo();
  2680. + }
  2681. +
  2682. + if (assist4 != null && assist4.isOnline() == 1)
  2683. + {
  2684. + assist4.setArenaAttack(val);
  2685. + assist4.broadcastUserInfo();
  2686. + }
  2687. + }
  2688. +
  2689. + public void removePet()
  2690. + {
  2691. + if (leader != null && leader.isOnline() == 1)
  2692. + {
  2693. + // Remove Summon's buffs
  2694. + if (leader.getPet() != null)
  2695. + {
  2696. + L2Summon summon = leader.getPet();
  2697. + if (summon != null)
  2698. + summon.unSummon(summon.getOwner());
  2699. +
  2700. + if (summon instanceof L2PetInstance)
  2701. + summon.unSummon(leader);
  2702. + }
  2703. +
  2704. + if (leader.getMountType() == 1 || leader.getMountType() == 2)
  2705. + leader.dismount();
  2706. + }
  2707. +
  2708. + if (assist != null && assist.isOnline() == 1)
  2709. + {
  2710. + // Remove Summon's buffs
  2711. + if (assist.getPet() != null)
  2712. + {
  2713. + L2Summon summon = assist.getPet();
  2714. + if (summon != null)
  2715. + summon.unSummon(summon.getOwner());
  2716. +
  2717. + if (summon instanceof L2PetInstance)
  2718. + summon.unSummon(assist);
  2719. + }
  2720. +
  2721. + if (assist.getMountType() == 1 || assist.getMountType() == 2)
  2722. + assist.dismount();
  2723. +
  2724. + }
  2725. +
  2726. + if (assist2 != null && assist2.isOnline() == 1)
  2727. + {
  2728. + // Remove Summon's buffs
  2729. + if (assist2.getPet() != null)
  2730. + {
  2731. + L2Summon summon = assist2.getPet();
  2732. + if (summon != null)
  2733. + summon.unSummon(summon.getOwner());
  2734. +
  2735. + if (summon instanceof L2PetInstance)
  2736. + summon.unSummon(assist2);
  2737. +
  2738. + }
  2739. +
  2740. + if (assist2.getMountType() == 1 || assist2.getMountType() == 2)
  2741. + assist2.dismount();
  2742. +
  2743. + }
  2744. +
  2745. + if (assist3 != null && assist3.isOnline() == 1)
  2746. + {
  2747. + // Remove Summon's buffs
  2748. + if (assist3.getPet() != null)
  2749. + {
  2750. + L2Summon summon = assist3.getPet();
  2751. + if (summon != null)
  2752. + summon.unSummon(summon.getOwner());
  2753. +
  2754. + if (summon instanceof L2PetInstance)
  2755. + summon.unSummon(assist3);
  2756. + }
  2757. +
  2758. + if (assist3.getMountType() == 1 || assist3.getMountType() == 2)
  2759. + assist3.dismount();
  2760. +
  2761. + }
  2762. +
  2763. + if (assist4 != null && assist4.isOnline() == 1)
  2764. + {
  2765. + // Remove Summon's buffs
  2766. + if (assist4.getPet() != null)
  2767. + {
  2768. + L2Summon summon = assist4.getPet();
  2769. + if (summon != null)
  2770. + summon.unSummon(summon.getOwner());
  2771. +
  2772. + if (summon instanceof L2PetInstance)
  2773. + summon.unSummon(assist4);
  2774. +
  2775. + }
  2776. +
  2777. + if (assist4.getMountType() == 1 || assist4.getMountType() == 2)
  2778. + assist4.dismount();
  2779. +
  2780. + }
  2781. + }
  2782. +
  2783. + public void removeSkills()
  2784. + {
  2785. + if (!(leader.getClassId() == ClassId.shillenElder || leader.getClassId() == ClassId.shillienSaint || leader.getClassId() == ClassId.bishop || leader.getClassId() == ClassId.cardinal || leader.getClassId() == ClassId.elder || leader.getClassId() == ClassId.evaSaint))
  2786. + {
  2787. + for (L2Effect effect : leader.getAllEffects())
  2788. + {
  2789. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  2790. + leader.stopSkillEffects(effect.getSkill().getId());
  2791. + }
  2792. + }
  2793. +
  2794. + if (!(assist.getClassId() == ClassId.shillenElder || assist.getClassId() == ClassId.shillienSaint || assist.getClassId() == ClassId.bishop || assist.getClassId() == ClassId.cardinal || assist.getClassId() == ClassId.elder || assist.getClassId() == ClassId.evaSaint))
  2795. + {
  2796. + for (L2Effect effect : assist.getAllEffects())
  2797. + {
  2798. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  2799. + assist.stopSkillEffects(effect.getSkill().getId());
  2800. + }
  2801. + }
  2802. +
  2803. + if (!(assist2.getClassId() == ClassId.shillenElder || assist2.getClassId() == ClassId.shillienSaint || assist2.getClassId() == ClassId.bishop || assist2.getClassId() == ClassId.cardinal || assist2.getClassId() == ClassId.elder || assist2.getClassId() == ClassId.evaSaint))
  2804. + {
  2805. + for (L2Effect effect : assist2.getAllEffects())
  2806. + {
  2807. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  2808. + assist2.stopSkillEffects(effect.getSkill().getId());
  2809. + }
  2810. + }
  2811. +
  2812. + if (!(assist3.getClassId() == ClassId.shillenElder || assist3.getClassId() == ClassId.shillienSaint || assist3.getClassId() == ClassId.bishop || assist3.getClassId() == ClassId.cardinal || assist3.getClassId() == ClassId.elder || assist3.getClassId() == ClassId.evaSaint))
  2813. + {
  2814. + for (L2Effect effect : assist3.getAllEffects())
  2815. + {
  2816. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  2817. + assist3.stopSkillEffects(effect.getSkill().getId());
  2818. + }
  2819. + }
  2820. +
  2821. + if (!(assist4.getClassId() == ClassId.shillenElder || assist4.getClassId() == ClassId.shillienSaint || assist4.getClassId() == ClassId.bishop || assist4.getClassId() == ClassId.cardinal || assist4.getClassId() == ClassId.elder || assist4.getClassId() == ClassId.evaSaint))
  2822. + {
  2823. + for (L2Effect effect : assist4.getAllEffects())
  2824. + {
  2825. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  2826. + assist4.stopSkillEffects(effect.getSkill().getId());
  2827. + }
  2828. + }
  2829. + }
  2830. +
  2831. + public void sendPacket(String message, int duration)
  2832. + {
  2833. + if (leader != null && leader.isOnline() == 1)
  2834. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  2835. +
  2836. + if (assist != null && assist.isOnline() == 1)
  2837. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  2838. +
  2839. + if (assist2 != null && assist2.isOnline() == 1)
  2840. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  2841. +
  2842. + if (assist3 != null && assist3.isOnline() == 1)
  2843. + assist3.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  2844. +
  2845. + if (assist4 != null && assist4.isOnline() == 1)
  2846. + assist4.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  2847. +
  2848. + }
  2849. +
  2850. + public void inicarContagem(int duration)
  2851. + {
  2852. + if (leader != null && leader.isOnline() == 1)
  2853. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(leader, duration), 0);
  2854. +
  2855. + if (assist != null && assist.isOnline() == 1)
  2856. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist, duration), 0);
  2857. +
  2858. + if (assist2 != null && assist2.isOnline() == 1)
  2859. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist2, duration), 0);
  2860. +
  2861. + if (assist3 != null && assist3.isOnline() == 1)
  2862. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist3, duration), 0);
  2863. +
  2864. + if (assist4 != null && assist4.isOnline() == 1)
  2865. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist4, duration), 0);
  2866. + }
  2867. +
  2868. + public void sendPacketinit(String message, int duration)
  2869. + {
  2870. + if (leader != null && leader.isOnline() == 1)
  2871. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  2872. +
  2873. + if (assist != null && assist.isOnline() == 1)
  2874. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  2875. +
  2876. + if (assist2 != null && assist2.isOnline() == 1)
  2877. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  2878. +
  2879. + if (assist3 != null && assist3.isOnline() == 1)
  2880. + assist3.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  2881. +
  2882. + if (assist4 != null && assist4.isOnline() == 1)
  2883. + assist4.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  2884. +
  2885. + }
  2886. + }
  2887. +
  2888. + private class EvtArenaTask implements Runnable
  2889. + {
  2890. + private final Pair pairOne;
  2891. + private final Pair pairTwo;
  2892. + private final int pOneX, pOneY, pOneZ, pTwoX, pTwoY, pTwoZ;
  2893. + private Arena arena;
  2894. +
  2895. + public EvtArenaTask(List<Pair> opponents)
  2896. + {
  2897. + pairOne = opponents.get(0);
  2898. + pairTwo = opponents.get(1);
  2899. + L2PcInstance leader = pairOne.getLeader();
  2900. + pOneX = leader.getX();
  2901. + pOneY = leader.getY();
  2902. + pOneZ = leader.getZ();
  2903. + leader = pairTwo.getLeader();
  2904. + pTwoX = leader.getX();
  2905. + pTwoY = leader.getY();
  2906. + pTwoZ = leader.getZ();
  2907. + }
  2908. +
  2909. + @Override
  2910. + public void run()
  2911. + {
  2912. + free--;
  2913. + pairOne.saveTitle();
  2914. + pairTwo.saveTitle();
  2915. + portPairsToArena();
  2916. + pairOne.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_5X5);
  2917. + pairTwo.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_5X5);
  2918. + try
  2919. + {
  2920. + Thread.sleep(ArenaConfig.ARENA_WAIT_INTERVAL_5X5 * 1000);
  2921. + }
  2922. + catch (InterruptedException e1)
  2923. + {
  2924. + }
  2925. + pairOne.sendPacketinit("Started. Good Fight!", 3);
  2926. + pairTwo.sendPacketinit("Started. Good Fight!", 3);
  2927. + pairOne.EventTitle(ArenaConfig.MSG_TEAM1, ArenaConfig.TITLE_COLOR_TEAM1);
  2928. + pairTwo.EventTitle(ArenaConfig.MSG_TEAM2, ArenaConfig.TITLE_COLOR_TEAM2);
  2929. + pairOne.setImobilised(false);
  2930. + pairTwo.setImobilised(false);
  2931. + pairOne.setArenaAttack(true);
  2932. + pairTwo.setArenaAttack(true);
  2933. +
  2934. + while (check())
  2935. + {
  2936. + // check players status each seconds
  2937. + try
  2938. + {
  2939. + Thread.sleep(ArenaConfig.ARENA_CHECK_INTERVAL);
  2940. + }
  2941. + catch (InterruptedException e)
  2942. + {
  2943. + break;
  2944. + }
  2945. + }
  2946. + finishDuel();
  2947. + free++;
  2948. + }
  2949. +
  2950. + private void finishDuel()
  2951. + {
  2952. + fights.remove(arena.id);
  2953. + rewardWinner();
  2954. + pairOne.revive();
  2955. + pairTwo.revive();
  2956. + pairOne.teleportTo(pOneX, pOneY, pOneZ);
  2957. + pairTwo.teleportTo(pTwoX, pTwoY, pTwoZ);
  2958. + pairOne.backTitle();
  2959. + pairTwo.backTitle();
  2960. + pairOne.setRealInstance();
  2961. + pairTwo.setRealInstance();
  2962. + pairOne.setInTournamentEvent(false);
  2963. + pairTwo.setInTournamentEvent(false);
  2964. + pairOne.setArenaProtection(false);
  2965. + pairTwo.setArenaProtection(false);
  2966. + pairOne.setArenaAttack(false);
  2967. + pairTwo.setArenaAttack(false);
  2968. + arena.setFree(true);
  2969. + }
  2970. +
  2971. + private void rewardWinner()
  2972. + {
  2973. + if (pairOne.isAlive() && !pairTwo.isAlive())
  2974. + {
  2975. + L2PcInstance leader1 = pairOne.getLeader();
  2976. + L2PcInstance leader2 = pairTwo.getLeader();
  2977. +
  2978. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  2979. + Broadcast.gameAnnounceToOnlinePlayers("(5X5):(" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  2980. +
  2981. + pairOne.rewards();
  2982. + pairTwo.rewardsLost();
  2983. + }
  2984. + else if (pairTwo.isAlive() && !pairOne.isAlive())
  2985. + {
  2986. + L2PcInstance leader1 = pairTwo.getLeader();
  2987. + L2PcInstance leader2 = pairOne.getLeader();
  2988. +
  2989. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  2990. + Broadcast.gameAnnounceToOnlinePlayers("(5X5):(" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  2991. +
  2992. + pairTwo.rewards();
  2993. + pairOne.rewardsLost();
  2994. + }
  2995. + }
  2996. +
  2997. + private boolean check()
  2998. + {
  2999. + return (pairOne.isDead() && pairTwo.isDead());
  3000. + }
  3001. +
  3002. + private void portPairsToArena()
  3003. + {
  3004. + for (Arena arena : arenas)
  3005. + {
  3006. + if (arena.isFree)
  3007. + {
  3008. + this.arena = arena;
  3009. + arena.setFree(false);
  3010. + pairOne.removePet();
  3011. + pairTwo.removePet();
  3012. + pairOne.setArenaInstance();
  3013. + pairTwo.setArenaInstance();
  3014. + pairOne.teleportTo(arena.x - 850, arena.y, arena.z);
  3015. + pairTwo.teleportTo(arena.x + 850, arena.y, arena.z);
  3016. + pairOne.setImobilised(true);
  3017. + pairTwo.setImobilised(true);
  3018. + pairOne.setInTournamentEvent(true);
  3019. + pairTwo.setInTournamentEvent(true);
  3020. + pairOne.removeSkills();
  3021. + pairTwo.removeSkills();
  3022. + fights.put(this.arena.id, pairOne.getLeader().getName() + " vs " + pairTwo.getLeader().getName());
  3023. + break;
  3024. + }
  3025. + }
  3026. + }
  3027. + }
  3028. +
  3029. + private class Arena
  3030. + {
  3031. + protected int x, y, z;
  3032. + protected boolean isFree = true;
  3033. + int id;
  3034. +
  3035. + public Arena(int id, int x, int y, int z)
  3036. + {
  3037. + this.id = id;
  3038. + this.x = x;
  3039. + this.y = y;
  3040. + this.z = z;
  3041. + }
  3042. +
  3043. + public void setFree(boolean val)
  3044. + {
  3045. + isFree = val;
  3046. + }
  3047. + }
  3048. +
  3049. + protected class countdown implements Runnable
  3050. + {
  3051. + private final L2PcInstance _player;
  3052. + private int _time;
  3053. +
  3054. + public countdown(L2PcInstance player, int time)
  3055. + {
  3056. + _time = time;
  3057. + _player = player;
  3058. + }
  3059. +
  3060. + @Override
  3061. + public void run()
  3062. + {
  3063. + if (_player.isOnline() == 1)
  3064. + {
  3065. +
  3066. + switch (_time)
  3067. + {
  3068. + case 300:
  3069. + case 240:
  3070. + case 180:
  3071. + case 120:
  3072. + case 57:
  3073. + if (_player.isOnline() == 1)
  3074. + {
  3075. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 60 second(s)..", 4000));
  3076. + _player.sendMessage("60 second(s) to start the battle.");
  3077. + }
  3078. + break;
  3079. + case 45:
  3080. + if (_player.isOnline() == 1)
  3081. + {
  3082. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  3083. + _player.sendMessage(_time + " second(s) to start the battle!");
  3084. + }
  3085. + break;
  3086. + case 27:
  3087. + if (_player.isOnline() == 1)
  3088. + {
  3089. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 30 second(s)..", 4000));
  3090. + _player.sendMessage("30 second(s) to start the battle.");
  3091. + }
  3092. + break;
  3093. + case 20:
  3094. + if (_player.isOnline() == 1)
  3095. + {
  3096. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  3097. + _player.sendMessage(_time + " second(s) to start the battle!");
  3098. + }
  3099. + break;
  3100. + case 15:
  3101. + if (_player.isOnline() == 1)
  3102. + {
  3103. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  3104. + _player.sendMessage(_time + " second(s) to start the battle!");
  3105. + }
  3106. + break;
  3107. + case 10:
  3108. + if (_player.isOnline() == 1)
  3109. + _player.sendMessage(_time + " second(s) to start the battle!");
  3110. + break;
  3111. + case 5:
  3112. + if (_player.isOnline() == 1)
  3113. + _player.sendMessage(_time + " second(s) to start the battle!");
  3114. + break;
  3115. + case 4:
  3116. + if (_player.isOnline() == 1)
  3117. + _player.sendMessage(_time + " second(s) to start the battle!");
  3118. + break;
  3119. + case 3:
  3120. + if (_player.isOnline() == 1)
  3121. + _player.sendMessage(_time + " second(s) to start the battle!");
  3122. + break;
  3123. + case 2:
  3124. + if (_player.isOnline() == 1)
  3125. + _player.sendMessage(_time + " second(s) to start the battle!");
  3126. + break;
  3127. + case 1:
  3128. + if (_player.isOnline() == 1)
  3129. + _player.sendMessage(_time + " second(s) to start the battle!");
  3130. + break;
  3131. + }
  3132. + if (_time > 1)
  3133. + {
  3134. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(_player, _time - 1), 1000);
  3135. + }
  3136. + }
  3137. + }
  3138. + }
  3139. +
  3140. + private static class SingletonHolder
  3141. + {
  3142. + protected static final Arena5x5 INSTANCE = new Arena5x5();
  3143. + }
  3144. +}
  3145. \ No newline at end of file
  3146. diff --git a/head-src/Dev/Tournament/Arena9x9.java b/head-src/Dev/Tournament/Arena9x9.java
  3147. new file mode 100644
  3148. index 0000000..ac82b10
  3149. --- /dev/null
  3150. +++ b/head-src/Dev/Tournament/Arena9x9.java
  3151. @@ -0,0 +1,1879 @@
  3152. +package Dev.Tournament;
  3153. +
  3154. +import com.l2jfrozen.gameserver.model.L2Character;
  3155. +import com.l2jfrozen.gameserver.model.L2Effect;
  3156. +import com.l2jfrozen.gameserver.model.L2Summon;
  3157. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  3158. +import com.l2jfrozen.gameserver.model.actor.instance.L2PetInstance;
  3159. +import com.l2jfrozen.gameserver.model.base.ClassId;
  3160. +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
  3161. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  3162. +import com.l2jfrozen.gameserver.util.Broadcast;
  3163. +import com.l2jfrozen.util.random.Rnd;
  3164. +
  3165. +import java.util.ArrayList;
  3166. +import java.util.HashMap;
  3167. +import java.util.List;
  3168. +import java.util.Map;
  3169. +
  3170. +import Dev.Tournament.properties.ArenaConfig;
  3171. +import Dev.Tournament.properties.ArenaTask;
  3172. +
  3173. +public class Arena9x9 implements Runnable
  3174. +{
  3175. + // list of participants
  3176. + public static List<Pair> registered;
  3177. + // number of Arenas
  3178. + int free = ArenaConfig.ARENA_EVENT_COUNT_9X9;
  3179. + // Arenas
  3180. + Arena[] arenas = new Arena[ArenaConfig.ARENA_EVENT_COUNT_9X9];
  3181. + // list of fights going on
  3182. + Map<Integer, String> fights = new HashMap<>(ArenaConfig.ARENA_EVENT_COUNT_9X9);
  3183. +
  3184. + public Arena9x9()
  3185. + {
  3186. + registered = new ArrayList<>();
  3187. + int[] coord;
  3188. + for (int i = 0; i < ArenaConfig.ARENA_EVENT_COUNT_9X9; i++)
  3189. + {
  3190. + coord = ArenaConfig.ARENA_EVENT_LOCS_9X9[i];
  3191. + arenas[i] = new Arena(i, coord[0], coord[1], coord[2]);
  3192. + }
  3193. + }
  3194. +
  3195. + public static Arena9x9 getInstance()
  3196. + {
  3197. + return SingletonHolder.INSTANCE;
  3198. + }
  3199. +
  3200. + public boolean register(L2PcInstance player, L2PcInstance assist, L2PcInstance assist2, L2PcInstance assist3, L2PcInstance assist4, L2PcInstance assist5, L2PcInstance assist6, L2PcInstance assist7, L2PcInstance assist8)
  3201. + {
  3202. + for (Pair p : registered)
  3203. + {
  3204. + if (p.getLeader() == player || p.getAssist() == player)
  3205. + {
  3206. + player.sendMessage("Tournament: You already registered!");
  3207. + return false;
  3208. + }
  3209. + else if (p.getLeader() == assist || p.getAssist() == assist)
  3210. + {
  3211. + player.sendMessage("Tournament: " + assist.getName() + " already registered!");
  3212. + return false;
  3213. + }
  3214. + else if (p.getLeader() == assist2 || p.getAssist2() == assist2)
  3215. + {
  3216. + player.sendMessage("Tournament: " + assist2.getName() + " already registered!");
  3217. + return false;
  3218. + }
  3219. + else if (p.getLeader() == assist3 || p.getAssist3() == assist3)
  3220. + {
  3221. + player.sendMessage("Tournament: " + assist3.getName() + " already registered!");
  3222. + return false;
  3223. + }
  3224. + else if (p.getLeader() == assist4 || p.getAssist4() == assist4)
  3225. + {
  3226. + player.sendMessage("Tournament: " + assist4.getName() + " already registered!");
  3227. + return false;
  3228. + }
  3229. + else if (p.getLeader() == assist5 || p.getAssist5() == assist5)
  3230. + {
  3231. + player.sendMessage("Tournament: " + assist5.getName() + " already registered!");
  3232. + return false;
  3233. + }
  3234. + else if (p.getLeader() == assist6 || p.getAssist6() == assist6)
  3235. + {
  3236. + player.sendMessage("Tournament: " + assist6.getName() + " already registered!");
  3237. + return false;
  3238. + }
  3239. + else if (p.getLeader() == assist7 || p.getAssist7() == assist7)
  3240. + {
  3241. + player.sendMessage("Tournament: " + assist7.getName() + " already registered!");
  3242. + return false;
  3243. + }
  3244. + else if (p.getLeader() == assist8 || p.getAssist8() == assist8)
  3245. + {
  3246. + player.sendMessage("Tournament: " + assist8.getName() + " already registered!");
  3247. + return false;
  3248. + }
  3249. + }
  3250. + return registered.add(new Pair(player, assist, assist2, assist3, assist4, assist5, assist6, assist7, assist8));
  3251. + }
  3252. +
  3253. + public boolean isRegistered(L2PcInstance player)
  3254. + {
  3255. + for (Pair p : registered)
  3256. + {
  3257. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player || p.getAssist3() == player || p.getAssist4() == player || p.getAssist5() == player || p.getAssist6() == player || p.getAssist7() == player || p.getAssist8() == player)
  3258. + {
  3259. + return true;
  3260. + }
  3261. + }
  3262. + return false;
  3263. + }
  3264. +
  3265. + public Map<Integer, String> getFights()
  3266. + {
  3267. + return fights;
  3268. + }
  3269. +
  3270. + public boolean remove(L2PcInstance player)
  3271. + {
  3272. + for (Pair p : registered)
  3273. + {
  3274. + if (p.getLeader() == player || p.getAssist() == player || p.getAssist2() == player || p.getAssist3() == player || p.getAssist4() == player || p.getAssist5() == player || p.getAssist6() == player || p.getAssist7() == player || p.getAssist8() == player)
  3275. + {
  3276. + p.removeMessage();
  3277. + registered.remove(p);
  3278. + return true;
  3279. + }
  3280. + }
  3281. + return false;
  3282. + }
  3283. +
  3284. + @Override
  3285. + public synchronized void run()
  3286. + {
  3287. + boolean load = true;
  3288. +
  3289. + // while server is running
  3290. + while (load)
  3291. + {
  3292. + if (!ArenaTask.is_started())
  3293. + load = false;
  3294. +
  3295. + // if no have participants or arenas are busy wait 1 minute
  3296. + if (registered.size() < 2 || free == 0)
  3297. + {
  3298. + try
  3299. + {
  3300. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  3301. + }
  3302. + catch (InterruptedException e)
  3303. + {
  3304. + }
  3305. + continue;
  3306. + }
  3307. + List<Pair> opponents = selectOpponents();
  3308. + if (opponents != null && opponents.size() == 2)
  3309. + {
  3310. + Thread T = new Thread(new EvtArenaTask(opponents));
  3311. + T.setDaemon(true);
  3312. + T.start();
  3313. + }
  3314. + // wait 1 minute for not stress server
  3315. + try
  3316. + {
  3317. + Thread.sleep(ArenaConfig.ARENA_CALL_INTERVAL * 1000);
  3318. + }
  3319. + catch (InterruptedException e)
  3320. + {
  3321. + }
  3322. + }
  3323. + }
  3324. +
  3325. + @SuppressWarnings("null")
  3326. + private List<Pair> selectOpponents()
  3327. + {
  3328. + List<Pair> opponents = new ArrayList<>();
  3329. + Pair pairOne = null, pairTwo = null;
  3330. + int tries = 3;
  3331. + do
  3332. + {
  3333. + int first = 0, second = 0;
  3334. + if (getRegisteredCount() < 2)
  3335. + return opponents;
  3336. +
  3337. + if (pairOne == null)
  3338. + {
  3339. + first = Rnd.get(getRegisteredCount());
  3340. + pairOne = registered.get(first);
  3341. + if (pairOne.check())
  3342. + {
  3343. + opponents.add(0, pairOne);
  3344. + registered.remove(first);
  3345. + }
  3346. + else
  3347. + {
  3348. + pairOne = null;
  3349. + registered.remove(first);
  3350. + return null;
  3351. + }
  3352. +
  3353. + }
  3354. + if (pairTwo == null)
  3355. + {
  3356. + second = Rnd.get(getRegisteredCount());
  3357. + pairTwo = registered.get(second);
  3358. + if (pairTwo.check())
  3359. + {
  3360. + opponents.add(1, pairTwo);
  3361. + registered.remove(second);
  3362. + }
  3363. + else
  3364. + {
  3365. + pairTwo = null;
  3366. + registered.remove(second);
  3367. + return null;
  3368. + }
  3369. +
  3370. + }
  3371. + }
  3372. + while ((pairOne == null || pairTwo == null) && --tries > 0);
  3373. + return opponents;
  3374. + }
  3375. +
  3376. + public void clear()
  3377. + {
  3378. + registered.clear();
  3379. + }
  3380. +
  3381. + public int getRegisteredCount()
  3382. + {
  3383. + return registered.size();
  3384. + }
  3385. +
  3386. + private class Pair
  3387. + {
  3388. + private L2PcInstance leader, assist, assist2, assist3, assist4, assist5, assist6, assist7, assist8;
  3389. +
  3390. + public Pair(L2PcInstance leader, L2PcInstance assist, L2PcInstance assist2, L2PcInstance assist3, L2PcInstance assist4, L2PcInstance assist5, L2PcInstance assist6, L2PcInstance assist7, L2PcInstance assist8)
  3391. + {
  3392. + this.leader = leader;
  3393. + this.assist = assist;
  3394. + this.assist2 = assist2;
  3395. + this.assist3 = assist3;
  3396. + this.assist4 = assist4;
  3397. + this.assist5 = assist5;
  3398. + this.assist6 = assist6;
  3399. + this.assist7 = assist7;
  3400. + this.assist8 = assist8;
  3401. + }
  3402. +
  3403. + public L2PcInstance getAssist()
  3404. + {
  3405. + return assist;
  3406. + }
  3407. +
  3408. + public L2PcInstance getAssist2()
  3409. + {
  3410. + return assist2;
  3411. + }
  3412. +
  3413. + public L2PcInstance getAssist3()
  3414. + {
  3415. + return assist3;
  3416. + }
  3417. +
  3418. + public L2PcInstance getAssist4()
  3419. + {
  3420. + return assist4;
  3421. + }
  3422. +
  3423. + public L2PcInstance getAssist5()
  3424. + {
  3425. + return assist5;
  3426. + }
  3427. +
  3428. + public L2PcInstance getAssist6()
  3429. + {
  3430. + return assist6;
  3431. + }
  3432. +
  3433. + public L2PcInstance getAssist7()
  3434. + {
  3435. + return assist7;
  3436. + }
  3437. +
  3438. + public L2PcInstance getAssist8()
  3439. + {
  3440. + return assist8;
  3441. + }
  3442. +
  3443. + public L2PcInstance getLeader()
  3444. + {
  3445. + return leader;
  3446. + }
  3447. +
  3448. + public boolean check()
  3449. + {
  3450. + if ((leader == null || !(leader.isOnline() == 1)))
  3451. + {
  3452. + if (assist != null || assist.isOnline() == 1)
  3453. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  3454. +
  3455. + if (assist2 != null || assist2.isOnline() == 1)
  3456. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  3457. +
  3458. + if (assist3 != null || assist3.isOnline() == 1)
  3459. + assist3.sendMessage("Tournament: You participation in Event was Canceled.");
  3460. +
  3461. + if (assist4 != null || assist4.isOnline() == 1)
  3462. + assist4.sendMessage("Tournament: You participation in Event was Canceled.");
  3463. +
  3464. + if (assist5 != null || assist5.isOnline() == 1)
  3465. + assist5.sendMessage("Tournament: You participation in Event was Canceled.");
  3466. +
  3467. + if (assist6 != null || assist6.isOnline() == 1)
  3468. + assist6.sendMessage("Tournament: You participation in Event was Canceled.");
  3469. +
  3470. + if (assist7 != null || assist7.isOnline() == 1)
  3471. + assist7.sendMessage("Tournament: You participation in Event was Canceled.");
  3472. +
  3473. + if (assist8 != null || assist8.isOnline() == 1)
  3474. + assist8.sendMessage("Tournament: You participation in Event was Canceled.");
  3475. +
  3476. + return false;
  3477. + }
  3478. + else if (((assist == null || !(assist.isOnline() == 1)) || (assist2 == null || !(assist2.isOnline() == 1)) || (assist3 == null || !(assist3.isOnline() == 1)) || (assist4 == null || !(assist4.isOnline() == 1)) || (assist5 == null || !(assist5.isOnline() == 1)) || (assist6 == null || !(assist6.isOnline() == 1)) || (assist7 == null || !(assist7.isOnline() == 1)) || (assist8 == null || !(assist8.isOnline() == 1))) && (leader != null || leader.isOnline() == 1))
  3479. + {
  3480. + leader.sendMessage("Tournament: You participation in Event was Canceled.");
  3481. +
  3482. + if (assist != null || assist.isOnline() == 1)
  3483. + assist.sendMessage("Tournament: You participation in Event was Canceled.");
  3484. +
  3485. + if (assist2 != null || assist2.isOnline() == 1)
  3486. + assist2.sendMessage("Tournament: You participation in Event was Canceled.");
  3487. +
  3488. + if (assist3 != null || assist3.isOnline() == 1)
  3489. + assist3.sendMessage("Tournament: You participation in Event was Canceled.");
  3490. +
  3491. + if (assist4 != null || assist4.isOnline() == 1)
  3492. + assist4.sendMessage("Tournament: You participation in Event was Canceled.");
  3493. +
  3494. + if (assist5 != null || assist5.isOnline() == 1)
  3495. + assist5.sendMessage("Tournament: You participation in Event was Canceled.");
  3496. +
  3497. + if (assist6 != null || assist6.isOnline() == 1)
  3498. + assist6.sendMessage("Tournament: You participation in Event was Canceled.");
  3499. +
  3500. + if (assist7 != null || assist7.isOnline() == 1)
  3501. + assist7.sendMessage("Tournament: You participation in Event was Canceled.");
  3502. +
  3503. + if (assist8 != null || assist8.isOnline() == 1)
  3504. + assist8.sendMessage("Tournament: You participation in Event was Canceled.");
  3505. +
  3506. + return false;
  3507. + }
  3508. + return true;
  3509. + }
  3510. +
  3511. + public boolean isDead()
  3512. + {
  3513. + if (ArenaConfig.ARENA_PROTECT)
  3514. + {
  3515. + if (leader != null && leader.isOnline() == 1 && leader.isArenaAttack() && !leader.isDead() && !leader.isInsideZone(L2Character.ARENA_EVENT))
  3516. + leader.logout();
  3517. + if (assist != null && assist.isOnline() == 1 && assist.isArenaAttack() && !assist.isDead() && !assist.isInsideZone(L2Character.ARENA_EVENT))
  3518. + assist.logout();
  3519. + if (assist2 != null && assist2.isOnline() == 1 && assist2.isArenaAttack() && !assist2.isDead() && !assist2.isInsideZone(L2Character.ARENA_EVENT))
  3520. + assist2.logout();
  3521. + if (assist3 != null && assist3.isOnline() == 1 && assist3.isArenaAttack() && !assist3.isDead() && !assist3.isInsideZone(L2Character.ARENA_EVENT))
  3522. + assist3.logout();
  3523. + if (assist4 != null && assist4.isOnline() == 1 && assist4.isArenaAttack() && !assist4.isDead() && !assist4.isInsideZone(L2Character.ARENA_EVENT))
  3524. + assist4.logout();
  3525. + if (assist5 != null && assist5.isOnline() == 1 && assist5.isArenaAttack() && !assist5.isDead() && !assist5.isInsideZone(L2Character.ARENA_EVENT))
  3526. + assist5.logout();
  3527. + if (assist6 != null && assist6.isOnline() == 1 && assist6.isArenaAttack() && !assist6.isDead() && !assist6.isInsideZone(L2Character.ARENA_EVENT))
  3528. + assist6.logout();
  3529. + if (assist7 != null && assist7.isOnline() == 1 && assist7.isArenaAttack() && !assist7.isDead() && !assist7.isInsideZone(L2Character.ARENA_EVENT))
  3530. + assist7.logout();
  3531. + if (assist8 != null && assist8.isOnline() == 1 && assist8.isArenaAttack() && !assist8.isDead() && !assist8.isInsideZone(L2Character.ARENA_EVENT))
  3532. + assist8.logout();
  3533. + }
  3534. +
  3535. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !(assist.isOnline() == 1) || !assist.isInsideZone(L2Character.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !(assist2.isOnline() == 1) || !assist2.isInsideZone(L2Character.ARENA_EVENT) || !assist2.isArenaAttack()) && (assist3 == null || assist3.isDead() || !(assist3.isOnline() == 1) || !assist3.isInsideZone(L2Character.ARENA_EVENT) || !assist3.isArenaAttack()) && (assist4 == null || assist4.isDead() || !(assist4.isOnline() == 1) || !assist4.isInsideZone(L2Character.ARENA_EVENT) || !assist4.isArenaAttack()) && (assist5 == null || assist5.isDead() || !(assist5.isOnline() == 1) || !assist5.isInsideZone(L2Character.ARENA_EVENT) || !assist5.isArenaAttack()) && (assist6 == null || assist6.isDead() || !(assist6.isOnline() == 1) || !assist6.isInsideZone(L2Character.ARENA_EVENT) || !assist6.isArenaAttack()) && (assist7 == null || assist7.isDead() || !(assist7.isOnline() == 1) || !assist7.isInsideZone(L2Character.ARENA_EVENT) || !assist7.isArenaAttack()) && (assist8 == null || assist8.isDead() || !(assist8.isOnline() == 1) || !assist8.isInsideZone(L2Character.ARENA_EVENT) || !assist8.isArenaAttack()))
  3536. + return false;
  3537. +
  3538. + return !(leader.isDead() && assist.isDead() && assist2.isDead() && assist3.isDead() && assist4.isDead() && assist5.isDead() && assist6.isDead() && assist7.isDead() && assist8.isDead());
  3539. + }
  3540. +
  3541. + public boolean isAlive()
  3542. + {
  3543. + if ((leader == null || leader.isDead() || !(leader.isOnline() == 1) || !leader.isInsideZone(L2Character.ARENA_EVENT) || !leader.isArenaAttack()) && (assist == null || assist.isDead() || !(assist.isOnline() == 1) || !assist.isInsideZone(L2Character.ARENA_EVENT) || !assist.isArenaAttack()) && (assist2 == null || assist2.isDead() || !(assist2.isOnline() == 1) || !assist2.isInsideZone(L2Character.ARENA_EVENT) || !assist2.isArenaAttack()) && (assist3 == null || assist3.isDead() || !(assist3.isOnline() == 1) || !assist3.isInsideZone(L2Character.ARENA_EVENT) || !assist3.isArenaAttack()) && (assist4 == null || assist4.isDead() || !(assist4.isOnline() == 1) || !assist4.isInsideZone(L2Character.ARENA_EVENT) || !assist4.isArenaAttack()) && (assist5 == null || assist5.isDead() || !(assist5.isOnline() == 1) || !assist5.isInsideZone(L2Character.ARENA_EVENT) || !assist5.isArenaAttack()) && (assist6 == null || assist6.isDead() || !(assist6.isOnline() == 1) || !assist6.isInsideZone(L2Character.ARENA_EVENT) || !assist6.isArenaAttack()) && (assist7 == null || assist7.isDead() || !(assist7.isOnline() == 1) || !assist7.isInsideZone(L2Character.ARENA_EVENT) || !assist7.isArenaAttack()) && (assist8 == null || assist8.isDead() || !(assist8.isOnline() == 1) || !assist8.isInsideZone(L2Character.ARENA_EVENT) || !assist8.isArenaAttack()))
  3544. + return false;
  3545. +
  3546. + return !(leader.isDead() && assist.isDead() && assist2.isDead() && assist3.isDead() && assist4.isDead() && assist5.isDead() && assist6.isDead() && assist7.isDead() && assist8.isDead());
  3547. + }
  3548. +
  3549. + public void teleportTo(int x, int y, int z)
  3550. + {
  3551. + if (leader != null && leader.isOnline() == 1)
  3552. + {
  3553. + //leader.getAppearance().setInvisible();
  3554. + leader.setCurrentCp(leader.getMaxCp());
  3555. + leader.setCurrentHp(leader.getMaxHp());
  3556. + leader.setCurrentMp(leader.getMaxMp());
  3557. +
  3558. + /*
  3559. + if (leader.isInObserverMode())
  3560. + {
  3561. + leader.setLastCords(x, y, z);
  3562. + leader.leaveOlympiadObserverMode();
  3563. + }
  3564. + */
  3565. + if (!leader.isInJail())
  3566. + leader.teleToLocation(x, y, z);
  3567. +
  3568. + leader.broadcastUserInfo();
  3569. +
  3570. + }
  3571. + if (assist != null && assist.isOnline() == 1)
  3572. + {
  3573. + //assist.getAppearance().setInvisible();
  3574. + assist.setCurrentCp(assist.getMaxCp());
  3575. + assist.setCurrentHp(assist.getMaxHp());
  3576. + assist.setCurrentMp(assist.getMaxMp());
  3577. +
  3578. + /*
  3579. + if (assist.isInObserverMode())
  3580. + {
  3581. + assist.setLastCords(x, y + 200, z);
  3582. + assist.leaveOlympiadObserverMode();
  3583. + }
  3584. + */
  3585. + if (!assist.isInJail())
  3586. + assist.teleToLocation(x, y + 200, z);
  3587. +
  3588. + assist.broadcastUserInfo();
  3589. + }
  3590. + if (assist2 != null && assist2.isOnline() == 1)
  3591. + {
  3592. + //assist2.getAppearance().setInvisible();
  3593. + assist2.setCurrentCp(assist2.getMaxCp());
  3594. + assist2.setCurrentHp(assist2.getMaxHp());
  3595. + assist2.setCurrentMp(assist2.getMaxMp());
  3596. +
  3597. + /*
  3598. + if (assist2.isInObserverMode())
  3599. + {
  3600. + assist2.setLastCords(x, y + 150, z);
  3601. + assist2.leaveOlympiadObserverMode();
  3602. + }
  3603. + */
  3604. + if (!assist2.isInJail())
  3605. + assist2.teleToLocation(x, y + 150, z);
  3606. +
  3607. + assist2.broadcastUserInfo();
  3608. + }
  3609. + if (assist3 != null && assist3.isOnline() == 1)
  3610. + {
  3611. + //assist3.getAppearance().setInvisible();
  3612. + assist3.setCurrentCp(assist3.getMaxCp());
  3613. + assist3.setCurrentHp(assist3.getMaxHp());
  3614. + assist3.setCurrentMp(assist3.getMaxMp());
  3615. +
  3616. + /*
  3617. + if (assist3.isInObserverMode())
  3618. + {
  3619. + assist3.setLastCords(x, y + 100, z);
  3620. + assist3.leaveOlympiadObserverMode();
  3621. + }
  3622. + */
  3623. + if (!assist3.isInJail())
  3624. + assist3.teleToLocation(x, y + 100, z);
  3625. +
  3626. + assist3.broadcastUserInfo();
  3627. + }
  3628. + if (assist4 != null && assist4.isOnline() == 1)
  3629. + {
  3630. + //assist4.getAppearance().setInvisible();
  3631. + assist4.setCurrentCp(assist4.getMaxCp());
  3632. + assist4.setCurrentHp(assist4.getMaxHp());
  3633. + assist4.setCurrentMp(assist4.getMaxMp());
  3634. +
  3635. + /*
  3636. + if (assist4.isInObserverMode())
  3637. + {
  3638. + assist4.setLastCords(x, y + 50, z);
  3639. + assist4.leaveOlympiadObserverMode();
  3640. + }
  3641. + */
  3642. + if (!assist4.isInJail())
  3643. + assist4.teleToLocation(x, y + 50, z);
  3644. +
  3645. + assist4.broadcastUserInfo();
  3646. + }
  3647. + if (assist5 != null && assist5.isOnline() == 1)
  3648. + {
  3649. + //assist5.getAppearance().setInvisible();
  3650. + assist5.setCurrentCp(assist5.getMaxCp());
  3651. + assist5.setCurrentHp(assist5.getMaxHp());
  3652. + assist5.setCurrentMp(assist5.getMaxMp());
  3653. +
  3654. + /*
  3655. + if (assist5.isInObserverMode())
  3656. + {
  3657. + assist5.setLastCords(x, y - 200, z);
  3658. + assist5.leaveOlympiadObserverMode();
  3659. + }
  3660. + */
  3661. + if (!assist5.isInJail())
  3662. + assist5.teleToLocation(x, y - 200, z);
  3663. +
  3664. +
  3665. + assist5.broadcastUserInfo();
  3666. + }
  3667. + if (assist6 != null && assist6.isOnline() == 1)
  3668. + {
  3669. + //assist6.getAppearance().setInvisible();
  3670. + assist6.setCurrentCp(assist6.getMaxCp());
  3671. + assist6.setCurrentHp(assist6.getMaxHp());
  3672. + assist6.setCurrentMp(assist6.getMaxMp());
  3673. +
  3674. + /*
  3675. + if (assist6.isInObserverMode())
  3676. + {
  3677. + assist6.setLastCords(x, y - 150, z);
  3678. + assist6.leaveOlympiadObserverMode();
  3679. + }
  3680. + */
  3681. + if (!assist6.isInJail())
  3682. + assist6.teleToLocation(x, y - 150, z);
  3683. +
  3684. + assist6.broadcastUserInfo();
  3685. + }
  3686. + if (assist7 != null && assist7.isOnline() == 1)
  3687. + {
  3688. + //assist7.getAppearance().setInvisible();
  3689. + assist7.setCurrentCp(assist7.getMaxCp());
  3690. + assist7.setCurrentHp(assist7.getMaxHp());
  3691. + assist7.setCurrentMp(assist7.getMaxMp());
  3692. +
  3693. + /*
  3694. + if (assist7.isInObserverMode())
  3695. + {
  3696. + assist7.setLastCords(x, y - 100, z);
  3697. + assist7.leaveOlympiadObserverMode();
  3698. + }
  3699. + */
  3700. + if (!assist7.isInJail())
  3701. + assist7.teleToLocation(x, y - 100, z);
  3702. +
  3703. + assist7.broadcastUserInfo();
  3704. + }
  3705. + if (assist8 != null && assist8.isOnline() == 1)
  3706. + {
  3707. + //assist8.getAppearance().setInvisible();
  3708. + assist8.setCurrentCp(assist8.getMaxCp());
  3709. + assist8.setCurrentHp(assist8.getMaxHp());
  3710. + assist8.setCurrentMp(assist8.getMaxMp());
  3711. +
  3712. + /*
  3713. + if (assist8.isInObserverMode())
  3714. + {
  3715. + assist8.setLastCords(x, y - 50, z);
  3716. + assist8.leaveOlympiadObserverMode();
  3717. + }
  3718. + */
  3719. + if (!assist8.isInJail())
  3720. + assist8.teleToLocation(x, y - 50, z);
  3721. +
  3722. + assist8.broadcastUserInfo();
  3723. + }
  3724. + }
  3725. +
  3726. + public void EventTitle(String title, String color)
  3727. + {
  3728. + if (leader != null && leader.isOnline() == 1)
  3729. + {
  3730. + leader.setTitle(title);
  3731. + leader.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3732. + leader.broadcastUserInfo();
  3733. + leader.broadcastTitleInfo();
  3734. + }
  3735. +
  3736. + if (assist != null && assist.isOnline() == 1)
  3737. + {
  3738. + assist.setTitle(title);
  3739. + assist.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3740. + assist.broadcastUserInfo();
  3741. + assist.broadcastTitleInfo();
  3742. + }
  3743. + if (assist2 != null && assist2.isOnline() == 1)
  3744. + {
  3745. + assist2.setTitle(title);
  3746. + assist2.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3747. + assist2.broadcastUserInfo();
  3748. + assist2.broadcastTitleInfo();
  3749. + }
  3750. + if (assist3 != null && assist3.isOnline() == 1)
  3751. + {
  3752. + assist3.setTitle(title);
  3753. + assist3.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3754. + assist3.broadcastUserInfo();
  3755. + assist3.broadcastTitleInfo();
  3756. + }
  3757. + if (assist4 != null && assist4.isOnline() == 1)
  3758. + {
  3759. + assist4.setTitle(title);
  3760. + assist4.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3761. + assist4.broadcastUserInfo();
  3762. + assist4.broadcastTitleInfo();
  3763. + }
  3764. + if (assist5 != null && assist5.isOnline() == 1)
  3765. + {
  3766. + assist5.setTitle(title);
  3767. + assist5.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3768. + assist5.broadcastUserInfo();
  3769. + assist5.broadcastTitleInfo();
  3770. + }
  3771. + if (assist6 != null && assist6.isOnline() == 1)
  3772. + {
  3773. + assist6.setTitle(title);
  3774. + assist6.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3775. + assist6.broadcastUserInfo();
  3776. + assist6.broadcastTitleInfo();
  3777. + }
  3778. + if (assist7 != null && assist7.isOnline() == 1)
  3779. + {
  3780. + assist7.setTitle(title);
  3781. + assist7.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3782. + assist7.broadcastUserInfo();
  3783. + assist7.broadcastTitleInfo();
  3784. + }
  3785. + if (assist8 != null && assist8.isOnline() == 1)
  3786. + {
  3787. + assist8.setTitle(title);
  3788. + assist8.getAppearance().setTitleColor(Integer.decode("0x" + color));
  3789. + assist8.broadcastUserInfo();
  3790. + assist8.broadcastTitleInfo();
  3791. + }
  3792. + }
  3793. +
  3794. + public void saveTitle()
  3795. + {
  3796. + if (leader != null && leader.isOnline() == 1)
  3797. + {
  3798. + leader._originalTitleColorTournament = leader.getAppearance().getTitleColor();
  3799. + leader._originalTitleTournament = leader.getTitle();
  3800. + }
  3801. +
  3802. + if (assist != null && assist.isOnline() == 1)
  3803. + {
  3804. + assist._originalTitleColorTournament = assist.getAppearance().getTitleColor();
  3805. + assist._originalTitleTournament = assist.getTitle();
  3806. + }
  3807. +
  3808. + if (assist2 != null && assist2.isOnline() == 1)
  3809. + {
  3810. + assist2._originalTitleColorTournament = assist2.getAppearance().getTitleColor();
  3811. + assist2._originalTitleTournament = assist2.getTitle();
  3812. + }
  3813. +
  3814. + if (assist3 != null && assist3.isOnline() == 1)
  3815. + {
  3816. + assist3._originalTitleColorTournament = assist3.getAppearance().getTitleColor();
  3817. + assist3._originalTitleTournament = assist3.getTitle();
  3818. + }
  3819. +
  3820. + if (assist4 != null && assist4.isOnline() == 1)
  3821. + {
  3822. + assist4._originalTitleColorTournament = assist4.getAppearance().getTitleColor();
  3823. + assist4._originalTitleTournament = assist4.getTitle();
  3824. + }
  3825. +
  3826. + if (assist5 != null && assist5.isOnline() == 1)
  3827. + {
  3828. + assist5._originalTitleColorTournament = assist5.getAppearance().getTitleColor();
  3829. + assist5._originalTitleTournament = assist5.getTitle();
  3830. + }
  3831. +
  3832. + if (assist6 != null && assist6.isOnline() == 1)
  3833. + {
  3834. + assist6._originalTitleColorTournament = assist6.getAppearance().getTitleColor();
  3835. + assist6._originalTitleTournament = assist6.getTitle();
  3836. + assist6._originalTitleTournament = assist6.getTitle();
  3837. + }
  3838. +
  3839. + if (assist7 != null && assist7.isOnline() == 1)
  3840. + {
  3841. + assist7._originalTitleColorTournament = assist7.getAppearance().getTitleColor();
  3842. + assist7._originalTitleTournament = assist7.getTitle();
  3843. + }
  3844. +
  3845. + if (assist8 != null && assist8.isOnline() == 1)
  3846. + {
  3847. + assist8._originalTitleColorTournament = assist8.getAppearance().getTitleColor();
  3848. + assist8._originalTitleTournament = assist8.getTitle();
  3849. + }
  3850. + }
  3851. +
  3852. + public void backTitle()
  3853. + {
  3854. + if (leader != null && leader.isOnline() == 1)
  3855. + {
  3856. + leader.setTitle(leader._originalTitleTournament);
  3857. + leader.getAppearance().setTitleColor(leader._originalTitleColorTournament);
  3858. + leader.broadcastUserInfo();
  3859. + leader.broadcastTitleInfo();
  3860. + }
  3861. +
  3862. + if (assist != null && assist.isOnline() == 1)
  3863. + {
  3864. + assist.setTitle(assist._originalTitleTournament);
  3865. + assist.getAppearance().setTitleColor(assist._originalTitleColorTournament);
  3866. + assist.broadcastUserInfo();
  3867. + assist.broadcastTitleInfo();
  3868. + }
  3869. +
  3870. + if (assist2 != null && assist2.isOnline() == 1)
  3871. + {
  3872. + assist2.setTitle(assist2._originalTitleTournament);
  3873. + assist2.getAppearance().setTitleColor(assist2._originalTitleColorTournament);
  3874. + assist2.broadcastUserInfo();
  3875. + assist2.broadcastTitleInfo();
  3876. + }
  3877. +
  3878. + if (assist3 != null && assist3.isOnline() == 1)
  3879. + {
  3880. + assist3.setTitle(assist3._originalTitleTournament);
  3881. + assist3.getAppearance().setTitleColor(assist3._originalTitleColorTournament);
  3882. + assist3.broadcastUserInfo();
  3883. + assist3.broadcastTitleInfo();
  3884. + }
  3885. +
  3886. + if (assist4 != null && assist4.isOnline() == 1)
  3887. + {
  3888. + assist4.setTitle(assist4._originalTitleTournament);
  3889. + assist4.getAppearance().setTitleColor(assist4._originalTitleColorTournament);
  3890. + assist4.broadcastUserInfo();
  3891. + assist4.broadcastTitleInfo();
  3892. + }
  3893. +
  3894. + if (assist5 != null && assist5.isOnline() == 1)
  3895. + {
  3896. + assist5.setTitle(assist5._originalTitleTournament);
  3897. + assist5.getAppearance().setTitleColor(assist5._originalTitleColorTournament);
  3898. + assist5.broadcastUserInfo();
  3899. + assist5.broadcastTitleInfo();
  3900. + }
  3901. +
  3902. + if (assist6 != null && assist6.isOnline() == 1)
  3903. + {
  3904. + assist6.setTitle(assist6._originalTitleTournament);
  3905. + assist6.getAppearance().setTitleColor(assist6._originalTitleColorTournament);
  3906. + assist6.broadcastUserInfo();
  3907. + assist6.broadcastTitleInfo();
  3908. + }
  3909. +
  3910. + if (assist7 != null && assist7.isOnline() == 1)
  3911. + {
  3912. + assist7.setTitle(assist7._originalTitleTournament);
  3913. + assist7.getAppearance().setTitleColor(assist7._originalTitleColorTournament);
  3914. + assist7.broadcastUserInfo();
  3915. + assist7.broadcastTitleInfo();
  3916. + }
  3917. +
  3918. + if (assist8 != null && assist8.isOnline() == 1)
  3919. + {
  3920. + assist8.setTitle(assist8._originalTitleTournament);
  3921. + assist8.getAppearance().setTitleColor(assist8._originalTitleColorTournament);
  3922. + assist8.broadcastUserInfo();
  3923. + assist8.broadcastTitleInfo();
  3924. + }
  3925. + }
  3926. +
  3927. + public void setArenaInstance()
  3928. + {
  3929. + if (leader != null && leader.isOnline() == 1)
  3930. + leader.setInstanceId(4); //9x9 Tournament Instance
  3931. +
  3932. + if (assist != null && assist.isOnline() == 1)
  3933. + assist.setInstanceId(4); //9x9 Tournament Instance
  3934. +
  3935. + if (assist2 != null && assist2.isOnline() == 1)
  3936. + assist2.setInstanceId(4); //9x9 Tournament Instance
  3937. +
  3938. + if (assist3 != null && assist3.isOnline() == 1)
  3939. + assist3.setInstanceId(4); //9x9 Tournament Instance
  3940. +
  3941. + if (assist4 != null && assist4.isOnline() == 1)
  3942. + assist4.setInstanceId(4); //9x9 Tournament Instance
  3943. +
  3944. + if (assist5 != null && assist5.isOnline() == 1)
  3945. + assist5.setInstanceId(4); //9x9 Tournament Instance
  3946. +
  3947. + if (assist6 != null && assist6.isOnline() == 1)
  3948. + assist6.setInstanceId(4); //9x9 Tournament Instance
  3949. +
  3950. + if (assist7 != null && assist7.isOnline() == 1)
  3951. + assist7.setInstanceId(4); //9x9 Tournament Instance
  3952. +
  3953. + if (assist8 != null && assist8.isOnline() == 1)
  3954. + assist8.setInstanceId(4); //9x9 Tournament Instance
  3955. + }
  3956. +
  3957. + public void setRealInstance()
  3958. + {
  3959. + if (leader != null && leader.isOnline() == 1)
  3960. + leader.setInstanceId(0);
  3961. +
  3962. + if (assist != null && assist.isOnline() == 1)
  3963. + assist.setInstanceId(0);
  3964. +
  3965. + if (assist2 != null && assist2.isOnline() == 1)
  3966. + assist2.setInstanceId(0);
  3967. +
  3968. + if (assist3 != null && assist3.isOnline() == 1)
  3969. + assist3.setInstanceId(0);
  3970. +
  3971. + if (assist4 != null && assist4.isOnline() == 1)
  3972. + assist4.setInstanceId(0);
  3973. +
  3974. + if (assist5 != null && assist5.isOnline() == 1)
  3975. + assist5.setInstanceId(0);
  3976. +
  3977. + if (assist6 != null && assist6.isOnline() == 1)
  3978. + assist6.setInstanceId(0);
  3979. +
  3980. + if (assist7 != null && assist7.isOnline() == 1)
  3981. + assist7.setInstanceId(0);
  3982. +
  3983. + if (assist8 != null && assist8.isOnline() == 1)
  3984. + assist8.setInstanceId(0);
  3985. + }
  3986. +
  3987. + public void rewards()
  3988. + {
  3989. + if (leader != null && leader.isOnline() == 1)
  3990. + {
  3991. + if (leader.isVip())
  3992. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  3993. + else
  3994. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, leader, true);
  3995. + }
  3996. +
  3997. + if (assist != null && assist.isOnline() == 1)
  3998. + {
  3999. + if (assist.isVip())
  4000. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  4001. + else
  4002. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist, true);
  4003. + }
  4004. +
  4005. + if (assist2 != null && assist2.isOnline() == 1)
  4006. + {
  4007. + if (assist2.isVip())
  4008. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  4009. + else
  4010. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist2, true);
  4011. + }
  4012. +
  4013. + if (assist3 != null && assist3.isOnline() == 1)
  4014. + {
  4015. + if (assist3.isVip())
  4016. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist3, true);
  4017. + else
  4018. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist3, true);
  4019. + }
  4020. +
  4021. + if (assist4 != null && assist4.isOnline() == 1)
  4022. + {
  4023. + if (assist4.isVip())
  4024. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist4, true);
  4025. + else
  4026. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist4, true);
  4027. + }
  4028. +
  4029. + if (assist5 != null && assist5.isOnline() == 1)
  4030. + {
  4031. + if (assist5.isVip())
  4032. + assist5.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist5, true);
  4033. + else
  4034. + assist5.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist5, true);
  4035. + }
  4036. +
  4037. + if (assist6 != null && assist6.isOnline() == 1)
  4038. + {
  4039. + if (assist6.isVip())
  4040. + assist6.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist6, true);
  4041. + else
  4042. + assist6.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist6, true);
  4043. + }
  4044. +
  4045. + if (assist7 != null && assist7.isOnline() == 1)
  4046. + {
  4047. + if (assist7.isVip())
  4048. + assist7.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist7, true);
  4049. + else
  4050. + assist7.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist7, true);
  4051. + }
  4052. +
  4053. + if (assist8 != null && assist8.isOnline() == 1)
  4054. + {
  4055. + if (assist8.isVip())
  4056. + assist8.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist8, true);
  4057. + else
  4058. + assist8.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_WIN_REWARD_COUNT_9X9, assist8, true);
  4059. + }
  4060. +
  4061. + sendPacket("Congratulations, your team won the event!", 5);
  4062. + }
  4063. +
  4064. + public void rewardsLost()
  4065. + {
  4066. + if (leader != null && leader.isOnline() == 1)
  4067. + {
  4068. + if (leader.isVip())
  4069. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, leader, true);
  4070. + else
  4071. + leader.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, leader, true);
  4072. + }
  4073. +
  4074. + if (assist != null && assist.isOnline() == 1)
  4075. + {
  4076. + if (assist.isVip())
  4077. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist, true);
  4078. + else
  4079. + assist.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist, true);
  4080. + }
  4081. + if (assist2 != null && assist2.isOnline() == 1)
  4082. + {
  4083. + if (assist2.isVip())
  4084. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist2, true);
  4085. + else
  4086. + assist2.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist2, true);
  4087. + }
  4088. + if (assist3 != null && assist3.isOnline() == 1)
  4089. + {
  4090. + if (assist3.isVip())
  4091. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist3, true);
  4092. + else
  4093. + assist3.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist3, true);
  4094. + }
  4095. +
  4096. + if (assist4 != null && assist4.isOnline() == 1)
  4097. + {
  4098. + if (assist4.isVip())
  4099. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist4, true);
  4100. + else
  4101. + assist4.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist4, true);
  4102. + }
  4103. +
  4104. + if (assist5 != null && assist5.isOnline() == 1)
  4105. + {
  4106. + if (assist5.isVip())
  4107. + assist5.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist5, true);
  4108. + else
  4109. + assist5.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist5, true);
  4110. + }
  4111. +
  4112. + if (assist6 != null && assist6.isOnline() == 1)
  4113. + {
  4114. + if (assist6.isVip())
  4115. + assist6.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist6, true);
  4116. + else
  4117. + assist6.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist6, true);
  4118. + }
  4119. +
  4120. + if (assist7 != null && assist7.isOnline() == 1)
  4121. + {
  4122. + if (assist7.isVip())
  4123. + assist7.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist7, true);
  4124. + else
  4125. + assist7.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist7, true);
  4126. + }
  4127. +
  4128. + if (assist8 != null && assist8.isOnline() == 1)
  4129. + {
  4130. + if (assist8.isVip())
  4131. + assist8.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9 * ArenaConfig.ARENA_VIP_DROP_RATE, assist8, true);
  4132. + else
  4133. + assist8.addItem("Arena_Event", ArenaConfig.ARENA_REWARD_ID, ArenaConfig.ARENA_LOST_REWARD_COUNT_9X9, assist8, true);
  4134. + }
  4135. +
  4136. + sendPacket("your team lost the event! =(", 5);
  4137. + }
  4138. +
  4139. + public void setInTournamentEvent(boolean val)
  4140. + {
  4141. + if (leader != null && leader.isOnline() == 1)
  4142. + leader.setInArenaEvent(val);
  4143. +
  4144. + if (assist != null && assist.isOnline() == 1)
  4145. + assist.setInArenaEvent(val);
  4146. +
  4147. + if (assist2 != null && assist2.isOnline() == 1)
  4148. + assist2.setInArenaEvent(val);
  4149. +
  4150. + if (assist3 != null && assist3.isOnline() == 1)
  4151. + assist3.setInArenaEvent(val);
  4152. +
  4153. + if (assist4 != null && assist4.isOnline() == 1)
  4154. + assist4.setInArenaEvent(val);
  4155. +
  4156. + if (assist5 != null && assist5.isOnline() == 1)
  4157. + assist5.setInArenaEvent(val);
  4158. +
  4159. + if (assist6 != null && assist6.isOnline() == 1)
  4160. + assist6.setInArenaEvent(val);
  4161. +
  4162. + if (assist7 != null && assist7.isOnline() == 1)
  4163. + assist7.setInArenaEvent(val);
  4164. +
  4165. + if (assist8 != null && assist8.isOnline() == 1)
  4166. + assist8.setInArenaEvent(val);
  4167. + }
  4168. +
  4169. + public void removeMessage()
  4170. + {
  4171. + if (leader != null && leader.isOnline() == 1)
  4172. + {
  4173. + leader.sendMessage("Tournament: Your participation has been removed.");
  4174. + leader.setArenaProtection(false);
  4175. + leader.setArena9x9(false);
  4176. + }
  4177. +
  4178. + if (assist != null && assist.isOnline() == 1)
  4179. + {
  4180. + assist.sendMessage("Tournament: Your participation has been removed.");
  4181. + assist.setArenaProtection(false);
  4182. + assist.setArena9x9(false);
  4183. + }
  4184. +
  4185. + if (assist2 != null && assist2.isOnline() == 1)
  4186. + {
  4187. + assist2.sendMessage("Tournament: Your participation has been removed.");
  4188. + assist2.setArenaProtection(false);
  4189. + assist2.setArena9x9(false);
  4190. + }
  4191. +
  4192. + if (assist3 != null && assist3.isOnline() == 1)
  4193. + {
  4194. + assist3.sendMessage("Tournament: Your participation has been removed.");
  4195. + assist3.setArenaProtection(false);
  4196. + assist3.setArena9x9(false);
  4197. + }
  4198. +
  4199. + if (assist4 != null && assist4.isOnline() == 1)
  4200. + {
  4201. + assist4.sendMessage("Tournament: Your participation has been removed.");
  4202. + assist4.setArenaProtection(false);
  4203. + assist4.setArena9x9(false);
  4204. + }
  4205. +
  4206. + if (assist5 != null && assist5.isOnline() == 1)
  4207. + {
  4208. + assist5.sendMessage("Tournament: Your participation has been removed.");
  4209. + assist5.setArenaProtection(false);
  4210. + assist5.setArena9x9(false);
  4211. + }
  4212. +
  4213. + if (assist6 != null && assist6.isOnline() == 1)
  4214. + {
  4215. + assist6.sendMessage("Tournament: Your participation has been removed.");
  4216. + assist6.setArenaProtection(false);
  4217. + assist6.setArena9x9(false);
  4218. + }
  4219. +
  4220. + if (assist7 != null && assist7.isOnline() == 1)
  4221. + {
  4222. + assist7.sendMessage("Tournament: Your participation has been removed.");
  4223. + assist7.setArenaProtection(false);
  4224. + assist7.setArena9x9(false);
  4225. + }
  4226. +
  4227. + if (assist8 != null && assist8.isOnline() == 1)
  4228. + {
  4229. + assist8.sendMessage("Tournament: Your participation has been removed.");
  4230. + assist8.setArenaProtection(false);
  4231. + assist8.setArena9x9(false);
  4232. + }
  4233. + }
  4234. +
  4235. + public void setArenaProtection(boolean val)
  4236. + {
  4237. + if (leader != null && leader.isOnline() == 1)
  4238. + {
  4239. + leader.setArenaProtection(val);
  4240. + leader.setArena9x9(val);
  4241. + }
  4242. +
  4243. + if (assist != null && assist.isOnline() == 1)
  4244. + {
  4245. + assist.setArenaProtection(val);
  4246. + assist.setArena9x9(val);
  4247. + }
  4248. + if (assist2 != null && assist2.isOnline() == 1)
  4249. + {
  4250. + assist2.setArenaProtection(val);
  4251. + assist2.setArena9x9(val);
  4252. + }
  4253. +
  4254. + if (assist3 != null && assist3.isOnline() == 1)
  4255. + {
  4256. + assist3.setArenaProtection(val);
  4257. + assist3.setArena9x9(val);
  4258. + }
  4259. +
  4260. + if (assist4 != null && assist4.isOnline() == 1)
  4261. + {
  4262. + assist4.setArenaProtection(val);
  4263. + assist4.setArena9x9(val);
  4264. + }
  4265. +
  4266. + if (assist5 != null && assist5.isOnline() == 1)
  4267. + {
  4268. + assist5.setArenaProtection(val);
  4269. + assist5.setArena9x9(val);
  4270. + }
  4271. +
  4272. + if (assist6 != null && assist6.isOnline() == 1)
  4273. + {
  4274. + assist6.setArenaProtection(val);
  4275. + assist6.setArena9x9(val);
  4276. + }
  4277. +
  4278. + if (assist7 != null && assist7.isOnline() == 1)
  4279. + {
  4280. + assist7.setArenaProtection(val);
  4281. + assist7.setArena9x9(val);
  4282. + }
  4283. +
  4284. + if (assist8 != null && assist8.isOnline() == 1)
  4285. + {
  4286. + assist8.setArenaProtection(val);
  4287. + assist8.setArena9x9(val);
  4288. + }
  4289. + }
  4290. +
  4291. + public void revive()
  4292. + {
  4293. + if (leader != null && leader.isOnline() == 1 && leader.isDead())
  4294. + leader.doRevive();
  4295. +
  4296. + if (assist != null && assist.isOnline() == 1 && assist.isDead())
  4297. + assist.doRevive();
  4298. +
  4299. + if (assist2 != null && assist2.isOnline() == 1 && assist2.isDead())
  4300. + assist2.doRevive();
  4301. +
  4302. + if (assist3 != null && assist3.isOnline() == 1 && assist3.isDead())
  4303. + assist3.doRevive();
  4304. +
  4305. + if (assist4 != null && assist4.isOnline() == 1 && assist4.isDead())
  4306. + assist4.doRevive();
  4307. +
  4308. + if (assist5 != null && assist5.isOnline() == 1 && assist5.isDead())
  4309. + assist5.doRevive();
  4310. +
  4311. + if (assist6 != null && assist6.isOnline() == 1 && assist6.isDead())
  4312. + assist6.doRevive();
  4313. +
  4314. + if (assist7 != null && assist7.isOnline() == 1 && assist7.isDead())
  4315. + assist7.doRevive();
  4316. +
  4317. + if (assist8 != null && assist8.isOnline() == 1 && assist8.isDead())
  4318. + assist8.doRevive();
  4319. + }
  4320. +
  4321. + public void setImobilised(boolean val)
  4322. + {
  4323. + if (leader != null && leader.isOnline() == 1)
  4324. + {
  4325. + leader.setIsInvul(val);
  4326. + leader.setStopArena(val);
  4327. + }
  4328. + if (assist != null && assist.isOnline() == 1)
  4329. + {
  4330. + assist.setIsInvul(val);
  4331. + assist.setStopArena(val);
  4332. + }
  4333. + if (assist2 != null && assist2.isOnline() == 1)
  4334. + {
  4335. + assist2.setIsInvul(val);
  4336. + assist2.setStopArena(val);
  4337. + }
  4338. + if (assist3 != null && assist3.isOnline() == 1)
  4339. + {
  4340. + assist3.setIsInvul(val);
  4341. + assist3.setStopArena(val);
  4342. + }
  4343. + if (assist4 != null && assist4.isOnline() == 1)
  4344. + {
  4345. + assist4.setIsInvul(val);
  4346. + assist4.setStopArena(val);
  4347. + }
  4348. + if (assist5 != null && assist5.isOnline() == 1)
  4349. + {
  4350. + assist5.setIsInvul(val);
  4351. + assist5.setStopArena(val);
  4352. + }
  4353. + if (assist6 != null && assist6.isOnline() == 1)
  4354. + {
  4355. + assist6.setIsInvul(val);
  4356. + assist6.setStopArena(val);
  4357. + }
  4358. + if (assist7 != null && assist7.isOnline() == 1)
  4359. + {
  4360. + assist7.setIsInvul(val);
  4361. + assist7.setStopArena(val);
  4362. + }
  4363. + if (assist8 != null && assist8.isOnline() == 1)
  4364. + {
  4365. + assist8.setIsInvul(val);
  4366. + assist8.setStopArena(val);
  4367. + }
  4368. + }
  4369. +
  4370. + public void setArenaAttack(boolean val)
  4371. + {
  4372. + if (leader != null && leader.isOnline() == 1)
  4373. + {
  4374. + leader.setArenaAttack(val);
  4375. + leader.broadcastUserInfo();
  4376. + }
  4377. +
  4378. + if (assist != null && assist.isOnline() == 1)
  4379. + {
  4380. + assist.setArenaAttack(val);
  4381. + assist.broadcastUserInfo();
  4382. + }
  4383. +
  4384. + if (assist2 != null && assist2.isOnline() == 1)
  4385. + {
  4386. + assist2.setArenaAttack(val);
  4387. + assist2.broadcastUserInfo();
  4388. + }
  4389. +
  4390. + if (assist3 != null && assist3.isOnline() == 1)
  4391. + {
  4392. + assist3.setArenaAttack(val);
  4393. + assist3.broadcastUserInfo();
  4394. + }
  4395. +
  4396. + if (assist4 != null && assist4.isOnline() == 1)
  4397. + {
  4398. + assist4.setArenaAttack(val);
  4399. + assist4.broadcastUserInfo();
  4400. + }
  4401. +
  4402. + if (assist5 != null && assist5.isOnline() == 1)
  4403. + {
  4404. + assist5.setArenaAttack(val);
  4405. + assist5.broadcastUserInfo();
  4406. + }
  4407. +
  4408. + if (assist6 != null && assist6.isOnline() == 1)
  4409. + {
  4410. + assist6.setArenaAttack(val);
  4411. + assist6.broadcastUserInfo();
  4412. + }
  4413. +
  4414. + if (assist7 != null && assist7.isOnline() == 1)
  4415. + {
  4416. + assist7.setArenaAttack(val);
  4417. + assist7.broadcastUserInfo();
  4418. + }
  4419. +
  4420. + if (assist8 != null && assist8.isOnline() == 1)
  4421. + {
  4422. + assist8.setArenaAttack(val);
  4423. + assist8.broadcastUserInfo();
  4424. + }
  4425. + }
  4426. +
  4427. + public void removePet()
  4428. + {
  4429. + if (leader != null && leader.isOnline() == 1)
  4430. + {
  4431. + // Remove Summon's buffs
  4432. + if (leader.getPet() != null)
  4433. + {
  4434. + L2Summon summon = leader.getPet();
  4435. + if (summon != null)
  4436. + summon.unSummon(summon.getOwner());
  4437. +
  4438. + if (summon instanceof L2PetInstance)
  4439. + summon.unSummon(leader);
  4440. + }
  4441. +
  4442. + if (leader.getMountType() == 1 || leader.getMountType() == 2)
  4443. + leader.dismount();
  4444. + }
  4445. +
  4446. + if (assist != null && assist.isOnline() == 1)
  4447. + {
  4448. + // Remove Summon's buffs
  4449. + if (assist.getPet() != null)
  4450. + {
  4451. + L2Summon summon = assist.getPet();
  4452. + if (summon != null)
  4453. + summon.unSummon(summon.getOwner());
  4454. +
  4455. + if (summon instanceof L2PetInstance)
  4456. + summon.unSummon(assist);
  4457. + }
  4458. +
  4459. + if (assist.getMountType() == 1 || assist.getMountType() == 2)
  4460. + assist.dismount();
  4461. +
  4462. + }
  4463. +
  4464. + if (assist2 != null && assist2.isOnline() == 1)
  4465. + {
  4466. + // Remove Summon's buffs
  4467. + if (assist2.getPet() != null)
  4468. + {
  4469. + L2Summon summon = assist2.getPet();
  4470. + if (summon != null)
  4471. + summon.unSummon(summon.getOwner());
  4472. +
  4473. + if (summon instanceof L2PetInstance)
  4474. + summon.unSummon(assist2);
  4475. +
  4476. + }
  4477. +
  4478. + if (assist2.getMountType() == 1 || assist2.getMountType() == 2)
  4479. + assist2.dismount();
  4480. +
  4481. + }
  4482. +
  4483. + if (assist3 != null && assist3.isOnline() == 1)
  4484. + {
  4485. + // Remove Summon's buffs
  4486. + if (assist3.getPet() != null)
  4487. + {
  4488. + L2Summon summon = assist3.getPet();
  4489. + if (summon != null)
  4490. + summon.unSummon(summon.getOwner());
  4491. +
  4492. + if (summon instanceof L2PetInstance)
  4493. + summon.unSummon(assist3);
  4494. + }
  4495. +
  4496. + if (assist3.getMountType() == 1 || assist3.getMountType() == 2)
  4497. + assist3.dismount();
  4498. +
  4499. + }
  4500. +
  4501. + if (assist4 != null && assist4.isOnline() == 1)
  4502. + {
  4503. + // Remove Summon's buffs
  4504. + if (assist4.getPet() != null)
  4505. + {
  4506. + L2Summon summon = assist4.getPet();
  4507. + if (summon != null)
  4508. + summon.unSummon(summon.getOwner());
  4509. +
  4510. + if (summon instanceof L2PetInstance)
  4511. + summon.unSummon(assist4);
  4512. +
  4513. + }
  4514. +
  4515. + if (assist4.getMountType() == 1 || assist4.getMountType() == 2)
  4516. + assist4.dismount();
  4517. +
  4518. + }
  4519. +
  4520. + if (assist5 != null && assist5.isOnline() == 1)
  4521. + {
  4522. + // Remove Summon's buffs
  4523. + if (assist5.getPet() != null)
  4524. + {
  4525. + L2Summon summon = assist5.getPet();
  4526. + if (summon != null)
  4527. + summon.unSummon(summon.getOwner());
  4528. +
  4529. + if (summon instanceof L2PetInstance)
  4530. + summon.unSummon(assist5);
  4531. +
  4532. + }
  4533. +
  4534. + if (assist5.getMountType() == 1 || assist5.getMountType() == 2)
  4535. + assist5.dismount();
  4536. +
  4537. + }
  4538. +
  4539. + if (assist6 != null && assist6.isOnline() == 1)
  4540. + {
  4541. + // Remove Summon's buffs
  4542. + if (assist6.getPet() != null)
  4543. + {
  4544. + L2Summon summon = assist6.getPet();
  4545. + if (summon != null)
  4546. + summon.unSummon(summon.getOwner());
  4547. +
  4548. + if (summon instanceof L2PetInstance)
  4549. + summon.unSummon(assist6);
  4550. + }
  4551. +
  4552. + if (assist6.getMountType() == 1 || assist6.getMountType() == 2)
  4553. + assist6.dismount();
  4554. +
  4555. + }
  4556. +
  4557. + if (assist7 != null && assist7.isOnline() == 1)
  4558. + {
  4559. + // Remove Summon's buffs
  4560. + if (assist7.getPet() != null)
  4561. + {
  4562. + L2Summon summon = assist7.getPet();
  4563. + if (summon != null)
  4564. + summon.unSummon(summon.getOwner());
  4565. +
  4566. + if (summon instanceof L2PetInstance)
  4567. + summon.unSummon(assist7);
  4568. +
  4569. + }
  4570. +
  4571. + if (assist7.getMountType() == 1 || assist7.getMountType() == 2)
  4572. + assist7.dismount();
  4573. +
  4574. + }
  4575. +
  4576. + if (assist8 != null && assist8.isOnline() == 1)
  4577. + {
  4578. + // Remove Summon's buffs
  4579. + if (assist8.getPet() != null)
  4580. + {
  4581. + L2Summon summon = assist8.getPet();
  4582. + if (summon != null)
  4583. + summon.unSummon(summon.getOwner());
  4584. +
  4585. + if (summon instanceof L2PetInstance)
  4586. + summon.unSummon(assist8);
  4587. +
  4588. + }
  4589. +
  4590. + if (assist8.getMountType() == 1 || assist8.getMountType() == 2)
  4591. + assist8.dismount();
  4592. + }
  4593. +
  4594. + }
  4595. +
  4596. + public void removeSkills()
  4597. + {
  4598. + if (!(leader.getClassId() == ClassId.shillenElder || leader.getClassId() == ClassId.shillienSaint || leader.getClassId() == ClassId.bishop || leader.getClassId() == ClassId.cardinal || leader.getClassId() == ClassId.elder || leader.getClassId() == ClassId.evaSaint))
  4599. + {
  4600. + for (L2Effect effect : leader.getAllEffects())
  4601. + {
  4602. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4603. + leader.stopSkillEffects(effect.getSkill().getId());
  4604. + }
  4605. + }
  4606. +
  4607. + if (!(assist.getClassId() == ClassId.shillenElder || assist.getClassId() == ClassId.shillienSaint || assist.getClassId() == ClassId.bishop || assist.getClassId() == ClassId.cardinal || assist.getClassId() == ClassId.elder || assist.getClassId() == ClassId.evaSaint))
  4608. + {
  4609. + for (L2Effect effect : assist.getAllEffects())
  4610. + {
  4611. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4612. + assist.stopSkillEffects(effect.getSkill().getId());
  4613. + }
  4614. + }
  4615. +
  4616. + if (!(assist2.getClassId() == ClassId.shillenElder || assist2.getClassId() == ClassId.shillienSaint || assist2.getClassId() == ClassId.bishop || assist2.getClassId() == ClassId.cardinal || assist2.getClassId() == ClassId.elder || assist2.getClassId() == ClassId.evaSaint))
  4617. + {
  4618. + for (L2Effect effect : assist2.getAllEffects())
  4619. + {
  4620. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4621. + assist2.stopSkillEffects(effect.getSkill().getId());
  4622. + }
  4623. + }
  4624. +
  4625. + if (!(assist3.getClassId() == ClassId.shillenElder || assist3.getClassId() == ClassId.shillienSaint || assist3.getClassId() == ClassId.bishop || assist3.getClassId() == ClassId.cardinal || assist3.getClassId() == ClassId.elder || assist3.getClassId() == ClassId.evaSaint))
  4626. + {
  4627. + for (L2Effect effect : assist3.getAllEffects())
  4628. + {
  4629. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4630. + assist3.stopSkillEffects(effect.getSkill().getId());
  4631. + }
  4632. + }
  4633. +
  4634. + if (!(assist4.getClassId() == ClassId.shillenElder || assist4.getClassId() == ClassId.shillienSaint || assist4.getClassId() == ClassId.bishop || assist4.getClassId() == ClassId.cardinal || assist4.getClassId() == ClassId.elder || assist4.getClassId() == ClassId.evaSaint))
  4635. + {
  4636. + for (L2Effect effect : assist4.getAllEffects())
  4637. + {
  4638. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4639. + assist4.stopSkillEffects(effect.getSkill().getId());
  4640. + }
  4641. + }
  4642. +
  4643. + if (!(assist5.getClassId() == ClassId.shillenElder || assist5.getClassId() == ClassId.shillienSaint || assist5.getClassId() == ClassId.bishop || assist5.getClassId() == ClassId.cardinal || assist5.getClassId() == ClassId.elder || assist5.getClassId() == ClassId.evaSaint))
  4644. + {
  4645. + for (L2Effect effect : assist5.getAllEffects())
  4646. + {
  4647. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4648. + assist5.stopSkillEffects(effect.getSkill().getId());
  4649. + }
  4650. + }
  4651. +
  4652. + if (!(assist6.getClassId() == ClassId.shillenElder || assist6.getClassId() == ClassId.shillienSaint || assist6.getClassId() == ClassId.bishop || assist6.getClassId() == ClassId.cardinal || assist6.getClassId() == ClassId.elder || assist6.getClassId() == ClassId.evaSaint))
  4653. + {
  4654. + for (L2Effect effect : assist6.getAllEffects())
  4655. + {
  4656. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4657. + assist6.stopSkillEffects(effect.getSkill().getId());
  4658. + }
  4659. + }
  4660. +
  4661. + if (!(assist7.getClassId() == ClassId.shillenElder || assist7.getClassId() == ClassId.shillienSaint || assist7.getClassId() == ClassId.bishop || assist7.getClassId() == ClassId.cardinal || assist7.getClassId() == ClassId.elder || assist7.getClassId() == ClassId.evaSaint))
  4662. + {
  4663. + for (L2Effect effect : assist7.getAllEffects())
  4664. + {
  4665. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4666. + assist7.stopSkillEffects(effect.getSkill().getId());
  4667. + }
  4668. + }
  4669. +
  4670. + if (!(assist8.getClassId() == ClassId.shillenElder || assist8.getClassId() == ClassId.shillienSaint || assist8.getClassId() == ClassId.bishop || assist8.getClassId() == ClassId.cardinal || assist8.getClassId() == ClassId.elder || assist8.getClassId() == ClassId.evaSaint))
  4671. + {
  4672. + for (L2Effect effect : assist8.getAllEffects())
  4673. + {
  4674. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  4675. + assist8.stopSkillEffects(effect.getSkill().getId());
  4676. + }
  4677. + }
  4678. + }
  4679. +
  4680. + public void sendPacket(String message, int duration)
  4681. + {
  4682. + if (leader != null && leader.isOnline() == 1)
  4683. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4684. +
  4685. + if (assist != null && assist.isOnline() == 1)
  4686. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4687. +
  4688. + if (assist2 != null && assist2.isOnline() == 1)
  4689. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4690. +
  4691. + if (assist3 != null && assist3.isOnline() == 1)
  4692. + assist3.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4693. +
  4694. + if (assist4 != null && assist4.isOnline() == 1)
  4695. + assist4.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4696. +
  4697. + if (assist5 != null && assist5.isOnline() == 1)
  4698. + assist5.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4699. +
  4700. + if (assist6 != null && assist6.isOnline() == 1)
  4701. + assist6.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4702. +
  4703. + if (assist7 != null && assist7.isOnline() == 1)
  4704. + assist7.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4705. +
  4706. + if (assist8 != null && assist8.isOnline() == 1)
  4707. + assist8.sendPacket(new ExShowScreenMessage(message, duration * 1000));
  4708. +
  4709. + }
  4710. +
  4711. + public void inicarContagem(int duration)
  4712. + {
  4713. + if (leader != null && leader.isOnline() == 1)
  4714. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(leader, duration), 0);
  4715. +
  4716. + if (assist != null && assist.isOnline() == 1)
  4717. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist, duration), 0);
  4718. +
  4719. + if (assist2 != null && assist2.isOnline() == 1)
  4720. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist2, duration), 0);
  4721. +
  4722. + if (assist3 != null && assist3.isOnline() == 1)
  4723. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist3, duration), 0);
  4724. +
  4725. + if (assist4 != null && assist4.isOnline() == 1)
  4726. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist4, duration), 0);
  4727. +
  4728. + if (assist5 != null && assist5.isOnline() == 1)
  4729. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist5, duration), 0);
  4730. +
  4731. + if (assist6 != null && assist6.isOnline() == 1)
  4732. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist6, duration), 0);
  4733. +
  4734. + if (assist7 != null && assist7.isOnline() == 1)
  4735. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist7, duration), 0);
  4736. +
  4737. + if (assist8 != null && assist8.isOnline() == 1)
  4738. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(assist8, duration), 0);
  4739. + }
  4740. +
  4741. + public void sendPacketinit(String message, int duration)
  4742. + {
  4743. + if (leader != null && leader.isOnline() == 1)
  4744. + leader.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4745. +
  4746. + if (assist != null && assist.isOnline() == 1)
  4747. + assist.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4748. +
  4749. + if (assist2 != null && assist2.isOnline() == 1)
  4750. + assist2.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4751. +
  4752. + if (assist3 != null && assist3.isOnline() == 1)
  4753. + assist3.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4754. +
  4755. + if (assist4 != null && assist4.isOnline() == 1)
  4756. + assist4.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4757. +
  4758. + if (assist5 != null && assist5.isOnline() == 1)
  4759. + assist5.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4760. +
  4761. + if (assist6 != null && assist6.isOnline() == 1)
  4762. + assist6.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4763. +
  4764. + if (assist7 != null && assist7.isOnline() == 1)
  4765. + assist7.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4766. +
  4767. + if (assist8 != null && assist8.isOnline() == 1)
  4768. + assist8.sendPacket(new ExShowScreenMessage(message, duration * 1000, ExShowScreenMessage.SMPOS.MIDDLE_LEFT, false));
  4769. +
  4770. + }
  4771. +
  4772. + }
  4773. +
  4774. + private class EvtArenaTask implements Runnable
  4775. + {
  4776. + private final Pair pairOne;
  4777. + private final Pair pairTwo;
  4778. + private final int pOneX, pOneY, pOneZ, pTwoX, pTwoY, pTwoZ;
  4779. + private Arena arena;
  4780. +
  4781. + public EvtArenaTask(List<Pair> opponents)
  4782. + {
  4783. + pairOne = opponents.get(0);
  4784. + pairTwo = opponents.get(1);
  4785. + L2PcInstance leader = pairOne.getLeader();
  4786. + pOneX = leader.getX();
  4787. + pOneY = leader.getY();
  4788. + pOneZ = leader.getZ();
  4789. + leader = pairTwo.getLeader();
  4790. + pTwoX = leader.getX();
  4791. + pTwoY = leader.getY();
  4792. + pTwoZ = leader.getZ();
  4793. + }
  4794. +
  4795. + @Override
  4796. + public void run()
  4797. + {
  4798. + free--;
  4799. + pairOne.saveTitle();
  4800. + pairTwo.saveTitle();
  4801. + portPairsToArena();
  4802. + pairOne.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_9X9);
  4803. + pairTwo.inicarContagem(ArenaConfig.ARENA_WAIT_INTERVAL_9X9);
  4804. + try
  4805. + {
  4806. + Thread.sleep(ArenaConfig.ARENA_WAIT_INTERVAL_9X9 * 1000);
  4807. + }
  4808. + catch (InterruptedException e1)
  4809. + {
  4810. + }
  4811. + pairOne.sendPacketinit("Started. Good Fight!", 3);
  4812. + pairTwo.sendPacketinit("Started. Good Fight!", 3);
  4813. + pairOne.EventTitle(ArenaConfig.MSG_TEAM1, ArenaConfig.TITLE_COLOR_TEAM1);
  4814. + pairTwo.EventTitle(ArenaConfig.MSG_TEAM2, ArenaConfig.TITLE_COLOR_TEAM2);
  4815. + pairOne.setImobilised(false);
  4816. + pairTwo.setImobilised(false);
  4817. + pairOne.setArenaAttack(true);
  4818. + pairTwo.setArenaAttack(true);
  4819. +
  4820. + while (check())
  4821. + {
  4822. + // check players status each seconds
  4823. + try
  4824. + {
  4825. + Thread.sleep(ArenaConfig.ARENA_CHECK_INTERVAL);
  4826. + }
  4827. + catch (InterruptedException e)
  4828. + {
  4829. + break;
  4830. + }
  4831. + }
  4832. + finishDuel();
  4833. + free++;
  4834. + }
  4835. +
  4836. + private void finishDuel()
  4837. + {
  4838. + fights.remove(arena.id);
  4839. + rewardWinner();
  4840. + pairOne.revive();
  4841. + pairTwo.revive();
  4842. + pairOne.teleportTo(pOneX, pOneY, pOneZ);
  4843. + pairTwo.teleportTo(pTwoX, pTwoY, pTwoZ);
  4844. + pairOne.backTitle();
  4845. + pairTwo.backTitle();
  4846. + pairOne.setRealInstance();
  4847. + pairTwo.setRealInstance();
  4848. + pairOne.setInTournamentEvent(false);
  4849. + pairTwo.setInTournamentEvent(false);
  4850. + pairOne.setArenaProtection(false);
  4851. + pairTwo.setArenaProtection(false);
  4852. + pairOne.setArenaAttack(false);
  4853. + pairTwo.setArenaAttack(false);
  4854. + arena.setFree(true);
  4855. + }
  4856. +
  4857. + private void rewardWinner()
  4858. + {
  4859. + if (pairOne.isAlive() && !pairTwo.isAlive())
  4860. + {
  4861. + L2PcInstance leader1 = pairOne.getLeader();
  4862. + L2PcInstance leader2 = pairTwo.getLeader();
  4863. +
  4864. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  4865. + Broadcast.gameAnnounceToOnlinePlayers("(9X9):(" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  4866. +
  4867. + pairOne.rewards();
  4868. + pairTwo.rewardsLost();
  4869. + }
  4870. + else if (pairTwo.isAlive() && !pairOne.isAlive())
  4871. + {
  4872. + L2PcInstance leader1 = pairTwo.getLeader();
  4873. + L2PcInstance leader2 = pairOne.getLeader();
  4874. +
  4875. + if (leader1.getClan() != null && leader2.getClan() != null && ArenaConfig.TOURNAMENT_EVENT_ANNOUNCE)
  4876. + Broadcast.gameAnnounceToOnlinePlayers("(9X9):(" + leader1.getClan().getName() + " VS " + leader2.getClan().getName() + ") ~> " + leader1.getClan().getName() + " win!");
  4877. +
  4878. + pairTwo.rewards();
  4879. + pairOne.rewardsLost();
  4880. + }
  4881. + }
  4882. +
  4883. + private boolean check()
  4884. + {
  4885. + return (pairOne.isDead() && pairTwo.isDead());
  4886. + }
  4887. +
  4888. + private void portPairsToArena()
  4889. + {
  4890. + for (Arena arena : arenas)
  4891. + {
  4892. + if (arena.isFree)
  4893. + {
  4894. + this.arena = arena;
  4895. + arena.setFree(false);
  4896. + pairOne.removePet();
  4897. + pairTwo.removePet();
  4898. + pairOne.setArenaInstance();
  4899. + pairTwo.setArenaInstance();
  4900. + pairOne.teleportTo(arena.x - 850, arena.y, arena.z);
  4901. + pairTwo.teleportTo(arena.x + 850, arena.y, arena.z);
  4902. + pairOne.setImobilised(true);
  4903. + pairTwo.setImobilised(true);
  4904. + pairOne.setInTournamentEvent(true);
  4905. + pairTwo.setInTournamentEvent(true);
  4906. + pairOne.removeSkills();
  4907. + pairTwo.removeSkills();
  4908. + fights.put(this.arena.id, pairOne.getLeader().getName() + " vs " + pairTwo.getLeader().getName());
  4909. + break;
  4910. + }
  4911. + }
  4912. + }
  4913. + }
  4914. +
  4915. + private class Arena
  4916. + {
  4917. + protected int x, y, z;
  4918. + protected boolean isFree = true;
  4919. + int id;
  4920. +
  4921. + public Arena(int id, int x, int y, int z)
  4922. + {
  4923. + this.id = id;
  4924. + this.x = x;
  4925. + this.y = y;
  4926. + this.z = z;
  4927. + }
  4928. +
  4929. + public void setFree(boolean val)
  4930. + {
  4931. + isFree = val;
  4932. + }
  4933. + }
  4934. +
  4935. + protected class countdown implements Runnable
  4936. + {
  4937. + private final L2PcInstance _player;
  4938. + private int _time;
  4939. +
  4940. + public countdown(L2PcInstance player, int time)
  4941. + {
  4942. + _time = time;
  4943. + _player = player;
  4944. + }
  4945. +
  4946. + @Override
  4947. + public void run()
  4948. + {
  4949. + if (_player.isOnline() == 1)
  4950. + {
  4951. +
  4952. + switch (_time)
  4953. + {
  4954. + case 300:
  4955. + case 240:
  4956. + case 180:
  4957. + case 120:
  4958. + case 57:
  4959. + if (_player.isOnline() == 1)
  4960. + {
  4961. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 60 second(s)..", 4000));
  4962. + _player.sendMessage("60 second(s) to start the battle.");
  4963. + }
  4964. + break;
  4965. + case 45:
  4966. + if (_player.isOnline() == 1)
  4967. + {
  4968. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  4969. + _player.sendMessage(_time + " second(s) to start the battle!");
  4970. + }
  4971. + break;
  4972. + case 27:
  4973. + if (_player.isOnline() == 1)
  4974. + {
  4975. + _player.sendPacket(new ExShowScreenMessage("The battle starts in 30 second(s)..", 4000));
  4976. + _player.sendMessage("30 second(s) to start the battle.");
  4977. + }
  4978. + break;
  4979. + case 20:
  4980. + if (_player.isOnline() == 1)
  4981. + {
  4982. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  4983. + _player.sendMessage(_time + " second(s) to start the battle!");
  4984. + }
  4985. + break;
  4986. + case 15:
  4987. + if (_player.isOnline() == 1)
  4988. + {
  4989. + _player.sendPacket(new ExShowScreenMessage("" + _time + " ..", 3000));
  4990. + _player.sendMessage(_time + " second(s) to start the battle!");
  4991. + }
  4992. + break;
  4993. + case 10:
  4994. + if (_player.isOnline() == 1)
  4995. + _player.sendMessage(_time + " second(s) to start the battle!");
  4996. + break;
  4997. + case 5:
  4998. + if (_player.isOnline() == 1)
  4999. + _player.sendMessage(_time + " second(s) to start the battle!");
  5000. + break;
  5001. + case 4:
  5002. + if (_player.isOnline() == 1)
  5003. + _player.sendMessage(_time + " second(s) to start the battle!");
  5004. + break;
  5005. + case 3:
  5006. + if (_player.isOnline() == 1)
  5007. + _player.sendMessage(_time + " second(s) to start the battle!");
  5008. + break;
  5009. + case 2:
  5010. + if (_player.isOnline() == 1)
  5011. + _player.sendMessage(_time + " second(s) to start the battle!");
  5012. + break;
  5013. + case 1:
  5014. + if (_player.isOnline() == 1)
  5015. + _player.sendMessage(_time + " second(s) to start the battle!");
  5016. + break;
  5017. + }
  5018. + if (_time > 1)
  5019. + {
  5020. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(_player, _time - 1), 1000);
  5021. + }
  5022. + }
  5023. + }
  5024. + }
  5025. +
  5026. + private static class SingletonHolder
  5027. + {
  5028. + protected static final Arena9x9 INSTANCE = new Arena9x9();
  5029. + }
  5030. +}
  5031. \ No newline at end of file
  5032. diff --git a/head-src/Dev/Tournament/properties/ArenaConfig.java b/head-src/Dev/Tournament/properties/ArenaConfig.java
  5033. new file mode 100644
  5034. index 0000000..9d5d1aa
  5035. --- /dev/null
  5036. +++ b/head-src/Dev/Tournament/properties/ArenaConfig.java
  5037. @@ -0,0 +1,368 @@
  5038. +/*
  5039. + * Copyright (C) 2004-2013 L2J Server
  5040. + *
  5041. + * This file is part of L2J Server.
  5042. + *
  5043. + * L2J Server is free software: you can redistribute it and/or modify
  5044. + * it under the terms of the GNU General Public License as published by
  5045. + * the Free Software Foundation, either version 3 of the License, or
  5046. + * (at your option) any later version.
  5047. + *
  5048. + * L2J Server is distributed in the hope that it will be useful,
  5049. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5050. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5051. + * General Public License for more details.
  5052. + *
  5053. + * You should have received a copy of the GNU General Public License
  5054. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  5055. + */
  5056. +package Dev.Tournament.properties;
  5057. +
  5058. +import com.l2jfrozen.commons.config.ExProperties;
  5059. +
  5060. +import java.io.File;
  5061. +import java.io.IOException;
  5062. +import java.util.ArrayList;
  5063. +import java.util.List;
  5064. +import java.util.logging.Logger;
  5065. +
  5066. +public class ArenaConfig
  5067. +{
  5068. + protected static final Logger _log = Logger.getLogger(ArenaConfig.class.getName());
  5069. +
  5070. + private static final String ARENA_FILE = "./config/CustomMods/Events/Tournament.ini";
  5071. +
  5072. + // tournament
  5073. + public static boolean TOURNAMENT_EVENT_START;
  5074. + public static boolean TOURNAMENT_EVENT_TIME;
  5075. + public static boolean TOURNAMENT_EVENT_SUMMON;
  5076. + public static boolean TOURNAMENT_EVENT_ANNOUNCE;
  5077. + public static boolean CHECK_NOBLESS;
  5078. +
  5079. + public static int TOURNAMENT_TIME;
  5080. + public static String[] TOURNAMENT_EVENT_INTERVAL_BY_TIME_OF_DAY;
  5081. +
  5082. + public static String TITLE_COLOR_TEAM1;
  5083. + public static String TITLE_COLOR_TEAM2;
  5084. +
  5085. + public static String MSG_TEAM1;
  5086. + public static String MSG_TEAM2;
  5087. +
  5088. + public static boolean Allow_Same_HWID_On_Tournament;
  5089. +
  5090. + public static int ARENA_NPC;
  5091. +
  5092. + public static int NPC_locx;
  5093. + public static int NPC_locy;
  5094. + public static int NPC_locz;
  5095. + public static int NPC_Heading;
  5096. +
  5097. + public static int NPC_locx2;
  5098. + public static int NPC_locy2;
  5099. + public static int NPC_locz2;
  5100. + public static int NPC_Heading2;
  5101. +
  5102. + public static int Tournament_locx;
  5103. + public static int Tournament_locy;
  5104. + public static int Tournament_locz;
  5105. +
  5106. + public static boolean ALLOW_1X1_REGISTER;
  5107. + public static boolean ALLOW_3X3_REGISTER;
  5108. + public static boolean ALLOW_5X5_REGISTER;
  5109. + public static boolean ALLOW_9X9_REGISTER;
  5110. +
  5111. + public static boolean ALLOW_5X5_LOSTBUFF;
  5112. +
  5113. + public static boolean ARENA_MESSAGE_ENABLED;
  5114. + public static String ARENA_MESSAGE_TEXT;
  5115. + public static int ARENA_MESSAGE_TIME;
  5116. +
  5117. + public static int ARENA_EVENT_COUNT_1X1;
  5118. + public static int[][] ARENA_EVENT_LOCS_1X1;
  5119. +
  5120. + public static int ARENA_EVENT_COUNT_3X3;
  5121. + public static int[][] ARENA_EVENT_LOCS_3X3;
  5122. +
  5123. + public static int ARENA_EVENT_COUNT_5X5;
  5124. + public static int[][] ARENA_EVENT_LOCS_5X5;
  5125. +
  5126. + public static int ARENA_EVENT_COUNT_9X9;
  5127. + public static int[][] ARENA_EVENT_LOCS_9X9;
  5128. +
  5129. + public static int duelist_COUNT_3X3;
  5130. + public static int dreadnought_COUNT_3X3;
  5131. + public static int tanker_COUNT_3X3;
  5132. + public static int dagger_COUNT_3X3;
  5133. + public static int archer_COUNT_3X3;
  5134. + public static int bs_COUNT_3X3;
  5135. + public static int archmage_COUNT_3X3;
  5136. + public static int soultaker_COUNT_3X3;
  5137. + public static int mysticMuse_COUNT_3X3;
  5138. + public static int stormScreamer_COUNT_3X3;
  5139. + public static int titan_COUNT_3X3;
  5140. + public static int dominator_COUNT_3X3;
  5141. +
  5142. + public static int duelist_COUNT_5X5;
  5143. + public static int dreadnought_COUNT_5X5;
  5144. + public static int tanker_COUNT_5X5;
  5145. + public static int dagger_COUNT_5X5;
  5146. + public static int archer_COUNT_5X5;
  5147. + public static int bs_COUNT_5X5;
  5148. + public static int archmage_COUNT_5X5;
  5149. + public static int soultaker_COUNT_5X5;
  5150. + public static int mysticMuse_COUNT_5X5;
  5151. + public static int stormScreamer_COUNT_5X5;
  5152. + public static int titan_COUNT_5X5;
  5153. + public static int dominator_COUNT_5X5;
  5154. +
  5155. + public static int duelist_COUNT_9X9;
  5156. + public static int dreadnought_COUNT_9X9;
  5157. + public static int tanker_COUNT_9X9;
  5158. + public static int dagger_COUNT_9X9;
  5159. + public static int archer_COUNT_9X9;
  5160. + public static int bs_COUNT_9X9;
  5161. + public static int archmage_COUNT_9X9;
  5162. + public static int soultaker_COUNT_9X9;
  5163. + public static int mysticMuse_COUNT_9X9;
  5164. + public static int stormScreamer_COUNT_9X9;
  5165. + public static int titan_COUNT_9X9;
  5166. + public static int dominator_COUNT_9X9;
  5167. +
  5168. + public static int ARENA_REWARD_ID;
  5169. + public static int ARENA_VIP_DROP_RATE;
  5170. + public static int ARENA_WIN_REWARD_COUNT_1X1;
  5171. + public static int ARENA_LOST_REWARD_COUNT_1X1;
  5172. + public static int ARENA_WIN_REWARD_COUNT_3X3;
  5173. + public static int ARENA_LOST_REWARD_COUNT_3X3;
  5174. + public static int ARENA_WIN_REWARD_COUNT_5X5;
  5175. + public static int ARENA_LOST_REWARD_COUNT_5X5;
  5176. + public static int ARENA_WIN_REWARD_COUNT_9X9;
  5177. + public static int ARENA_LOST_REWARD_COUNT_9X9;
  5178. +
  5179. + public static int ARENA_CHECK_INTERVAL;
  5180. + public static int ARENA_CALL_INTERVAL;
  5181. +
  5182. + public static int ARENA_WAIT_INTERVAL_1X1;
  5183. + public static int ARENA_WAIT_INTERVAL_3X3;
  5184. + public static int ARENA_WAIT_INTERVAL_5X5;
  5185. + public static int ARENA_WAIT_INTERVAL_9X9;
  5186. +
  5187. + public static String TOURNAMENT_ID_RESTRICT;
  5188. + public static List<Integer> TOURNAMENT_LISTID_RESTRICT;
  5189. + public static boolean ARENA_SKILL_PROTECT;
  5190. + public static List<Integer> ARENA_SKILL_LIST = new ArrayList<>();
  5191. + public static List<Integer> ARENA_DISABLE_SKILL_LIST = new ArrayList<>();
  5192. + public static List<Integer> ARENA_STOP_SKILL_LIST = new ArrayList<>();
  5193. + public static List<Integer> ARENA_DISABLE_SKILL_LIST_PERM = new ArrayList<>();
  5194. + public static boolean ARENA_PROTECT;
  5195. +
  5196. + public static void init()
  5197. + {
  5198. + ExProperties tournament = load(ARENA_FILE);
  5199. +
  5200. + TOURNAMENT_EVENT_START = tournament.getProperty("TournamentStartOn", false);
  5201. + TOURNAMENT_EVENT_TIME = tournament.getProperty("TournamentAutoEvent", false);
  5202. + TOURNAMENT_EVENT_SUMMON = tournament.getProperty("TournamentSummon", false);
  5203. + TOURNAMENT_EVENT_ANNOUNCE = tournament.getProperty("TournamentAnnounce", false);
  5204. + CHECK_NOBLESS = tournament.getProperty("TournamentNobles", false);
  5205. +
  5206. + TOURNAMENT_EVENT_INTERVAL_BY_TIME_OF_DAY = tournament.getProperty("TournamentStartTime", "20:00").split(",");
  5207. +
  5208. + TOURNAMENT_TIME = Integer.parseInt(tournament.getProperty("TournamentEventTime", "1"));
  5209. +
  5210. + TITLE_COLOR_TEAM1 = tournament.getProperty("TitleColorTeam_1", "FFFFFF");
  5211. + TITLE_COLOR_TEAM2 = tournament.getProperty("TitleColorTeam_2", "FFFFFF");
  5212. +
  5213. + MSG_TEAM1 = tournament.getProperty("TitleTeam_1", "Team [1]");
  5214. + MSG_TEAM2 = tournament.getProperty("TitleTeam_2", "Team [2]");
  5215. +
  5216. + Allow_Same_HWID_On_Tournament = Boolean.parseBoolean(tournament.getProperty("Allow_Same_HWID_On_Tournament", "true"));
  5217. +
  5218. + ARENA_NPC = Integer.parseInt(tournament.getProperty("NPCRegister", "1"));
  5219. +
  5220. + NPC_locx = Integer.parseInt(tournament.getProperty("Locx", "1"));
  5221. + NPC_locy = Integer.parseInt(tournament.getProperty("Locy", "1"));
  5222. + NPC_locz = Integer.parseInt(tournament.getProperty("Locz", "1"));
  5223. + NPC_Heading = Integer.parseInt(tournament.getProperty("Heading", "1"));
  5224. +
  5225. + NPC_locx2 = Integer.parseInt(tournament.getProperty("Locx2", "1"));
  5226. + NPC_locy2 = Integer.parseInt(tournament.getProperty("Locy2", "1"));
  5227. + NPC_locz2 = Integer.parseInt(tournament.getProperty("Locz2", "1"));
  5228. + NPC_Heading2 = Integer.parseInt(tournament.getProperty("Heading2", "1"));
  5229. +
  5230. + Tournament_locx = Integer.parseInt(tournament.getProperty("TournamentLocx", "1"));
  5231. + Tournament_locy = Integer.parseInt(tournament.getProperty("TournamentLocy", "1"));
  5232. + Tournament_locz = Integer.parseInt(tournament.getProperty("TournamentLocz", "1"));
  5233. +
  5234. + ALLOW_1X1_REGISTER = Boolean.parseBoolean(tournament.getProperty("Allow1x1Register", "true"));
  5235. + ALLOW_3X3_REGISTER = Boolean.parseBoolean(tournament.getProperty("Allow3x3Register", "true"));
  5236. + ALLOW_5X5_REGISTER = Boolean.parseBoolean(tournament.getProperty("Allow5x5Register", "true"));
  5237. + ALLOW_9X9_REGISTER = Boolean.parseBoolean(tournament.getProperty("Allow9x9Register", "true"));
  5238. +
  5239. + ALLOW_5X5_LOSTBUFF = Boolean.parseBoolean(tournament.getProperty("Allow5x5LostBuff", "false"));
  5240. +
  5241. + ARENA_MESSAGE_ENABLED = Boolean.parseBoolean(tournament.getProperty("ScreenArenaMessageEnable", "false"));
  5242. + ARENA_MESSAGE_TEXT = tournament.getProperty("ScreenArenaMessageText", "Welcome to L2J server!");
  5243. + ARENA_MESSAGE_TIME = Integer.parseInt(tournament.getProperty("ScreenArenaMessageTime", "10")) * 1000;
  5244. +
  5245. + String[] arenaLocs1x1 = tournament.getProperty("ArenasLoc1x1", "").split(";");
  5246. + String[] locSplit1x1 = null;
  5247. + ARENA_EVENT_COUNT_1X1 = arenaLocs1x1.length;
  5248. + ARENA_EVENT_LOCS_1X1 = new int[ARENA_EVENT_COUNT_1X1][3];
  5249. + for (int i = 0; i < ARENA_EVENT_COUNT_1X1; i++)
  5250. + {
  5251. + locSplit1x1 = arenaLocs1x1[i].split(",");
  5252. + for (int j = 0; j < 3; j++)
  5253. + {
  5254. + ARENA_EVENT_LOCS_1X1[i][j] = Integer.parseInt(locSplit1x1[j].trim());
  5255. + }
  5256. + }
  5257. +
  5258. + String[] arenaLocs3x3 = tournament.getProperty("ArenasLoc3x3", "").split(";");
  5259. + String[] locSplit3x3 = null;
  5260. + ARENA_EVENT_COUNT_3X3 = arenaLocs3x3.length;
  5261. + ARENA_EVENT_LOCS_3X3 = new int[ARENA_EVENT_COUNT_3X3][3];
  5262. + for (int i = 0; i < ARENA_EVENT_COUNT_3X3; i++)
  5263. + {
  5264. + locSplit3x3 = arenaLocs3x3[i].split(",");
  5265. + for (int j = 0; j < 3; j++)
  5266. + {
  5267. + ARENA_EVENT_LOCS_3X3[i][j] = Integer.parseInt(locSplit3x3[j].trim());
  5268. + }
  5269. + }
  5270. +
  5271. + String[] arenaLocs5x5 = tournament.getProperty("Arenas5x5Loc", "").split(";");
  5272. + String[] locSplit5x5 = null;
  5273. + ARENA_EVENT_COUNT_5X5 = arenaLocs5x5.length;
  5274. + ARENA_EVENT_LOCS_5X5 = new int[ARENA_EVENT_COUNT_5X5][3];
  5275. + for (int i = 0; i < ARENA_EVENT_COUNT_5X5; i++)
  5276. + {
  5277. + locSplit5x5 = arenaLocs5x5[i].split(",");
  5278. + for (int j = 0; j < 3; j++)
  5279. + {
  5280. + ARENA_EVENT_LOCS_5X5[i][j] = Integer.parseInt(locSplit5x5[j].trim());
  5281. + }
  5282. + }
  5283. +
  5284. + String[] arenaLocs9x9 = tournament.getProperty("Arenas9x9Loc", "").split(";");
  5285. + String[] locSplit8x8 = null;
  5286. + ARENA_EVENT_COUNT_9X9 = arenaLocs9x9.length;
  5287. + ARENA_EVENT_LOCS_9X9 = new int[ARENA_EVENT_COUNT_9X9][3];
  5288. + for (int i = 0; i < ARENA_EVENT_COUNT_9X9; i++)
  5289. + {
  5290. + locSplit8x8 = arenaLocs9x9[i].split(",");
  5291. + for (int j = 0; j < 3; j++)
  5292. + {
  5293. + ARENA_EVENT_LOCS_9X9[i][j] = Integer.parseInt(locSplit8x8[j].trim());
  5294. + }
  5295. + }
  5296. +
  5297. + duelist_COUNT_3X3 = tournament.getProperty("duelist_amount_3x3", 1);
  5298. + dreadnought_COUNT_3X3 = tournament.getProperty("dreadnought_amount_3x3", 1);
  5299. + tanker_COUNT_3X3 = tournament.getProperty("tanker_amount_3x3", 1);
  5300. + dagger_COUNT_3X3 = tournament.getProperty("dagger_amount_3x3", 1);
  5301. + archer_COUNT_3X3 = tournament.getProperty("archer_amount_3x3", 1);
  5302. + bs_COUNT_3X3 = tournament.getProperty("bs_amount_3x3", 1);
  5303. + archmage_COUNT_3X3 = tournament.getProperty("archmage_amount_3x3", 1);
  5304. + soultaker_COUNT_3X3 = tournament.getProperty("soultaker_amount_3x3", 1);
  5305. + mysticMuse_COUNT_3X3 = tournament.getProperty("mysticMuse_amount_3x3", 1);
  5306. + stormScreamer_COUNT_3X3 = tournament.getProperty("stormScreamer_amount_3x3", 1);
  5307. + titan_COUNT_3X3 = tournament.getProperty("titan_amount_3x3", 1);
  5308. + dominator_COUNT_3X3 = tournament.getProperty("dominator_amount_3x3", 1);
  5309. +
  5310. + duelist_COUNT_5X5 = tournament.getProperty("duelist_amount_5x5", 1);
  5311. + dreadnought_COUNT_5X5 = tournament.getProperty("dreadnought_amount_5x5", 1);
  5312. + tanker_COUNT_5X5 = tournament.getProperty("tanker_amount_5x5", 1);
  5313. + dagger_COUNT_5X5 = tournament.getProperty("dagger_amount_5x5", 1);
  5314. + archer_COUNT_5X5 = tournament.getProperty("archer_amount_5x5", 1);
  5315. + bs_COUNT_5X5 = tournament.getProperty("bs_amount_5x5", 1);
  5316. + archmage_COUNT_5X5 = tournament.getProperty("archmage_amount_5x5", 1);
  5317. + soultaker_COUNT_5X5 = tournament.getProperty("soultaker_amount_5x5", 1);
  5318. + mysticMuse_COUNT_5X5 = tournament.getProperty("mysticMuse_amount_5x5", 1);
  5319. + stormScreamer_COUNT_5X5 = tournament.getProperty("stormScreamer_amount_5x5", 1);
  5320. + titan_COUNT_5X5 = tournament.getProperty("titan_amount_5x5", 1);
  5321. + dominator_COUNT_5X5 = tournament.getProperty("dominator_amount_5x5", 1);
  5322. +
  5323. + duelist_COUNT_9X9 = tournament.getProperty("duelist_amount_9x9", 1);
  5324. + dreadnought_COUNT_9X9 = tournament.getProperty("dreadnought_amount_9x9", 1);
  5325. + tanker_COUNT_9X9 = tournament.getProperty("tanker_amount_9x9", 1);
  5326. + dagger_COUNT_9X9 = tournament.getProperty("dagger_amount_9x9", 1);
  5327. + archer_COUNT_9X9 = tournament.getProperty("archer_amount_9x9", 1);
  5328. + bs_COUNT_9X9 = tournament.getProperty("bs_amount_9x9", 1);
  5329. + archmage_COUNT_9X9 = tournament.getProperty("archmage_amount_9x9", 1);
  5330. + soultaker_COUNT_9X9 = tournament.getProperty("soultaker_amount_9x9", 1);
  5331. + mysticMuse_COUNT_9X9 = tournament.getProperty("mysticMuse_amount_9x9", 1);
  5332. + stormScreamer_COUNT_9X9 = tournament.getProperty("stormScreamer_amount_9x9", 1);
  5333. + titan_COUNT_9X9 = tournament.getProperty("titan_amount_9x9", 1);
  5334. + dominator_COUNT_9X9 = tournament.getProperty("dominator_amount_9x9", 1);
  5335. +
  5336. + ARENA_REWARD_ID = tournament.getProperty("ArenaRewardId", 57);
  5337. + ARENA_VIP_DROP_RATE = tournament.getProperty("ArenaRateDropVIP", 1);
  5338. + ARENA_WIN_REWARD_COUNT_1X1 = tournament.getProperty("ArenaWinRewardCount1x1", 1);
  5339. + ARENA_LOST_REWARD_COUNT_1X1 = tournament.getProperty("ArenaLostRewardCount1x1", 1);
  5340. + ARENA_WIN_REWARD_COUNT_3X3 = tournament.getProperty("ArenaWinRewardCount3x3", 1);
  5341. + ARENA_LOST_REWARD_COUNT_3X3 = tournament.getProperty("ArenaLostRewardCount3x3", 1);
  5342. + ARENA_WIN_REWARD_COUNT_5X5 = tournament.getProperty("ArenaWinRewardCount5x5", 1);
  5343. + ARENA_LOST_REWARD_COUNT_5X5 = tournament.getProperty("ArenaLostRewardCount5x5", 1);
  5344. + ARENA_WIN_REWARD_COUNT_9X9 = tournament.getProperty("ArenaWinRewardCount9x9", 1);
  5345. + ARENA_LOST_REWARD_COUNT_9X9 = tournament.getProperty("ArenaLostRewardCount9x9", 1);
  5346. +
  5347. + ARENA_CHECK_INTERVAL = tournament.getProperty("ArenaBattleCheckInterval", 15) * 1000;
  5348. + ARENA_CALL_INTERVAL = tournament.getProperty("ArenaBattleCallInterval", 60);
  5349. +
  5350. + ARENA_WAIT_INTERVAL_1X1 = tournament.getProperty("ArenaBattleWaitInterval1x1", 20);
  5351. + ARENA_WAIT_INTERVAL_3X3 = tournament.getProperty("ArenaBattleWaitInterval3x3", 20);
  5352. + ARENA_WAIT_INTERVAL_5X5 = tournament.getProperty("ArenaBattleWaitInterval5x5", 45);
  5353. + ARENA_WAIT_INTERVAL_9X9 = tournament.getProperty("ArenaBattleWaitInterval9x9", 45);
  5354. +
  5355. + TOURNAMENT_ID_RESTRICT = tournament.getProperty("ItemsRestriction");
  5356. +
  5357. + TOURNAMENT_LISTID_RESTRICT = new ArrayList<>();
  5358. + for (String id : TOURNAMENT_ID_RESTRICT.split(","))
  5359. + TOURNAMENT_LISTID_RESTRICT.add(Integer.parseInt(id));
  5360. +
  5361. + ARENA_SKILL_PROTECT = Boolean.parseBoolean(tournament.getProperty("ArenaSkillProtect", "false"));
  5362. +
  5363. + for (String id : tournament.getProperty("ArenaDisableSkillList", "0").split(","))
  5364. + {
  5365. + ARENA_SKILL_LIST.add(Integer.parseInt(id));
  5366. + }
  5367. +
  5368. + for (String id : tournament.getProperty("DisableSkillList", "0").split(","))
  5369. + {
  5370. + ARENA_DISABLE_SKILL_LIST_PERM.add(Integer.parseInt(id));
  5371. + }
  5372. +
  5373. + for (String id : tournament.getProperty("ArenaDisableSkillList_noStart", "0").split(","))
  5374. + {
  5375. + ARENA_DISABLE_SKILL_LIST.add(Integer.parseInt(id));
  5376. + }
  5377. +
  5378. + for (String id : tournament.getProperty("ArenaStopSkillList", "0").split(","))
  5379. + {
  5380. + ARENA_STOP_SKILL_LIST.add(Integer.parseInt(id));
  5381. + }
  5382. +
  5383. + ARENA_PROTECT = Boolean.parseBoolean(tournament.getProperty("ArenaProtect", "true"));
  5384. + }
  5385. +
  5386. + public static ExProperties load(String filename)
  5387. + {
  5388. + return load(new File(filename));
  5389. + }
  5390. +
  5391. + public static ExProperties load(File file)
  5392. + {
  5393. + ExProperties result = new ExProperties();
  5394. +
  5395. + try
  5396. + {
  5397. + result.load(file);
  5398. + }
  5399. + catch (IOException e)
  5400. + {
  5401. + _log.warning("Error loading config : " + file.getName() + "!");
  5402. + }
  5403. + return result;
  5404. + }
  5405. +}
  5406. \ No newline at end of file
  5407. diff --git a/head-src/Dev/Tournament/properties/ArenaEvent.java b/head-src/Dev/Tournament/properties/ArenaEvent.java
  5408. new file mode 100644
  5409. index 0000000..51a06d3
  5410. --- /dev/null
  5411. +++ b/head-src/Dev/Tournament/properties/ArenaEvent.java
  5412. @@ -0,0 +1,109 @@
  5413. +/*
  5414. + * This program is free software: you can redistribute it and/or modify it under
  5415. + * the terms of the GNU General Public License as published by the Free Software
  5416. + * Foundation, either version 3 of the License, or (at your option) any later
  5417. + * version.
  5418. + *
  5419. + * This program is distributed in the hope that it will be useful, but WITHOUT
  5420. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  5421. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  5422. + * details.
  5423. + *
  5424. + * You should have received a copy of the GNU General Public License along with
  5425. + * this program. If not, see <http://www.gnu.org/licenses/>.
  5426. + */
  5427. +package Dev.Tournament.properties;
  5428. +
  5429. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  5430. +
  5431. +import java.text.SimpleDateFormat;
  5432. +import java.util.Calendar;
  5433. +import java.util.logging.Logger;
  5434. +
  5435. +/**
  5436. + * @author Axcel Kuhn (Baseado no Restart System)
  5437. + */
  5438. +public class ArenaEvent
  5439. +{
  5440. + private static ArenaEvent _instance = null;
  5441. + protected static final Logger _log = Logger.getLogger(ArenaEvent.class.getName());
  5442. + private Calendar NextEvent;
  5443. + private final SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  5444. +
  5445. + public static ArenaEvent getInstance()
  5446. + {
  5447. + if (_instance == null)
  5448. + _instance = new ArenaEvent();
  5449. + return _instance;
  5450. + }
  5451. +
  5452. + public String getNextTime()
  5453. + {
  5454. + if (NextEvent.getTime() != null)
  5455. + return format.format(NextEvent.getTime());
  5456. + return "Erro";
  5457. + }
  5458. +
  5459. + private ArenaEvent()
  5460. + {
  5461. + }
  5462. +
  5463. + public void StartCalculationOfNextEventTime()
  5464. + {
  5465. + try
  5466. + {
  5467. + Calendar currentTime = Calendar.getInstance();
  5468. + Calendar testStartTime = null;
  5469. + long flush2 = 0, timeL = 0;
  5470. + int count = 0;
  5471. +
  5472. + for (String timeOfDay : ArenaConfig.TOURNAMENT_EVENT_INTERVAL_BY_TIME_OF_DAY)
  5473. + {
  5474. + testStartTime = Calendar.getInstance();
  5475. + testStartTime.setLenient(true);
  5476. + String[] splitTimeOfDay = timeOfDay.split(":");
  5477. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  5478. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  5479. + testStartTime.set(Calendar.SECOND, 00);
  5480. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  5481. + {
  5482. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  5483. + }
  5484. +
  5485. + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
  5486. +
  5487. + if (count == 0)
  5488. + {
  5489. + flush2 = timeL;
  5490. + NextEvent = testStartTime;
  5491. + }
  5492. +
  5493. + if (timeL < flush2)
  5494. + {
  5495. + flush2 = timeL;
  5496. + NextEvent = testStartTime;
  5497. + }
  5498. + count++;
  5499. + }
  5500. + _log.info("Tournament: Next Event " + NextEvent.getTime().toString());
  5501. + ThreadPoolManager.getInstance().scheduleGeneral(new StartEventTask(), flush2);
  5502. + }
  5503. + catch (Exception e)
  5504. + {
  5505. + e.printStackTrace();
  5506. + System.out.println("[Tournament]: "+e);
  5507. + }
  5508. + }
  5509. +
  5510. + class StartEventTask implements Runnable
  5511. + {
  5512. + @Override
  5513. + public void run()
  5514. + {
  5515. + _log.info("----------------------------------------------------------------------------");
  5516. + _log.info("Tournament: Event Started.");
  5517. + _log.info("----------------------------------------------------------------------------");
  5518. + ArenaTask.SpawnEvent();
  5519. + }
  5520. + }
  5521. +}
  5522. diff --git a/head-src/Dev/Tournament/properties/ArenaTask.java b/head-src/Dev/Tournament/properties/ArenaTask.java
  5523. new file mode 100644
  5524. index 0000000..1dbe67e
  5525. --- /dev/null
  5526. +++ b/head-src/Dev/Tournament/properties/ArenaTask.java
  5527. @@ -0,0 +1,311 @@
  5528. +/*
  5529. + * This program is free software: you can redistribute it and/or modify it under
  5530. + * the terms of the GNU General Public License as published by the Free Software
  5531. + * Foundation, either version 3 of the License, or (at your option) any later
  5532. + * version.
  5533. + *
  5534. + * This program is distributed in the hope that it will be useful, but WITHOUT
  5535. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  5536. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  5537. + * details.
  5538. + *
  5539. + * You should have received a copy of the GNU General Public License along with
  5540. + * this program. If not, see <http://www.gnu.org/licenses/>.
  5541. + */
  5542. +package Dev.Tournament.properties;
  5543. +
  5544. +import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
  5545. +import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
  5546. +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable;
  5547. +import com.l2jfrozen.gameserver.model.L2World;
  5548. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  5549. +import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
  5550. +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
  5551. +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
  5552. +import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
  5553. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  5554. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  5555. +import com.l2jfrozen.gameserver.util.Broadcast;
  5556. +
  5557. +import Dev.Tournament.Arena1x1;
  5558. +import Dev.Tournament.Arena3x3;
  5559. +import Dev.Tournament.Arena5x5;
  5560. +import Dev.Tournament.Arena9x9;
  5561. +
  5562. +public abstract class ArenaTask
  5563. +{
  5564. + public static L2Spawn _npcSpawn1;
  5565. + public static L2Spawn _npcSpawn2;
  5566. +
  5567. + public static int _bossHeading = 0;
  5568. +
  5569. + /** The _in progress. */
  5570. + public static boolean _started = false;
  5571. +
  5572. + public static boolean _aborted = false;
  5573. +
  5574. + public static void SpawnEvent()
  5575. + {
  5576. + Arena1x1.getInstance().clear();
  5577. + Arena3x3.getInstance().clear();
  5578. + Arena5x5.getInstance().clear();
  5579. + Arena9x9.getInstance().clear();
  5580. +
  5581. + spawnNpc1();
  5582. + spawnNpc2();
  5583. +
  5584. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: Event Started");
  5585. + //Broadcast.gameAnnounceToOnlinePlayers("Tournament: 1x1| 3x3 | 5x5 | 9x9");
  5586. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: Duration: " + ArenaConfig.TOURNAMENT_TIME + " minute(s)!");
  5587. +
  5588. + _aborted = false;
  5589. + _started = true;
  5590. +
  5591. + ThreadPoolManager.getInstance().scheduleGeneral(Arena1x1.getInstance(), 5000);
  5592. + ThreadPoolManager.getInstance().scheduleGeneral(Arena3x3.getInstance(), 5000);
  5593. + ThreadPoolManager.getInstance().scheduleGeneral(Arena5x5.getInstance(), 5000);
  5594. + ThreadPoolManager.getInstance().scheduleGeneral(Arena9x9.getInstance(), 5000);
  5595. +
  5596. + waiter(ArenaConfig.TOURNAMENT_TIME * 60 * 1000); // minutes for event time
  5597. +
  5598. + if (!_aborted)
  5599. + finishEvent();
  5600. + }
  5601. +
  5602. + public static void finishEvent()
  5603. + {
  5604. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: Event Finished!");
  5605. +
  5606. + unspawnNpc1();
  5607. + unspawnNpc2();
  5608. + _started = false;
  5609. +
  5610. + ArenaEvent.getInstance().StartCalculationOfNextEventTime();
  5611. +
  5612. + for (L2PcInstance player : L2World.getInstance().getAllPlayers())
  5613. + {
  5614. + if (player != null && player.isOnline() == 1)
  5615. + {
  5616. + if (player.isArenaProtection())
  5617. + {
  5618. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  5619. + {
  5620. +
  5621. + @Override
  5622. + public void run()
  5623. + {
  5624. + if (player.isOnline() == 1 && !player.isInArenaEvent() && !player.isArenaAttack())
  5625. + {
  5626. + if (player.isArena1x1())
  5627. + Arena1x1.getInstance().remove(player);
  5628. + if (player.isArena3x3())
  5629. + Arena3x3.getInstance().remove(player);
  5630. + if (player.isArena5x5())
  5631. + Arena5x5.getInstance().remove(player);
  5632. + if (player.isArena9x9())
  5633. + Arena9x9.getInstance().remove(player);
  5634. +
  5635. + player.setArenaProtection(false);
  5636. + }
  5637. + }
  5638. + }, 25000);
  5639. + }
  5640. +
  5641. + CreatureSay cs = new CreatureSay(player.getObjectId(), Say2.PARTY, "[Tournament]", ("Next Tournament: " + ArenaEvent.getInstance().getNextTime()) + " (GMT-3)."); // 8D
  5642. + player.sendPacket(cs);
  5643. + }
  5644. + }
  5645. + }
  5646. +
  5647. + public static void spawnNpc1()
  5648. + {
  5649. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(ArenaConfig.ARENA_NPC);
  5650. +
  5651. + try
  5652. + {
  5653. + _npcSpawn1 = new L2Spawn(tmpl);
  5654. + _npcSpawn1.setLocx(loc1x());
  5655. + _npcSpawn1.setLocy(loc1y());
  5656. + _npcSpawn1.setLocz(loc1z());
  5657. + _npcSpawn1.setHeading(ArenaConfig.NPC_Heading);
  5658. + _npcSpawn1.setRespawnDelay(1);
  5659. +
  5660. + SpawnTable.getInstance().addNewSpawn(_npcSpawn1, false);
  5661. +
  5662. + _npcSpawn1.doSpawn();
  5663. + _npcSpawn1.getLastSpawn().getStatus().setCurrentHp(999999999);
  5664. + _npcSpawn1.getLastSpawn().isAggressive();
  5665. + _npcSpawn1.getLastSpawn().decayMe();
  5666. + _npcSpawn1.getLastSpawn().spawnMe(_npcSpawn1.getLastSpawn().getX(), _npcSpawn1.getLastSpawn().getY(), _npcSpawn1.getLastSpawn().getZ());
  5667. + _npcSpawn1.getLastSpawn().broadcastPacket(new MagicSkillUser(_npcSpawn1.getLastSpawn(), _npcSpawn1.getLastSpawn(), 1034, 1, 1, 1));
  5668. + }
  5669. + catch (Exception e)
  5670. + {
  5671. + e.printStackTrace();
  5672. + }
  5673. + }
  5674. +
  5675. + public static void spawnNpc2()
  5676. + {
  5677. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(ArenaConfig.ARENA_NPC);
  5678. +
  5679. + try
  5680. + {
  5681. + _npcSpawn2 = new L2Spawn(tmpl);
  5682. + _npcSpawn2.setLocx(loc2x());
  5683. + _npcSpawn2.setLocy(loc2y());
  5684. + _npcSpawn2.setLocz(loc2z());
  5685. + _npcSpawn2.setHeading(ArenaConfig.NPC_Heading2);
  5686. + _npcSpawn2.setRespawnDelay(1);
  5687. +
  5688. +
  5689. + SpawnTable.getInstance().addNewSpawn(_npcSpawn2, false);
  5690. +
  5691. +
  5692. + _npcSpawn2.doSpawn();
  5693. + _npcSpawn2.getLastSpawn().getStatus().setCurrentHp(999999999);
  5694. + _npcSpawn2.getLastSpawn().isAggressive();
  5695. + _npcSpawn2.getLastSpawn().decayMe();
  5696. + _npcSpawn2.getLastSpawn().spawnMe(_npcSpawn2.getLastSpawn().getX(), _npcSpawn2.getLastSpawn().getY(), _npcSpawn2.getLastSpawn().getZ());
  5697. + _npcSpawn2.getLastSpawn().broadcastPacket(new MagicSkillUser(_npcSpawn2.getLastSpawn(), _npcSpawn2.getLastSpawn(), 1034, 1, 1, 1));
  5698. +
  5699. + }
  5700. + catch (Exception e)
  5701. + {
  5702. + e.printStackTrace();
  5703. + }
  5704. + }
  5705. +
  5706. + /**
  5707. + * Checks if is _started.
  5708. + * @return the _started
  5709. + */
  5710. + public static boolean is_started()
  5711. + {
  5712. + return _started;
  5713. + }
  5714. +
  5715. + public static void unspawnNpc1()
  5716. + {
  5717. + if (_npcSpawn1 == null)
  5718. + return;
  5719. +
  5720. + _npcSpawn1.getLastSpawn().deleteMe();
  5721. + _npcSpawn1.stopRespawn();
  5722. + SpawnTable.getInstance().deleteSpawn(_npcSpawn1, true);
  5723. + }
  5724. +
  5725. + public static void unspawnNpc2()
  5726. + {
  5727. + if (_npcSpawn2 == null)
  5728. + return;
  5729. +
  5730. + _npcSpawn2.getLastSpawn().deleteMe();
  5731. + _npcSpawn2.stopRespawn();
  5732. + SpawnTable.getInstance().deleteSpawn(_npcSpawn2, true);
  5733. + }
  5734. +
  5735. + public static int loc1x()
  5736. + {
  5737. + int loc1x = ArenaConfig.NPC_locx;
  5738. + return loc1x;
  5739. + }
  5740. +
  5741. + public static int loc1y()
  5742. + {
  5743. + int loc1y = ArenaConfig.NPC_locy;
  5744. + return loc1y;
  5745. + }
  5746. +
  5747. + public static int loc1z()
  5748. + {
  5749. + int loc1z = ArenaConfig.NPC_locz;
  5750. + return loc1z;
  5751. + }
  5752. +
  5753. + public static int loc2x()
  5754. + {
  5755. + int loc2x = ArenaConfig.NPC_locx2;
  5756. + return loc2x;
  5757. + }
  5758. +
  5759. + public static int loc2y()
  5760. + {
  5761. + int loc2y = ArenaConfig.NPC_locy2;
  5762. + return loc2y;
  5763. + }
  5764. +
  5765. + public static int loc2z()
  5766. + {
  5767. + int loc2z = ArenaConfig.NPC_locz2;
  5768. + return loc2z;
  5769. + }
  5770. +
  5771. + /**
  5772. + * Waiter.
  5773. + * @param interval the interval
  5774. + */
  5775. + protected static void waiter(long interval)
  5776. + {
  5777. + long startWaiterTime = System.currentTimeMillis();
  5778. + int seconds = (int) (interval / 1000);
  5779. +
  5780. + while (startWaiterTime + interval > System.currentTimeMillis() && !_aborted)
  5781. + {
  5782. + seconds--; // Here because we don't want to see two time announce at the same time
  5783. +
  5784. + switch (seconds)
  5785. + {
  5786. + case 3600: // 1 hour left
  5787. +
  5788. + if (_started)
  5789. + {
  5790. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: Party Event PvP");
  5791. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: Teleport in the GK to (Tournament) Zone");
  5792. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: Reward: " + ItemTable.getInstance().getTemplate(ArenaConfig.ARENA_REWARD_ID).getName());
  5793. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: " + seconds / 60 / 60 + " hour(s) till event finish!");
  5794. + }
  5795. + break;
  5796. + case 1800: // 30 minutes left
  5797. + case 900: // 15 minutes left
  5798. + case 600: // 10 minutes left
  5799. + case 300: // 5 minutes left
  5800. + case 240: // 4 minutes left
  5801. + case 180: // 3 minutes left
  5802. + case 120: // 2 minutes left
  5803. + case 60: // 1 minute left
  5804. + // removeOfflinePlayers();
  5805. +
  5806. + if (_started)
  5807. + {
  5808. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: " + seconds / 60 + " minute(s) till event finish!");
  5809. + }
  5810. + break;
  5811. + case 30: // 30 seconds left
  5812. + case 15: // 15 seconds left
  5813. + case 10: // 10 seconds left
  5814. + case 3: // 3 seconds left
  5815. + case 2: // 2 seconds left
  5816. + case 1: // 1 seconds left
  5817. + if (_started)
  5818. + Broadcast.gameAnnounceToOnlinePlayers("Tournament: " + seconds + " second(s) till event finish!");
  5819. +
  5820. + break;
  5821. + }
  5822. +
  5823. + long startOneSecondWaiterStartTime = System.currentTimeMillis();
  5824. +
  5825. + // Only the try catch with Thread.sleep(1000) give bad countdown on high wait times
  5826. + while (startOneSecondWaiterStartTime + 1000 > System.currentTimeMillis())
  5827. + {
  5828. + try
  5829. + {
  5830. + Thread.sleep(1);
  5831. + }
  5832. + catch (InterruptedException ie)
  5833. + {
  5834. + }
  5835. + }
  5836. + }
  5837. + }
  5838. +}
  5839. \ No newline at end of file
  5840. diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
  5841. index f9008de..f8a728a 100644
  5842. --- a/head-src/com/l2jfrozen/Config.java
  5843. +++ b/head-src/com/l2jfrozen/Config.java
  5844. @@ -45,6 +45,7 @@
  5845.  
  5846. import org.apache.log4j.Logger;
  5847.  
  5848. +import com.l2jfrozen.commons.config.ExProperties;
  5849. import com.l2jfrozen.gameserver.model.entity.olympiad.OlympiadPeriod;
  5850. import com.l2jfrozen.gameserver.model.holder.RewardHolder;
  5851. import com.l2jfrozen.gameserver.util.FloodProtectorConfig;
  5852. @@ -6268,7 +6269,26 @@
  5853. return false;
  5854. return true;
  5855. }
  5856. -
  5857. + /**
  5858. + * Initialize {@link ExProperties} from specified configuration file.
  5859. + * @param filename : File name to be loaded.
  5860. + * @return ExProperties : Initialized {@link ExProperties}.
  5861. + */
  5862. + public static final ExProperties initProperties(String filename)
  5863. + {
  5864. + final ExProperties result = new ExProperties();
  5865. +
  5866. + try
  5867. + {
  5868. + result.load(new File(filename));
  5869. + }
  5870. + catch (IOException e)
  5871. + {
  5872. + LOGGER.warn("Config: Error loading \"" + filename + "\" config.");
  5873. + }
  5874. +
  5875. + return result;
  5876. + }
  5877. public static void saveHexid(final int serverId, final String string)
  5878. {
  5879. Config.saveHexid(serverId, string, HEXID_FILE);
  5880. diff --git a/head-src/com/l2jfrozen/commons/config/ExProperties.java b/head-src/com/l2jfrozen/commons/config/ExProperties.java
  5881. new file mode 100644
  5882. index 0000000..b7cdc9c
  5883. --- /dev/null
  5884. +++ b/head-src/com/l2jfrozen/commons/config/ExProperties.java
  5885. @@ -0,0 +1,175 @@
  5886. +package com.l2jfrozen.commons.config;
  5887. +
  5888. +import java.io.File;
  5889. +import java.io.FileInputStream;
  5890. +import java.io.IOException;
  5891. +import java.io.InputStream;
  5892. +import java.util.Properties;
  5893. +
  5894. +public class ExProperties extends Properties
  5895. +{
  5896. + private static final long serialVersionUID = 1L;
  5897. +
  5898. + public static final String defaultDelimiter = "[\\s,;]+";
  5899. +
  5900. + public void load(final String fileName) throws IOException
  5901. + {
  5902. + load(new File(fileName));
  5903. + }
  5904. +
  5905. + public void load(final File file) throws IOException
  5906. + {
  5907. + try (InputStream is = new FileInputStream(file))
  5908. + {
  5909. + load(is);
  5910. + }
  5911. + }
  5912. +
  5913. + public boolean getProperty(final String name, final boolean defaultValue)
  5914. + {
  5915. + boolean val = defaultValue;
  5916. +
  5917. + final String value;
  5918. +
  5919. + if ((value = super.getProperty(name, null)) != null)
  5920. + val = Boolean.parseBoolean(value);
  5921. +
  5922. + return val;
  5923. + }
  5924. +
  5925. + public int getProperty(final String name, final int defaultValue)
  5926. + {
  5927. + int val = defaultValue;
  5928. +
  5929. + final String value;
  5930. +
  5931. + if ((value = super.getProperty(name, null)) != null)
  5932. + val = Integer.parseInt(value);
  5933. +
  5934. + return val;
  5935. + }
  5936. +
  5937. + public long getProperty(final String name, final long defaultValue)
  5938. + {
  5939. + long val = defaultValue;
  5940. +
  5941. + final String value;
  5942. +
  5943. + if ((value = super.getProperty(name, null)) != null)
  5944. + val = Long.parseLong(value);
  5945. +
  5946. + return val;
  5947. + }
  5948. +
  5949. + public double getProperty(final String name, final double defaultValue)
  5950. + {
  5951. + double val = defaultValue;
  5952. +
  5953. + final String value;
  5954. +
  5955. + if ((value = super.getProperty(name, null)) != null)
  5956. + val = Double.parseDouble(value);
  5957. +
  5958. + return val;
  5959. + }
  5960. +
  5961. + public String[] getProperty(final String name, final String[] defaultValue)
  5962. + {
  5963. + return getProperty(name, defaultValue, defaultDelimiter);
  5964. + }
  5965. +
  5966. + public String[] getProperty(final String name, final String[] defaultValue, final String delimiter)
  5967. + {
  5968. + String[] val = defaultValue;
  5969. + final String value;
  5970. +
  5971. + if ((value = super.getProperty(name, null)) != null)
  5972. + val = value.split(delimiter);
  5973. +
  5974. + return val;
  5975. + }
  5976. +
  5977. + public boolean[] getProperty(final String name, final boolean[] defaultValue)
  5978. + {
  5979. + return getProperty(name, defaultValue, defaultDelimiter);
  5980. + }
  5981. +
  5982. + public boolean[] getProperty(final String name, final boolean[] defaultValue, final String delimiter)
  5983. + {
  5984. + boolean[] val = defaultValue;
  5985. + final String value;
  5986. +
  5987. + if ((value = super.getProperty(name, null)) != null)
  5988. + {
  5989. + final String[] values = value.split(delimiter);
  5990. + val = new boolean[values.length];
  5991. + for (int i = 0; i < val.length; i++)
  5992. + val[i] = Boolean.parseBoolean(values[i]);
  5993. + }
  5994. +
  5995. + return val;
  5996. + }
  5997. +
  5998. + public int[] getProperty(final String name, final int[] defaultValue)
  5999. + {
  6000. + return getProperty(name, defaultValue, defaultDelimiter);
  6001. + }
  6002. +
  6003. + public int[] getProperty(final String name, final int[] defaultValue, final String delimiter)
  6004. + {
  6005. + int[] val = defaultValue;
  6006. + final String value;
  6007. +
  6008. + if ((value = super.getProperty(name, null)) != null)
  6009. + {
  6010. + final String[] values = value.split(delimiter);
  6011. + val = new int[values.length];
  6012. + for (int i = 0; i < val.length; i++)
  6013. + val[i] = Integer.parseInt(values[i]);
  6014. + }
  6015. +
  6016. + return val;
  6017. + }
  6018. +
  6019. + public long[] getProperty(final String name, final long[] defaultValue)
  6020. + {
  6021. + return getProperty(name, defaultValue, defaultDelimiter);
  6022. + }
  6023. +
  6024. + public long[] getProperty(final String name, final long[] defaultValue, final String delimiter)
  6025. + {
  6026. + long[] val = defaultValue;
  6027. + final String value;
  6028. +
  6029. + if ((value = super.getProperty(name, null)) != null)
  6030. + {
  6031. + final String[] values = value.split(delimiter);
  6032. + val = new long[values.length];
  6033. + for (int i = 0; i < val.length; i++)
  6034. + val[i] = Long.parseLong(values[i]);
  6035. + }
  6036. +
  6037. + return val;
  6038. + }
  6039. +
  6040. + public double[] getProperty(final String name, final double[] defaultValue)
  6041. + {
  6042. + return getProperty(name, defaultValue, defaultDelimiter);
  6043. + }
  6044. +
  6045. + public double[] getProperty(final String name, final double[] defaultValue, final String delimiter)
  6046. + {
  6047. + double[] val = defaultValue;
  6048. + final String value;
  6049. +
  6050. + if ((value = super.getProperty(name, null)) != null)
  6051. + {
  6052. + final String[] values = value.split(delimiter);
  6053. + val = new double[values.length];
  6054. + for (int i = 0; i < val.length; i++)
  6055. + val[i] = Double.parseDouble(values[i]);
  6056. + }
  6057. +
  6058. + return val;
  6059. + }
  6060. +}
  6061. \ No newline at end of file
  6062. diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
  6063. index 1631218..0be4989 100644
  6064. --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
  6065. +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
  6066. @@ -160,6 +160,9 @@
  6067. import Dev.SpecialMods.PartyZoneReward;
  6068. import Dev.SpecialMods.RaidBossInfoManager;
  6069. import Dev.SpecialMods.XMLDocumentFactory;
  6070. +import Dev.Tournament.properties.ArenaConfig;
  6071. +import Dev.Tournament.properties.ArenaEvent;
  6072. +import Dev.Tournament.properties.ArenaTask;
  6073.  
  6074. public class GameServer
  6075. {
  6076. @@ -610,6 +613,20 @@
  6077. else
  6078. LOGGER.info("All events are Disabled.");
  6079.  
  6080. + ArenaConfig.init();
  6081. + if (ArenaConfig.TOURNAMENT_EVENT_TIME)
  6082. + {
  6083. + LOGGER.info("Tournament Event is enabled.");
  6084. + ArenaEvent.getInstance().StartCalculationOfNextEventTime();
  6085. + }
  6086. + else if (ArenaConfig.TOURNAMENT_EVENT_START)
  6087. + {
  6088. + LOGGER.info("Tournament Event is enabled.");
  6089. + ArenaTask.spawnNpc1();
  6090. + ArenaTask.spawnNpc2();
  6091. + }
  6092. + else
  6093. + LOGGER.info("Tournament Event is disabled");
  6094. if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
  6095. OfflineTradeTable.restoreOfflineTraders();
  6096.  
  6097. diff --git a/head-src/com/l2jfrozen/gameserver/datatables/xml/ZoneData.java b/head-src/com/l2jfrozen/gameserver/datatables/xml/ZoneData.java
  6098. index 6b66771..6e7bc93 100644
  6099. --- a/head-src/com/l2jfrozen/gameserver/datatables/xml/ZoneData.java
  6100. +++ b/head-src/com/l2jfrozen/gameserver/datatables/xml/ZoneData.java
  6101. @@ -45,6 +45,7 @@
  6102. import com.l2jfrozen.gameserver.model.zone.form.ZoneCuboid;
  6103. import com.l2jfrozen.gameserver.model.zone.form.ZoneCylinder;
  6104. import com.l2jfrozen.gameserver.model.zone.form.ZoneNPoly;
  6105. +import com.l2jfrozen.gameserver.model.zone.type.L2ArenaEventZone;
  6106. import com.l2jfrozen.gameserver.model.zone.type.L2ArenaZone;
  6107. import com.l2jfrozen.gameserver.model.zone.type.L2BigheadZone;
  6108. import com.l2jfrozen.gameserver.model.zone.type.L2BossZone;
  6109. @@ -67,6 +68,7 @@
  6110. import com.l2jfrozen.gameserver.model.zone.type.L2PeaceZone;
  6111. import com.l2jfrozen.gameserver.model.zone.type.L2PoisonZone;
  6112. import com.l2jfrozen.gameserver.model.zone.type.L2SwampZone;
  6113. +import com.l2jfrozen.gameserver.model.zone.type.L2TournamentZone;
  6114. import com.l2jfrozen.gameserver.model.zone.type.L2TownZone;
  6115. import com.l2jfrozen.gameserver.model.zone.type.L2WaterZone;
  6116. import com.l2jfrozen.util.CloseUtil;
  6117. @@ -238,6 +240,12 @@
  6118. case "FlagZone":
  6119. temp = new L2FlagZone(zoneId);
  6120. break;
  6121. + case "ArenaEventZone":
  6122. + temp = new L2ArenaEventZone(zoneId);
  6123. + break;
  6124. + case "TournamentZone":
  6125. + temp = new L2TournamentZone(zoneId);
  6126. + break;
  6127. case "BossZone":
  6128. int boss_id = -1;
  6129.  
  6130. diff --git a/head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminCustom.java b/head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminCustom.java
  6131. index a740e7a..15b7fd1 100644
  6132. --- a/head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminCustom.java
  6133. +++ b/head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminCustom.java
  6134. @@ -7,6 +7,7 @@
  6135. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  6136.  
  6137. import Dev.Events.PartyFarm.PartyFarm;
  6138. +import Dev.Tournament.properties.ArenaTask;
  6139. //import Dev.Tournament.properties.ArenaTask;
  6140.  
  6141.  
  6142. @@ -29,7 +30,7 @@
  6143. {
  6144.  
  6145.  
  6146. - /*if (command.equals("admin_tour"))
  6147. + if (command.equals("admin_tour"))
  6148. {
  6149. if (ArenaTask._started)
  6150. {
  6151. @@ -53,7 +54,7 @@
  6152. }
  6153.  
  6154. return true;
  6155. - }*/
  6156. + }
  6157. if (command.equals("admin_ptfarm"))
  6158. {
  6159. if (PartyFarm._started)
  6160. @@ -108,7 +109,7 @@
  6161. }, 1L);
  6162. }
  6163.  
  6164. - /*
  6165. +
  6166. private static void initEventArena()
  6167. {
  6168. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  6169. @@ -133,7 +134,7 @@
  6170. ArenaTask.finishEvent();
  6171. }
  6172. }, 10L);
  6173. - }*/
  6174. + }
  6175.  
  6176.  
  6177.  
  6178. diff --git a/head-src/com/l2jfrozen/gameserver/handler/itemhandlers/SummonItems.java b/head-src/com/l2jfrozen/gameserver/handler/itemhandlers/SummonItems.java
  6179. index 0e47ef9..b6e34b3 100644
  6180. --- a/head-src/com/l2jfrozen/gameserver/handler/itemhandlers/SummonItems.java
  6181. +++ b/head-src/com/l2jfrozen/gameserver/handler/itemhandlers/SummonItems.java
  6182. @@ -27,6 +27,7 @@
  6183. import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
  6184. import com.l2jfrozen.gameserver.handler.IItemHandler;
  6185. import com.l2jfrozen.gameserver.idfactory.IdFactory;
  6186. +import com.l2jfrozen.gameserver.model.L2Character;
  6187. import com.l2jfrozen.gameserver.model.L2Skill;
  6188. import com.l2jfrozen.gameserver.model.L2SummonItem;
  6189. import com.l2jfrozen.gameserver.model.L2World;
  6190. @@ -63,7 +64,11 @@
  6191. playable.sendPacket(ActionFailed.STATIC_PACKET);
  6192. return;
  6193. }
  6194. -
  6195. + if (activeChar.isArenaProtection() && activeChar.isInsideZone(L2Character.TOURNAMENT))
  6196. + {
  6197. + activeChar.sendMessage("You can not do this in Tournament Event");
  6198. + return;
  6199. + }
  6200. // if(activeChar._inEventTvT && TvT._started && !Config.TVT_ALLOW_SUMMON)
  6201. if (activeChar._inEventTvT && TvT.is_started() && !Config.TVT_ALLOW_SUMMON)
  6202. {
  6203. diff --git a/head-src/com/l2jfrozen/gameserver/handler/skillhandlers/SummonFriend.java b/head-src/com/l2jfrozen/gameserver/handler/skillhandlers/SummonFriend.java
  6204. index aa13e95..50d415a 100644
  6205. --- a/head-src/com/l2jfrozen/gameserver/handler/skillhandlers/SummonFriend.java
  6206. +++ b/head-src/com/l2jfrozen/gameserver/handler/skillhandlers/SummonFriend.java
  6207. @@ -64,7 +64,11 @@
  6208. activePlayer.sendPacket(new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
  6209. return;
  6210. }
  6211. -
  6212. + if (activeChar.isArenaProtection() && activeChar.isInsideZone(L2Character.TOURNAMENT))
  6213. + {
  6214. + activePlayer.sendMessage("You cannot use this skill in Tournament Event.");
  6215. + return;
  6216. + }
  6217. if (activePlayer._inEvent)
  6218. {
  6219. activePlayer.sendMessage("You cannot use this skill in Event.");
  6220. diff --git a/head-src/com/l2jfrozen/gameserver/handler/usercommandhandlers/Escape.java b/head-src/com/l2jfrozen/gameserver/handler/usercommandhandlers/Escape.java
  6221. index f13d56e..2698fd8 100644
  6222. --- a/head-src/com/l2jfrozen/gameserver/handler/usercommandhandlers/Escape.java
  6223. +++ b/head-src/com/l2jfrozen/gameserver/handler/usercommandhandlers/Escape.java
  6224. @@ -26,6 +26,7 @@
  6225. import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable;
  6226. import com.l2jfrozen.gameserver.handler.IUserCommandHandler;
  6227. import com.l2jfrozen.gameserver.managers.GrandBossManager;
  6228. +import com.l2jfrozen.gameserver.model.L2Character;
  6229. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  6230. import com.l2jfrozen.gameserver.model.entity.event.CTF;
  6231. import com.l2jfrozen.gameserver.model.entity.event.DM;
  6232. @@ -65,7 +66,11 @@
  6233. activeChar.sendMessage("You may not use an escape command in a festival.");
  6234. return false;
  6235. }
  6236. -
  6237. + if (activeChar.isArenaProtection() && activeChar.isInsideZone(L2Character.TOURNAMENT))
  6238. + {
  6239. + activeChar.sendMessage("You cannot use this skill in Tournament Event/Zone.");
  6240. + return false;
  6241. + }
  6242. // Check to see if the current player is in TVT Event.
  6243. if (activeChar._inEventTvT && TvT.is_started())
  6244. {
  6245. diff --git a/head-src/com/l2jfrozen/gameserver/model/L2Character.java b/head-src/com/l2jfrozen/gameserver/model/L2Character.java
  6246. index 13a0f45..3bc645a 100644
  6247. --- a/head-src/com/l2jfrozen/gameserver/model/L2Character.java
  6248. +++ b/head-src/com/l2jfrozen/gameserver/model/L2Character.java
  6249. @@ -142,6 +142,8 @@
  6250. import com.l2jfrozen.util.Point3D;
  6251. import com.l2jfrozen.util.random.Rnd;
  6252.  
  6253. +import Dev.Tournament.properties.ArenaConfig;
  6254. +
  6255. /**
  6256. * Mother class of all character objects of the world (PC, NPC...)<BR>
  6257. * <BR>
  6258. @@ -310,7 +312,8 @@
  6259. * x^2 or x*x.
  6260. */
  6261. public static final int ZONE_PVP = 1;
  6262. -
  6263. + public static final int ARENA_EVENT = 21;
  6264. + public static final int TOURNAMENT = 22;
  6265. /** The Constant ZONE_PEACE. */
  6266. public static final int ZONE_PEACE = 2;
  6267.  
  6268. @@ -2259,7 +2262,7 @@
  6269. if (Config.CTF_REMOVE_BUFFS_ON_DIE)
  6270. stopAllEffects();
  6271. }
  6272. - else if (Config.LEAVE_BUFFS_ON_DIE) // this means that the player is not in event
  6273. + else if (Config.LEAVE_BUFFS_ON_DIE || (isArenaAttack() && (isArena9x9() || (isArena5x5() && ArenaConfig.ALLOW_5X5_LOSTBUFF)))) // this means that the player is not in event
  6274. {
  6275. stopAllEffects();
  6276. }
  6277. @@ -2809,7 +2812,7 @@
  6278. */
  6279. public boolean isMovementDisabled()
  6280. {
  6281. - return isImmobileUntilAttacked() || isStunned() || isRooted() || isSleeping() || isOverloaded() || isParalyzed() || isImobilised() || isFakeDeath() || isFallsdown();
  6282. + return isImmobileUntilAttacked() || isStunned() || isRooted() || isStopArena() || isSleeping() || isOverloaded() || isParalyzed() || isImobilised() || isFakeDeath() || isFallsdown();
  6283. }
  6284.  
  6285. /**
  6286. @@ -10973,6 +10976,173 @@
  6287. {
  6288. _isAttackDisabled = value;
  6289. }
  6290. + //--------------
  6291. + // Tournament
  6292. + //--------------
  6293. +
  6294. + private boolean _ArenaProtection;
  6295. +
  6296. + public void setArenaProtection(boolean comm)
  6297. + {
  6298. + _ArenaProtection = comm;
  6299. + }
  6300. +
  6301. + public boolean isArenaProtection()
  6302. + {
  6303. + return _ArenaProtection;
  6304. + }
  6305. +
  6306. + private boolean inArenaEvent = false;
  6307. +
  6308. + public void setInArenaEvent(boolean val)
  6309. + {
  6310. + inArenaEvent = val;
  6311. + }
  6312. +
  6313. + public boolean isInArenaEvent()
  6314. + {
  6315. + return inArenaEvent;
  6316. + }
  6317. +
  6318. + private boolean _ArenaAttack;
  6319. +
  6320. + public void setArenaAttack(boolean comm)
  6321. + {
  6322. + _ArenaAttack = comm;
  6323. + }
  6324. +
  6325. + public boolean isArenaAttack()
  6326. + {
  6327. + return _ArenaAttack;
  6328. + }
  6329. +
  6330. + private boolean _Arena1x1;
  6331. +
  6332. + public void setArena1x1(boolean comm)
  6333. + {
  6334. + _Arena1x1 = comm;
  6335. + }
  6336. +
  6337. + public boolean isArena1x1()
  6338. + {
  6339. + return _Arena1x1;
  6340. + }
  6341. +
  6342. + private boolean _Arena3x3;
  6343. +
  6344. + public void setArena3x3(boolean comm)
  6345. + {
  6346. + _Arena3x3 = comm;
  6347. + }
  6348. +
  6349. + public boolean isArena3x3()
  6350. + {
  6351. + return _Arena3x3;
  6352. + }
  6353. +
  6354. + private boolean _Arena5x5;
  6355. +
  6356. + public void setArena5x5(boolean comm)
  6357. + {
  6358. + _Arena5x5 = comm;
  6359. + }
  6360. +
  6361. + public boolean isArena5x5()
  6362. + {
  6363. + return _Arena5x5;
  6364. + }
  6365. +
  6366. + private boolean _Arena9x9;
  6367. +
  6368. + public void setArena9x9(boolean comm)
  6369. + {
  6370. + _Arena9x9 = comm;
  6371. + }
  6372. +
  6373. + public boolean isArena9x9()
  6374. + {
  6375. + return _Arena9x9;
  6376. + }
  6377. + private boolean _ArenaObserv;
  6378. +
  6379. + public void setArenaObserv(boolean comm)
  6380. + {
  6381. + _ArenaObserv = comm;
  6382. + }
  6383. +
  6384. + public boolean isArenaObserv()
  6385. + {
  6386. + return _ArenaObserv;
  6387. + }
  6388. + private boolean _isStopMov = false;
  6389. + public boolean isStopArena()
  6390. + {
  6391. + return _isStopMov;
  6392. + }
  6393. + //---------
  6394. +
  6395. + public int _originalTitleColorTournament = 0;
  6396. + public String _originalTitleTournament;
  6397. +
  6398. + private boolean _TournamentTeleport;
  6399. +
  6400. + public void setTournamentTeleport(boolean comm)
  6401. + {
  6402. + _TournamentTeleport = comm;
  6403. + }
  6404. +
  6405. + public boolean isTournamentTeleport()
  6406. + {
  6407. + return _TournamentTeleport;
  6408. + }
  6409. +
  6410. + public int duelist_cont = 0,
  6411. + dreadnought_cont = 0,
  6412. + tanker_cont = 0,
  6413. + dagger_cont = 0,
  6414. + archer_cont = 0,
  6415. + bs_cont = 0,
  6416. + archmage_cont = 0,
  6417. + soultaker_cont = 0,
  6418. + mysticMuse_cont = 0,
  6419. + stormScreamer_cont = 0,
  6420. + titan_cont = 0,
  6421. + dominator_cont = 0,
  6422. + grandKhauatari_cont = 0,
  6423. + doomcryer_cont = 0;
  6424. +
  6425. + public int duelist_cont_tournament = 0,
  6426. + dreadnought_cont_tournament = 0,
  6427. + tanker_cont_tournament = 0,
  6428. + dagger_cont_tournament = 0,
  6429. + archer_cont_tournament = 0,
  6430. + bs_cont_tournament = 0,
  6431. + archmage_cont_tournament = 0,
  6432. + soultaker_cont_tournament = 0,
  6433. + mysticMuse_cont_tournament = 0,
  6434. + stormScreamer_cont_tournament = 0,
  6435. + titan_cont_tournament = 0,
  6436. + dominator_cont_tournament = 0;
  6437. +
  6438. +
  6439. + private boolean _OlympiadProtection;
  6440. +
  6441. + public int _player_n = 1;
  6442. +
  6443. + public void setOlympiadProtection(boolean comm)
  6444. + {
  6445. + _OlympiadProtection = comm;
  6446. + }
  6447. +
  6448. + public boolean isOlympiadProtection()
  6449. + {
  6450. + return _OlympiadProtection;
  6451. + }
  6452. +
  6453. + public void setStopArena(boolean value)
  6454. + {
  6455. + _isStopMov = value;
  6456. + }
  6457. /**
  6458. * <B><U> Overridden in </U> :</B><BR>
  6459. * <BR>
  6460. diff --git a/head-src/com/l2jfrozen/gameserver/model/L2Skill.java b/head-src/com/l2jfrozen/gameserver/model/L2Skill.java
  6461. index cf89e89..36f7db9 100644
  6462. --- a/head-src/com/l2jfrozen/gameserver/model/L2Skill.java
  6463. +++ b/head-src/com/l2jfrozen/gameserver/model/L2Skill.java
  6464. @@ -1576,7 +1576,7 @@
  6465. }
  6466.  
  6467. // Check for null target or any other invalid target
  6468. - if (target == null || target.isDead() || target == activeChar && !canTargetSelf)
  6469. + if (target == null || target.isDead() || (target == activeChar && !canTargetSelf) || ((activeChar instanceof L2PcInstance) && !activeChar.isInArenaEvent() && target.isInArenaEvent()))
  6470. {
  6471.  
  6472. return null;
  6473. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  6474. index 3756755..7498ee2 100644
  6475. --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  6476. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  6477. @@ -248,6 +248,7 @@
  6478. import com.l2jfrozen.util.random.Rnd;
  6479.  
  6480. import Dev.SpecialMods.DressMeData;
  6481. +import Dev.Tournament.properties.ArenaConfig;
  6482.  
  6483. /**
  6484. * This class represents all player characters in the world.<br>
  6485. @@ -684,7 +685,29 @@
  6486. sendPacket(ActionFailed.STATIC_PACKET);
  6487. return;
  6488. }
  6489. + if (isArenaProtection() && ((isArena5x5() && ArenaConfig.bs_COUNT_5X5 == 0) || isArena3x3()) && (skill.getSkillType() == SkillType.RESURRECT))
  6490. + {
  6491. + sendPacket(ActionFailed.STATIC_PACKET);
  6492. + return;
  6493. + }
  6494.  
  6495. + if (isArenaProtection() && !isArena5x5() && !isArena9x9() && ArenaConfig.ARENA_SKILL_LIST.contains(skill.getId()))
  6496. + {
  6497. + sendPacket(ActionFailed.STATIC_PACKET);
  6498. + return;
  6499. + }
  6500. +
  6501. + if (isArenaProtection() && ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(skill.getId()))
  6502. + {
  6503. + sendMessage("[Tournament]: Skill disabled in tournament.");
  6504. + return;
  6505. + }
  6506. +
  6507. + if (isInArenaEvent() && !isArenaAttack() && ArenaConfig.ARENA_DISABLE_SKILL_LIST.contains(skill.getId()))
  6508. + {
  6509. + sendMessage("[Tournament]: Wait for the battle to begin");
  6510. + return;
  6511. + }
  6512. super.doCast(skill);
  6513.  
  6514. if (!skill.isOffensive())
  6515. @@ -11858,7 +11881,25 @@
  6516. return false;
  6517. }
  6518. }
  6519. -
  6520. + if (attacker.isInArenaEvent())
  6521. + {
  6522. + L2PcInstance player = null;
  6523. + if (attacker instanceof L2PcInstance)
  6524. + {
  6525. + player = (L2PcInstance) attacker;
  6526. + }
  6527. + else if (attacker instanceof L2Summon)
  6528. + {
  6529. + player = ((L2Summon) attacker).getOwner();
  6530. + }
  6531. + if (player != null)
  6532. + {
  6533. + if (isArenaAttack() && player.isArenaAttack())
  6534. + return true;
  6535. +
  6536. + return false;
  6537. + }
  6538. + }
  6539. if (L2Character.isInsidePeaceZone(attacker, this))
  6540. {
  6541. return false;
  6542. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2TeleporterInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2TeleporterInstance.java
  6543. index 52a05c4..298cba6 100644
  6544. --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2TeleporterInstance.java
  6545. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2TeleporterInstance.java
  6546. @@ -37,6 +37,8 @@
  6547. import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  6548. import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  6549.  
  6550. +import Dev.Tournament.properties.ArenaTask;
  6551. +
  6552. /**
  6553. * The Class L2TeleporterInstance.
  6554. * @author NightMarez
  6555. @@ -82,7 +84,14 @@
  6556. player.sendMessage("You are not allowed to use a teleport while registered in olympiad game.");
  6557. return;
  6558. }
  6559. -
  6560. + if (player.isArenaProtection())
  6561. + {
  6562. + if (!ArenaTask.is_started())
  6563. + player.setArenaProtection(false);
  6564. + else
  6565. + player.sendMessage("Remove your participation from the Tournament event!");
  6566. + return;
  6567. + }
  6568. if (player.isAio() && !Config.ALLOW_AIO_USE_GK)
  6569. {
  6570. player.sendMessage("Aio Buffers Can't Use Teleports");
  6571. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2TournamentInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2TournamentInstance.java
  6572. new file mode 100644
  6573. index 0000000..60ba666
  6574. --- /dev/null
  6575. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2TournamentInstance.java
  6576. @@ -0,0 +1,1250 @@
  6577. +/*
  6578. + * Copyright (C) 2004-2013 L2J Server
  6579. + *
  6580. + * This file is part of L2J Server.
  6581. + *
  6582. + * L2J Server is free software: you can redistribute it and/or modify
  6583. + * it under the terms of the GNU General Public License as published by
  6584. + * the Free Software Foundation, either version 3 of the License, or
  6585. + * (at your option) any later version.
  6586. + *
  6587. + * L2J Server is distributed in the hope that it will be useful,
  6588. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6589. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6590. + * General Public License for more details.
  6591. + *
  6592. + * You should have received a copy of the GNU General Public License
  6593. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  6594. + */
  6595. +package com.l2jfrozen.gameserver.model.actor.instance;
  6596. +
  6597. +import com.l2jfrozen.gameserver.ai.CtrlIntention;
  6598. +import com.l2jfrozen.gameserver.model.L2Effect;
  6599. +import com.l2jfrozen.gameserver.model.L2Party;
  6600. +import com.l2jfrozen.gameserver.model.L2World;
  6601. +import com.l2jfrozen.gameserver.model.base.ClassId;
  6602. +import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  6603. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  6604. +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
  6605. +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  6606. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  6607. +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  6608. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  6609. +
  6610. +import java.util.List;
  6611. +
  6612. +
  6613. +import Dev.Tournament.Arena1x1;
  6614. +import Dev.Tournament.Arena3x3;
  6615. +import Dev.Tournament.Arena5x5;
  6616. +import Dev.Tournament.Arena9x9;
  6617. +import Dev.Tournament.properties.ArenaConfig;
  6618. +
  6619. +public class L2TournamentInstance extends L2FolkInstance
  6620. +{
  6621. + public L2TournamentInstance(int objectId, L2NpcTemplate template)
  6622. + {
  6623. + super(objectId, template);
  6624. + }
  6625. + @Override
  6626. + public void onAction(L2PcInstance player)
  6627. + {
  6628. + if (!canTarget(player))
  6629. + return;
  6630. +
  6631. + player.setLastFolkNPC(this);
  6632. +
  6633. + // Check if the L2PcInstance already target the L2NpcInstance
  6634. + if (this != player.getTarget())
  6635. + {
  6636. + // Set the target of the L2PcInstance player
  6637. + player.setTarget(this);
  6638. +
  6639. + // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
  6640. + MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
  6641. + player.sendPacket(my);
  6642. + my = null;
  6643. +
  6644. + // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
  6645. + player.sendPacket(new ValidateLocation(this));
  6646. + }
  6647. + else
  6648. + {
  6649. + // Calculate the distance between the L2PcInstance and the L2NpcInstance
  6650. + if (!canInteract(player))
  6651. + {
  6652. + // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
  6653. + player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  6654. + }
  6655. + else
  6656. + {
  6657. + showMessageWindow(player);
  6658. + }
  6659. + }
  6660. + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  6661. + player.sendPacket(ActionFailed.STATIC_PACKET);
  6662. + }
  6663. +
  6664. + public void showMessageWindow(L2PcInstance player)
  6665. + {
  6666. + //player.sendPacket(ActionFailed.STATIC_PACKET);
  6667. + String filename = "data/html/mods/tournament/index.htm";
  6668. + NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  6669. + html.setFile(filename);
  6670. + html.replace("%objectId%", getObjectId());
  6671. +
  6672. + if (Arena1x1.registered.size() == 0)
  6673. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_0_over\" fore=\"L2UI_CH3.calculate1_0\">");
  6674. + else if (Arena1x1.registered.size() == 1)
  6675. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_1_over\" fore=\"L2UI_CH3.calculate1_1\">");
  6676. + else if (Arena1x1.registered.size() == 2)
  6677. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_2_over\" fore=\"L2UI_CH3.calculate1_2\">");
  6678. + else if (Arena1x1.registered.size() == 3)
  6679. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_3_over\" fore=\"L2UI_CH3.calculate1_3\">");
  6680. + else if (Arena1x1.registered.size() == 4)
  6681. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_4_over\" fore=\"L2UI_CH3.calculate1_4\">");
  6682. + else if (Arena1x1.registered.size() == 5)
  6683. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_5_over\" fore=\"L2UI_CH3.calculate1_5\">");
  6684. + else if (Arena1x1.registered.size() == 6)
  6685. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_6_over\" fore=\"L2UI_CH3.calculate1_6\">");
  6686. + else if (Arena1x1.registered.size() == 7)
  6687. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_7_over\" fore=\"L2UI_CH3.calculate1_7\">");
  6688. + else if (Arena1x1.registered.size() == 8)
  6689. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_8_over\" fore=\"L2UI_CH3.calculate1_8\">");
  6690. + else if (Arena1x1.registered.size() >= 9)
  6691. + html.replace("%1x1%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_9_over\" fore=\"L2UI_CH3.calculate1_9\">");
  6692. +
  6693. + if (Arena3x3.registered.size() == 0)
  6694. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_0_over\" fore=\"L2UI_CH3.calculate1_0\">");
  6695. + else if (Arena3x3.registered.size() == 1)
  6696. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_1_over\" fore=\"L2UI_CH3.calculate1_1\">");
  6697. + else if (Arena3x3.registered.size() == 2)
  6698. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_2_over\" fore=\"L2UI_CH3.calculate1_2\">");
  6699. + else if (Arena3x3.registered.size() == 3)
  6700. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_3_over\" fore=\"L2UI_CH3.calculate1_3\">");
  6701. + else if (Arena3x3.registered.size() == 4)
  6702. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_4_over\" fore=\"L2UI_CH3.calculate1_4\">");
  6703. + else if (Arena3x3.registered.size() == 5)
  6704. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_5_over\" fore=\"L2UI_CH3.calculate1_5\">");
  6705. + else if (Arena3x3.registered.size() == 6)
  6706. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_6_over\" fore=\"L2UI_CH3.calculate1_6\">");
  6707. + else if (Arena3x3.registered.size() == 7)
  6708. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_7_over\" fore=\"L2UI_CH3.calculate1_7\">");
  6709. + else if (Arena3x3.registered.size() == 8)
  6710. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_8_over\" fore=\"L2UI_CH3.calculate1_8\">");
  6711. + else if (Arena3x3.registered.size() >= 9)
  6712. + html.replace("%3x3%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_9_over\" fore=\"L2UI_CH3.calculate1_9\">");
  6713. +
  6714. + if (Arena5x5.registered.size() == 0)
  6715. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_0_over\" fore=\"L2UI_CH3.calculate1_0\">");
  6716. + else if (Arena5x5.registered.size() == 1)
  6717. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_1_over\" fore=\"L2UI_CH3.calculate1_1\">");
  6718. + else if (Arena5x5.registered.size() == 2)
  6719. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_2_over\" fore=\"L2UI_CH3.calculate1_2\">");
  6720. + else if (Arena5x5.registered.size() == 3)
  6721. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_3_over\" fore=\"L2UI_CH3.calculate1_3\">");
  6722. + else if (Arena5x5.registered.size() == 4)
  6723. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_4_over\" fore=\"L2UI_CH3.calculate1_4\">");
  6724. + else if (Arena5x5.registered.size() == 5)
  6725. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_5_over\" fore=\"L2UI_CH3.calculate1_5\">");
  6726. + else if (Arena5x5.registered.size() == 6)
  6727. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_6_over\" fore=\"L2UI_CH3.calculate1_6\">");
  6728. + else if (Arena5x5.registered.size() == 7)
  6729. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_7_over\" fore=\"L2UI_CH3.calculate1_7\">");
  6730. + else if (Arena5x5.registered.size() == 8)
  6731. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_8_over\" fore=\"L2UI_CH3.calculate1_8\">");
  6732. + else if (Arena5x5.registered.size() >= 9)
  6733. + html.replace("%5x5%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_9_over\" fore=\"L2UI_CH3.calculate1_9\">");
  6734. +
  6735. + if (Arena9x9.registered.size() == 0)
  6736. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_0_over\" fore=\"L2UI_CH3.calculate1_0\">");
  6737. + else if (Arena9x9.registered.size() == 1)
  6738. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_1_over\" fore=\"L2UI_CH3.calculate1_1\">");
  6739. + else if (Arena9x9.registered.size() == 2)
  6740. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_2_over\" fore=\"L2UI_CH3.calculate1_2\">");
  6741. + else if (Arena9x9.registered.size() == 3)
  6742. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_3_over\" fore=\"L2UI_CH3.calculate1_3\">");
  6743. + else if (Arena9x9.registered.size() == 4)
  6744. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_4_over\" fore=\"L2UI_CH3.calculate1_4\">");
  6745. + else if (Arena9x9.registered.size() == 5)
  6746. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_5_over\" fore=\"L2UI_CH3.calculate1_5\">");
  6747. + else if (Arena9x9.registered.size() == 6)
  6748. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_6_over\" fore=\"L2UI_CH3.calculate1_6\">");
  6749. + else if (Arena9x9.registered.size() == 7)
  6750. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_7_over\" fore=\"L2UI_CH3.calculate1_7\">");
  6751. + else if (Arena9x9.registered.size() == 8)
  6752. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_8_over\" fore=\"L2UI_CH3.calculate1_8\">");
  6753. + else if (Arena9x9.registered.size() >= 9)
  6754. + html.replace("%9x9%", "<button value=\"\" action=\"\" width=32 height=32 back=\"L2UI_CH3.calculate1_9_over\" fore=\"L2UI_CH3.calculate1_9\">");
  6755. +
  6756. + player.sendPacket(html);
  6757. + }
  6758. +
  6759. + @Override
  6760. + public void onBypassFeedback(L2PcInstance player, String command)
  6761. + {
  6762. + if (command.startsWith("1x1"))
  6763. + {
  6764. + if (!ArenaConfig.ALLOW_1X1_REGISTER)
  6765. + {
  6766. + player.sendMessage("Tournament 1x1 is not enabled.");
  6767. + return;
  6768. + }
  6769. +
  6770. + if (player.isArena3x3() || player.isArena5x5() || player.isArena9x9() || player.isArenaProtection())
  6771. + {
  6772. + player.sendMessage("You are already registered in another tournament event.");
  6773. + return;
  6774. + }
  6775. +
  6776. + if (player._active_boxes > 1 && !ArenaConfig.Allow_Same_HWID_On_Tournament)
  6777. + {
  6778. + final List<String> players_in_boxes = player.active_boxes_characters;
  6779. +
  6780. + if (players_in_boxes != null && players_in_boxes.size() > 1)
  6781. + {
  6782. + for (final String character_name : players_in_boxes)
  6783. + {
  6784. + final L2PcInstance ppl = L2World.getInstance().getPlayer(character_name);
  6785. +
  6786. + if (ppl != null && ppl.isArenaProtection())
  6787. + {
  6788. + player.sendMessage("You are already participating in Tournament with another char!");
  6789. + return;
  6790. + }
  6791. + }
  6792. + }
  6793. + }
  6794. +
  6795. + if (ArenaConfig.CHECK_NOBLESS)
  6796. + {
  6797. + if (!player.isNoble())
  6798. + {
  6799. + player.sendMessage("You does not have the necessary requirements.");
  6800. + return;
  6801. + }
  6802. + }
  6803. +
  6804. + if (player.isCursedWeaponEquipped() || player.inObserverMode() || player.isInStoreMode() || player.isAio() || player.getKarma() > 0)
  6805. + {
  6806. + player.sendMessage("You does not have the necessary requirements.");
  6807. + return;
  6808. + }
  6809. +
  6810. + if (player._inEventTvT || player._inEventCTF)
  6811. + {
  6812. + player.sendMessage("Tournament: You already participated in another event!");
  6813. + return;
  6814. + }
  6815. +
  6816. + if (Olympiad.getInstance().isRegistered(player))
  6817. + {
  6818. + player.sendMessage("You is registered in the Olympiad.");
  6819. + return;
  6820. + }
  6821. +
  6822. + if (player.getClassId() == ClassId.shillenElder || player.getClassId() == ClassId.shillienSaint || player.getClassId() == ClassId.bishop || player.getClassId() == ClassId.cardinal || player.getClassId() == ClassId.elder || player.getClassId() == ClassId.evaSaint)
  6823. + {
  6824. + player.sendMessage("Yor class is not allowed in 1x1 game event.");
  6825. + return;
  6826. + }
  6827. +
  6828. + if (Arena1x1.getInstance().register(player))
  6829. + {
  6830. + player.setArena1x1(true);
  6831. + player.setArenaProtection(true);
  6832. + }
  6833. + }
  6834. +
  6835. + if (command.startsWith("3x3"))
  6836. + {
  6837. + if (!ArenaConfig.ALLOW_3X3_REGISTER)
  6838. + {
  6839. + player.sendMessage("Tournament 3x3 is not enabled.");
  6840. + return;
  6841. + }
  6842. +
  6843. + if (player.isArena3x3() || player.isArena5x5() || player.isArena9x9() || player.isArenaProtection())
  6844. + {
  6845. + player.sendMessage("Tournament: You already registered!");
  6846. + return;
  6847. + }
  6848. +
  6849. + if (player._active_boxes > 1 && !ArenaConfig.Allow_Same_HWID_On_Tournament)
  6850. + {
  6851. + final List<String> players_in_boxes = player.active_boxes_characters;
  6852. +
  6853. + if (players_in_boxes != null && players_in_boxes.size() > 1)
  6854. + {
  6855. + for (final String character_name : players_in_boxes)
  6856. + {
  6857. + final L2PcInstance ppl = L2World.getInstance().getPlayer(character_name);
  6858. +
  6859. + if (ppl != null && ppl.isArenaProtection())
  6860. + {
  6861. + player.sendMessage("You are already participating in Tournament with another char!");
  6862. + return;
  6863. + }
  6864. + }
  6865. + }
  6866. + }
  6867. +
  6868. + if (!player.isInParty())
  6869. + {
  6870. + player.sendMessage("Tournament: You dont have a party.");
  6871. + return;
  6872. + }
  6873. +
  6874. + if (!player.getParty().isLeader(player))
  6875. + {
  6876. + player.sendMessage("Tournament: You are not the party leader!");
  6877. + return;
  6878. + }
  6879. +
  6880. + if (player.getParty().getMemberCount() < 3)
  6881. + {
  6882. + player.sendMessage("Tournament: Your party does not have 3 members.");
  6883. + player.sendPacket(new ExShowScreenMessage("Your party does not have 3 members", 6 * 1000));
  6884. + return;
  6885. + }
  6886. +
  6887. + if (player.getParty().getMemberCount() > 3)
  6888. + {
  6889. + player.sendMessage("Tournament: Your Party can not have more than 3 members.");
  6890. + player.sendPacket(new ExShowScreenMessage("Your Party can not have more than 3 members", 6 * 1000));
  6891. + return;
  6892. + }
  6893. +
  6894. + L2PcInstance assist1 = player.getParty().getPartyMembers().get(1);
  6895. + L2PcInstance assist2 = player.getParty().getPartyMembers().get(2);
  6896. +
  6897. + if (player.isCursedWeaponEquipped() || assist1.isCursedWeaponEquipped() || assist2.isCursedWeaponEquipped() || player.isInStoreMode() || assist1.isInStoreMode() || assist2.isInStoreMode() || player.getKarma() > 0 || assist1.getKarma() > 0 || assist2.getKarma() > 0)
  6898. + {
  6899. + player.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  6900. + assist1.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  6901. + assist2.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  6902. + return;
  6903. + }
  6904. +
  6905. + if (Olympiad.getInstance().isRegistered(player) || Olympiad.getInstance().isRegistered(assist1) || Olympiad.getInstance().isRegistered(assist2))
  6906. + {
  6907. + player.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  6908. + assist1.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  6909. + assist2.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  6910. + return;
  6911. + }
  6912. +
  6913. + if (player._inEventTvT || assist1._inEventTvT || assist2._inEventTvT || player._inEventCTF || assist1._inEventCTF || assist2._inEventCTF)
  6914. + {
  6915. + player.sendMessage("Tournament: You already participated in TvT event!");
  6916. + assist1.sendMessage("Tournament: You already participated in TvT event!");
  6917. + assist2.sendMessage("Tournament: You already participated in TvT event!");
  6918. + return;
  6919. + }
  6920. +
  6921. + if (!ArenaConfig.Allow_Same_HWID_On_Tournament)
  6922. + {
  6923. + //String ip1 = player.getHWID();
  6924. + //String ip2 = assist1.getHWID();
  6925. + //String ip3 = assist2.getHWID();
  6926. + String ip1 = player.getClient().getConnection().getInetAddress().getHostAddress();
  6927. + String ip2 = assist1.getClient().getConnection().getInetAddress().getHostAddress();
  6928. + String ip3 = assist2.getClient().getConnection().getInetAddress().getHostAddress();
  6929. +
  6930. +
  6931. + if (ip1.equals(ip2) || ip1.equals(ip3))
  6932. + {
  6933. + player.sendMessage("Tournament: Register only 1 player per Computer");
  6934. + assist1.sendMessage("Tournament: Register only 1 player per Computer");
  6935. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  6936. + return;
  6937. + }
  6938. + else if (ip2.equals(ip1) || ip2.equals(ip3))
  6939. + {
  6940. + player.sendMessage("Tournament: Register only 1 player per Computer");
  6941. + assist1.sendMessage("Tournament: Register only 1 player per Computer");
  6942. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  6943. + return;
  6944. + }
  6945. + else if (ip3.equals(ip1) || ip3.equals(ip2))
  6946. + {
  6947. + player.sendMessage("Tournament: Register only 1 player per Computer");
  6948. + assist1.sendMessage("Tournament: Register only 1 player per Computer");
  6949. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  6950. + return;
  6951. + }
  6952. + }
  6953. +
  6954. + if (ArenaConfig.ARENA_SKILL_PROTECT)
  6955. + {
  6956. + for (L2Effect effect : player.getAllEffects())
  6957. + {
  6958. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  6959. + player.stopSkillEffects(effect.getSkill().getId());
  6960. + }
  6961. +
  6962. + for (L2Effect effect : assist1.getAllEffects())
  6963. + {
  6964. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  6965. + assist1.stopSkillEffects(effect.getSkill().getId());
  6966. + }
  6967. +
  6968. + for (L2Effect effect : assist2.getAllEffects())
  6969. + {
  6970. + if (ArenaConfig.ARENA_STOP_SKILL_LIST.contains(effect.getSkill().getId()))
  6971. + assist2.stopSkillEffects(effect.getSkill().getId());
  6972. + }
  6973. +
  6974. + for (L2Effect effect : player.getAllEffects())
  6975. + {
  6976. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  6977. + player.stopSkillEffects(effect.getSkill().getId());
  6978. + }
  6979. +
  6980. + for (L2Effect effect : assist1.getAllEffects())
  6981. + {
  6982. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  6983. + assist1.stopSkillEffects(effect.getSkill().getId());
  6984. + }
  6985. +
  6986. + for (L2Effect effect : assist2.getAllEffects())
  6987. + {
  6988. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  6989. + assist2.stopSkillEffects(effect.getSkill().getId());
  6990. + }
  6991. + }
  6992. +
  6993. + if (Arena3x3.getInstance().register(player, assist1, assist2))
  6994. + {
  6995. + player.sendMessage("Tournament: Your participation has been approved.");
  6996. + assist1.sendMessage("Tournament: Your participation has been approved.");
  6997. + assist2.sendMessage("Tournament: Your participation has been approved.");
  6998. + player.setArenaProtection(true);
  6999. + assist1.setArenaProtection(true);
  7000. + assist2.setArenaProtection(true);
  7001. + player.setArena3x3(true);
  7002. + assist1.setArena3x3(true);
  7003. + assist2.setArena3x3(true);
  7004. + showChatWindow(player);
  7005. + }
  7006. + else
  7007. + player.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7008. + }
  7009. +
  7010. + if (command.startsWith("5x5"))
  7011. + {
  7012. + if (!ArenaConfig.ALLOW_5X5_REGISTER)
  7013. + {
  7014. + player.sendMessage("Tournament 5x5 is not enabled.");
  7015. + return;
  7016. + }
  7017. +
  7018. + if (player.isArena3x3() || player.isArena5x5() || player.isArena9x9() || player.isArenaProtection())
  7019. + {
  7020. + player.sendMessage("Tournament: You already registered!");
  7021. + return;
  7022. + }
  7023. +
  7024. + if (player._active_boxes > 1 && !ArenaConfig.Allow_Same_HWID_On_Tournament)
  7025. + {
  7026. + final List<String> players_in_boxes = player.active_boxes_characters;
  7027. +
  7028. + if (players_in_boxes != null && players_in_boxes.size() > 1)
  7029. + {
  7030. + for (final String character_name : players_in_boxes)
  7031. + {
  7032. + final L2PcInstance ppl = L2World.getInstance().getPlayer(character_name);
  7033. +
  7034. + if (ppl != null && ppl.isArenaProtection())
  7035. + {
  7036. + player.sendMessage("You are already participating in Tournament with another char!");
  7037. + return;
  7038. + }
  7039. + }
  7040. + }
  7041. + }
  7042. +
  7043. + if (!player.isInParty())
  7044. + {
  7045. + player.sendMessage("Tournament: You dont have a party.");
  7046. + return;
  7047. + }
  7048. +
  7049. + if (!player.getParty().isLeader(player))
  7050. + {
  7051. + player.sendMessage("Tournament: You are not the party leader!");
  7052. + return;
  7053. + }
  7054. +
  7055. + if (player.getParty().getMemberCount() < 5)
  7056. + {
  7057. + player.sendMessage("Tournament: Your party does not have 4 members.");
  7058. + player.sendPacket(new ExShowScreenMessage("Your party does not have 4 members", 6 * 1000));
  7059. + return;
  7060. + }
  7061. +
  7062. + if (player.getParty().getMemberCount() > 5)
  7063. + {
  7064. + player.sendMessage("Tournament: Your Party can not have more than 4 members.");
  7065. + player.sendPacket(new ExShowScreenMessage("Your Party can not have more than 4 members", 6 * 1000));
  7066. + return;
  7067. + }
  7068. +
  7069. + L2PcInstance assist1 = player.getParty().getPartyMembers().get(1);
  7070. + L2PcInstance assist2 = player.getParty().getPartyMembers().get(2);
  7071. + L2PcInstance assist3 = player.getParty().getPartyMembers().get(3);
  7072. + L2PcInstance assist4 = player.getParty().getPartyMembers().get(4);
  7073. +
  7074. + if (player.isCursedWeaponEquipped() || assist1.isCursedWeaponEquipped() || assist2.isCursedWeaponEquipped() || assist3.isCursedWeaponEquipped() || assist4.isCursedWeaponEquipped() || player.isInStoreMode() || assist1.isInStoreMode() || assist2.isInStoreMode() || assist3.isInStoreMode() || assist4.isInStoreMode() || player.getKarma() > 0 || assist1.getKarma() > 0 || assist2.getKarma() > 0 || assist3.getKarma() > 0 || assist4.getKarma() > 0)
  7075. + {
  7076. + player.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7077. + assist1.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7078. + assist2.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7079. + assist3.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7080. + assist4.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7081. + return;
  7082. + }
  7083. +
  7084. + if (Olympiad.getInstance().isRegistered(player) || Olympiad.getInstance().isRegistered(assist1) || Olympiad.getInstance().isRegistered(assist2) || Olympiad.getInstance().isRegistered(assist3) || Olympiad.getInstance().isRegistered(assist4))
  7085. + {
  7086. + player.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7087. + assist1.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7088. + assist2.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7089. + assist3.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7090. + assist4.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7091. + return;
  7092. + }
  7093. +
  7094. + if (player._inEventTvT || assist1._inEventTvT || assist2._inEventTvT || assist3._inEventTvT || assist4._inEventTvT || player._inEventCTF || assist1._inEventCTF || assist2._inEventCTF || assist3._inEventCTF || assist4._inEventCTF)
  7095. + {
  7096. + player.sendMessage("Tournament: You already participated in TvT event!");
  7097. + assist1.sendMessage("Tournament: You already participated in TvT event!");
  7098. + assist2.sendMessage("Tournament: You already participated in TvT event!");
  7099. + assist3.sendMessage("Tournament: You already participated in TvT event!");
  7100. + assist4.sendMessage("Tournament: You already participated in TvT event!");
  7101. + return;
  7102. + }
  7103. +
  7104. + if (!ArenaConfig.Allow_Same_HWID_On_Tournament)
  7105. + {
  7106. + //String ip1 = player.getHWID();
  7107. + //String ip2 = assist1.getHWID();
  7108. + //String ip3 = assist2.getHWID();
  7109. + //String ip4 = assist3.getHWID();
  7110. + //String ip5 = assist4.getHWID();
  7111. + String ip1 = player.getClient().getConnection().getInetAddress().getHostAddress();
  7112. + String ip2 = assist1.getClient().getConnection().getInetAddress().getHostAddress();
  7113. + String ip3 = assist2.getClient().getConnection().getInetAddress().getHostAddress();
  7114. + String ip4 = assist3.getClient().getConnection().getInetAddress().getHostAddress();
  7115. + String ip5 = assist4.getClient().getConnection().getInetAddress().getHostAddress();
  7116. +
  7117. + if (ip1.equals(ip2) || ip1.equals(ip3) || ip1.equals(ip4) || ip1.equals(ip5))
  7118. + {
  7119. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7120. + assist1.sendMessage("Tournament: Register only 1 player per Computer");
  7121. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7122. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7123. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7124. + return;
  7125. + }
  7126. + else if (ip2.equals(ip1) || ip2.equals(ip3) || ip2.equals(ip4) || ip2.equals(ip5))
  7127. + {
  7128. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7129. + assist1.sendMessage("Tournament: Register only 1 player per Computer");
  7130. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7131. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7132. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7133. + return;
  7134. + }
  7135. + else if (ip3.equals(ip1) || ip3.equals(ip2) || ip3.equals(ip4) || ip3.equals(ip5))
  7136. + {
  7137. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7138. + assist1.sendMessage("Tournament: Register only 1 player per Computer");
  7139. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7140. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7141. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7142. + return;
  7143. + }
  7144. + else if (ip4.equals(ip1) || ip4.equals(ip2) || ip4.equals(ip3) || ip3.equals(ip5))
  7145. + {
  7146. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7147. + assist1.sendMessage("Tournament: Register only 1 player per Computer");
  7148. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7149. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7150. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7151. + return;
  7152. + }
  7153. + }
  7154. +
  7155. + for (L2Effect effect : player.getAllEffects())
  7156. + {
  7157. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7158. + player.stopSkillEffects(effect.getSkill().getId());
  7159. + }
  7160. +
  7161. + for (L2Effect effect : assist1.getAllEffects())
  7162. + {
  7163. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7164. + assist1.stopSkillEffects(effect.getSkill().getId());
  7165. + }
  7166. +
  7167. + for (L2Effect effect : assist2.getAllEffects())
  7168. + {
  7169. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7170. + assist2.stopSkillEffects(effect.getSkill().getId());
  7171. + }
  7172. +
  7173. + for (L2Effect effect : assist3.getAllEffects())
  7174. + {
  7175. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7176. + assist3.stopSkillEffects(effect.getSkill().getId());
  7177. + }
  7178. +
  7179. + for (L2Effect effect : assist4.getAllEffects())
  7180. + {
  7181. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7182. + assist4.stopSkillEffects(effect.getSkill().getId());
  7183. + }
  7184. +
  7185. + ClasseCheck(player);
  7186. +
  7187. + if (player.duelist_cont > ArenaConfig.duelist_COUNT_5X5)
  7188. + {
  7189. + player.sendMessage("Tournament: Only " + ArenaConfig.duelist_COUNT_5X5 + " Duelist's or " + ArenaConfig.duelist_COUNT_5X5 + " Grand Khauatari's allowed per party.");
  7190. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.duelist_COUNT_5X5 + " Duelist's or " + ArenaConfig.duelist_COUNT_5X5 + " Grand Khauatari'sallowed per party.", 6 * 1000));
  7191. + clean(player);
  7192. + return;
  7193. + }
  7194. + else if (player.dreadnought_cont > ArenaConfig.dreadnought_COUNT_5X5)
  7195. + {
  7196. + player.sendMessage("Tournament: Only " + ArenaConfig.dreadnought_COUNT_5X5 + " Dread Nought's allowed per party.");
  7197. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.dreadnought_COUNT_5X5 + " Dread Nought's allowed per party.", 6 * 1000));
  7198. + clean(player);
  7199. + return;
  7200. + }
  7201. + else if (player.tanker_cont > ArenaConfig.tanker_COUNT_5X5)
  7202. + {
  7203. + player.sendMessage("Tournament: Only " + ArenaConfig.tanker_COUNT_5X5 + " Tanker's allowed per party.");
  7204. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.tanker_COUNT_5X5 + " Tanker's allowed per party.", 6 * 1000));
  7205. + clean(player);
  7206. + return;
  7207. + }
  7208. + else if (player.dagger_cont > ArenaConfig.dagger_COUNT_5X5)
  7209. + {
  7210. + player.sendMessage("Tournament: Only " + ArenaConfig.dagger_COUNT_5X5 + " Dagger's allowed per party.");
  7211. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.dagger_COUNT_5X5 + " Dagger's allowed per party.", 6 * 1000));
  7212. + clean(player);
  7213. + return;
  7214. + }
  7215. + else if (player.archer_cont > ArenaConfig.archer_COUNT_5X5)
  7216. + {
  7217. + player.sendMessage("Tournament: Only " + ArenaConfig.archer_COUNT_5X5 + " Archer's allowed per party.");
  7218. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.archer_COUNT_5X5 + " Archer's allowed per party.", 6 * 1000));
  7219. + clean(player);
  7220. + return;
  7221. + }
  7222. + else if (player.bs_cont > ArenaConfig.bs_COUNT_5X5)
  7223. + {
  7224. + if (ArenaConfig.bs_COUNT_5X5 == 0)
  7225. + {
  7226. + player.sendMessage("Tournament: Bishop's not allowed in 5x5.");
  7227. + player.sendPacket(new ExShowScreenMessage("Tournament: Bishop's not allowed in 5x5.", 6 * 1000));
  7228. + }
  7229. + else
  7230. + {
  7231. + player.sendMessage("Tournament: Only " + ArenaConfig.bs_COUNT_5X5 + " Bishop's allowed per party.");
  7232. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.bs_COUNT_5X5 + " Bishop's allowed per party.", 6 * 1000));
  7233. + }
  7234. + clean(player);
  7235. + return;
  7236. + }
  7237. + else if (player.archmage_cont > ArenaConfig.archmage_COUNT_5X5)
  7238. + {
  7239. + player.sendMessage("Tournament: Only " + ArenaConfig.archmage_COUNT_5X5 + " Archmage's allowed per party.");
  7240. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.archmage_COUNT_5X5 + " Archmage's allowed per party.", 6 * 1000));
  7241. + clean(player);
  7242. + return;
  7243. + }
  7244. + else if (player.soultaker_cont > ArenaConfig.soultaker_COUNT_5X5)
  7245. + {
  7246. + player.sendMessage("Tournament: Only " + ArenaConfig.soultaker_COUNT_5X5 + " Soultaker's allowed per party.");
  7247. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.soultaker_COUNT_5X5 + " Soultaker's allowed per party.", 6 * 1000));
  7248. + clean(player);
  7249. + return;
  7250. + }
  7251. + else if (player.mysticMuse_cont > ArenaConfig.mysticMuse_COUNT_5X5)
  7252. + {
  7253. + player.sendMessage("Tournament: Only " + ArenaConfig.mysticMuse_COUNT_5X5 + " Mystic Muse's allowed per party.");
  7254. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.mysticMuse_COUNT_5X5 + " Mystic Muse's allowed per party.", 6 * 1000));
  7255. + clean(player);
  7256. + return;
  7257. + }
  7258. + else if (player.stormScreamer_cont > ArenaConfig.stormScreamer_COUNT_5X5)
  7259. + {
  7260. + player.sendMessage("Tournament: Only " + ArenaConfig.stormScreamer_COUNT_5X5 + " Storm Screamer's allowed per party.");
  7261. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.stormScreamer_COUNT_5X5 + " Storm Screamer's allowed per party.", 6 * 1000));
  7262. + clean(player);
  7263. + return;
  7264. + }
  7265. + else if (player.titan_cont > ArenaConfig.titan_COUNT_5X5)
  7266. + {
  7267. + player.sendMessage("Tournament: Only " + ArenaConfig.titan_COUNT_5X5 + " Titan's allowed per party.");
  7268. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.titan_COUNT_5X5 + " Titan's allowed per party.", 6 * 1000));
  7269. + clean(player);
  7270. + return;
  7271. + }
  7272. + else if (player.dominator_cont > ArenaConfig.dominator_COUNT_5X5)
  7273. + {
  7274. + player.sendMessage("Tournament: Only " + ArenaConfig.dominator_COUNT_5X5 + " Dominator's or " + ArenaConfig.dominator_COUNT_5X5 + " Doomcryer's allowed per party.");
  7275. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.dominator_COUNT_5X5 + " Dominator's or " + ArenaConfig.dominator_COUNT_5X5 + " Doomcryer's allowed per party.", 6 * 1000));
  7276. + clean(player);
  7277. + return;
  7278. + }
  7279. + else if (Arena5x5.getInstance().register(player, assist1, assist2, assist3, assist4) && (player.getParty().getPartyMembers().get(1) != null && player.getParty().getPartyMembers().get(2) != null && player.getParty().getPartyMembers().get(3) != null && player.getParty().getPartyMembers().get(4) != null))
  7280. + {
  7281. + player.sendMessage("Tournament: Your participation has been approved.");
  7282. + assist1.sendMessage("Tournament: Your participation has been approved.");
  7283. + assist2.sendMessage("Tournament: Your participation has been approved.");
  7284. + assist3.sendMessage("Tournament: Your participation has been approved.");
  7285. + assist4.sendMessage("Tournament: Your participation has been approved.");
  7286. +
  7287. + player.setArenaProtection(true);
  7288. + assist1.setArenaProtection(true);
  7289. + assist2.setArenaProtection(true);
  7290. + assist3.setArenaProtection(true);
  7291. + assist4.setArenaProtection(true);
  7292. +
  7293. + player.setArena5x5(true);
  7294. + assist1.setArena5x5(true);
  7295. + assist2.setArena5x5(true);
  7296. + assist3.setArena5x5(true);
  7297. + assist4.setArena5x5(true);
  7298. + clean(player);
  7299. + showChatWindow(player);
  7300. + }
  7301. + else
  7302. + player.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7303. + }
  7304. +
  7305. + if (command.startsWith("9x9"))
  7306. + {
  7307. + if (!ArenaConfig.ALLOW_9X9_REGISTER)
  7308. + {
  7309. + player.sendMessage("Tournament 9x9 is not enabled.");
  7310. + return;
  7311. + }
  7312. +
  7313. + if (player.isArena3x3() || player.isArena5x5() || player.isArena9x9() || player.isArenaProtection())
  7314. + {
  7315. + player.sendMessage("Tournament: You already registered!");
  7316. + return;
  7317. + }
  7318. +
  7319. + if (player._active_boxes > 1 && !ArenaConfig.Allow_Same_HWID_On_Tournament)
  7320. + {
  7321. + final List<String> players_in_boxes = player.active_boxes_characters;
  7322. +
  7323. + if (players_in_boxes != null && players_in_boxes.size() > 1)
  7324. + {
  7325. + for (final String character_name : players_in_boxes)
  7326. + {
  7327. + final L2PcInstance ppl = L2World.getInstance().getPlayer(character_name);
  7328. +
  7329. + if (ppl != null && ppl.isArenaProtection())
  7330. + {
  7331. + player.sendMessage("You are already participating in Tournament with another char!");
  7332. + return;
  7333. + }
  7334. + }
  7335. + }
  7336. + }
  7337. +
  7338. + if (!player.isInParty())
  7339. + {
  7340. + player.sendMessage("Tournament: You dont have a party.");
  7341. + return;
  7342. + }
  7343. +
  7344. + if (!player.getParty().isLeader(player))
  7345. + {
  7346. + player.sendMessage("Tournament: You are not the party leader!");
  7347. + return;
  7348. + }
  7349. +
  7350. + if (player.getParty().getMemberCount() < 9)
  7351. + {
  7352. + player.sendMessage("Tournament: Your party does not have 9 members.");
  7353. + player.sendPacket(new ExShowScreenMessage("Your party does not have 9 members", 6 * 1000));
  7354. + return;
  7355. + }
  7356. +
  7357. + if (player.getParty().getMemberCount() > 9)
  7358. + {
  7359. + player.sendMessage("Tournament: Your Party can not have more than 9 members.");
  7360. + player.sendPacket(new ExShowScreenMessage("Your Party can not have more than 9 members", 6 * 1000));
  7361. + return;
  7362. + }
  7363. +
  7364. + L2PcInstance assist = player.getParty().getPartyMembers().get(1);
  7365. + L2PcInstance assist2 = player.getParty().getPartyMembers().get(2);
  7366. + L2PcInstance assist3 = player.getParty().getPartyMembers().get(3);
  7367. + L2PcInstance assist4 = player.getParty().getPartyMembers().get(4);
  7368. + L2PcInstance assist5 = player.getParty().getPartyMembers().get(5);
  7369. + L2PcInstance assist6 = player.getParty().getPartyMembers().get(6);
  7370. + L2PcInstance assist7 = player.getParty().getPartyMembers().get(7);
  7371. + L2PcInstance assist8 = player.getParty().getPartyMembers().get(8);
  7372. +
  7373. + if (player.isCursedWeaponEquipped() || assist.isCursedWeaponEquipped() || assist2.isCursedWeaponEquipped() || assist3.isCursedWeaponEquipped() || assist4.isCursedWeaponEquipped() || assist5.isCursedWeaponEquipped() || assist6.isCursedWeaponEquipped() || assist7.isCursedWeaponEquipped() || assist8.isCursedWeaponEquipped() || player.isInStoreMode() || assist.isInStoreMode() || assist2.isInStoreMode() || assist3.isInStoreMode() || assist4.isInStoreMode() || assist5.isInStoreMode() || assist6.isInStoreMode() || assist7.isInStoreMode() || assist8.isInStoreMode() || player.getKarma() > 0 || assist.getKarma() > 0 || assist2.getKarma() > 0 || assist3.getKarma() > 0 || assist4.getKarma() > 0 || assist5.getKarma() > 0 || assist6.getKarma() > 0 || assist7.getKarma() > 0 || assist8.getKarma() > 0)
  7374. + {
  7375. + player.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7376. + assist.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7377. + assist2.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7378. + assist3.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7379. + assist4.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7380. + assist5.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7381. + assist6.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7382. + assist7.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7383. + assist8.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7384. + return;
  7385. + }
  7386. +
  7387. + if (Olympiad.getInstance().isRegistered(player) || Olympiad.getInstance().isRegistered(assist) || Olympiad.getInstance().isRegistered(assist2) || Olympiad.getInstance().isRegistered(assist3) || Olympiad.getInstance().isRegistered(assist4) || Olympiad.getInstance().isRegistered(assist5) || Olympiad.getInstance().isRegistered(assist6) || Olympiad.getInstance().isRegistered(assist7) || Olympiad.getInstance().isRegistered(assist8))
  7388. + {
  7389. + player.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7390. + assist.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7391. + assist2.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7392. + assist3.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7393. + assist4.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7394. + assist5.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7395. + assist6.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7396. + assist7.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7397. + assist8.sendMessage("Tournament: You or your member is registered in the Olympiad.");
  7398. + return;
  7399. + }
  7400. +
  7401. + if (player._inEventTvT || assist._inEventTvT || assist2._inEventTvT || assist3._inEventTvT || assist4._inEventTvT || assist5._inEventTvT || assist6._inEventTvT || assist7._inEventTvT || assist8._inEventTvT || player._inEventCTF || assist._inEventCTF || assist2._inEventCTF || assist3._inEventCTF || assist4._inEventCTF || assist5._inEventCTF || assist6._inEventCTF || assist7._inEventCTF || assist8._inEventCTF)
  7402. + {
  7403. + player.sendMessage("Tournament: You already participated in TvT event!");
  7404. + assist.sendMessage("Tournament: You already participated in TvT event!");
  7405. + assist2.sendMessage("Tournament: You already participated in TvT event!");
  7406. + assist3.sendMessage("Tournament: You already participated in TvT event!");
  7407. + assist4.sendMessage("Tournament: You already participated in TvT event!");
  7408. + assist5.sendMessage("Tournament: You already participated in TvT event!");
  7409. + assist6.sendMessage("Tournament: You already participated in TvT event!");
  7410. + assist7.sendMessage("Tournament: You already participated in TvT event!");
  7411. + assist8.sendMessage("Tournament: You already participated in TvT event!");
  7412. + return;
  7413. + }
  7414. +
  7415. + if (!ArenaConfig.Allow_Same_HWID_On_Tournament)
  7416. + {
  7417. + if (player.isInParty() && (player.getParty().getPartyMembers().get(1) != null && player.getParty().getPartyMembers().get(2) != null && player.getParty().getPartyMembers().get(3) != null && player.getParty().getPartyMembers().get(4) != null && player.getParty().getPartyMembers().get(5) != null && player.getParty().getPartyMembers().get(6) != null && player.getParty().getPartyMembers().get(7) != null && player.getParty().getPartyMembers().get(8) != null))
  7418. + {
  7419. + //String ip1 = player.getHWID();
  7420. + //String ip2 = assist.getHWID();
  7421. + //String ip3 = assist2.getHWID();
  7422. + //String ip4 = assist3.getHWID();
  7423. + //String ip5 = assist4.getHWID();
  7424. + //String ip6 = assist5.getHWID();
  7425. + //String ip7 = assist6.getHWID();
  7426. + //String ip8 = assist7.getHWID();
  7427. + //String ip9 = assist8.getHWID();
  7428. + String ip1 = player.getClient().getConnection().getInetAddress().getHostAddress();
  7429. + String ip2 = assist.getClient().getConnection().getInetAddress().getHostAddress();
  7430. + String ip3 = assist2.getClient().getConnection().getInetAddress().getHostAddress();
  7431. + String ip4 = assist3.getClient().getConnection().getInetAddress().getHostAddress();
  7432. + String ip5 = assist4.getClient().getConnection().getInetAddress().getHostAddress();
  7433. + String ip6 = assist5.getClient().getConnection().getInetAddress().getHostAddress();
  7434. + String ip7 = assist6.getClient().getConnection().getInetAddress().getHostAddress();
  7435. + String ip8 = assist7.getClient().getConnection().getInetAddress().getHostAddress();
  7436. + String ip9 = assist8.getClient().getConnection().getInetAddress().getHostAddress();
  7437. +
  7438. + if (ip1.equals(ip2) || ip1.equals(ip3) || ip1.equals(ip4) || ip1.equals(ip5) || ip1.equals(ip6) || ip1.equals(ip7) || ip1.equals(ip8) || ip1.equals(ip9))
  7439. + {
  7440. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7441. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7442. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7443. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7444. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7445. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7446. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7447. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7448. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7449. + return;
  7450. + }
  7451. + else if (ip2.equals(ip1) || ip2.equals(ip3) || ip2.equals(ip4) || ip2.equals(ip5) || ip2.equals(ip6) || ip2.equals(ip7) || ip2.equals(ip8) || ip2.equals(ip9))
  7452. + {
  7453. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7454. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7455. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7456. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7457. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7458. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7459. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7460. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7461. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7462. + return;
  7463. + }
  7464. + else if (ip3.equals(ip1) || ip3.equals(ip2) || ip3.equals(ip4) || ip3.equals(ip5) || ip3.equals(ip6) || ip3.equals(ip7) || ip3.equals(ip8) || ip3.equals(ip9))
  7465. + {
  7466. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7467. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7468. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7469. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7470. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7471. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7472. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7473. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7474. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7475. + return;
  7476. + }
  7477. + else if (ip4.equals(ip1) || ip4.equals(ip2) || ip4.equals(ip3) || ip4.equals(ip5) || ip4.equals(ip6) || ip4.equals(ip7) || ip4.equals(ip8) || ip4.equals(ip9))
  7478. + {
  7479. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7480. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7481. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7482. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7483. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7484. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7485. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7486. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7487. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7488. + return;
  7489. + }
  7490. + else if (ip5.equals(ip1) || ip5.equals(ip2) || ip5.equals(ip3) || ip5.equals(ip4) || ip5.equals(ip6) || ip5.equals(ip7) || ip5.equals(ip8) || ip5.equals(ip9))
  7491. + {
  7492. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7493. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7494. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7495. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7496. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7497. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7498. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7499. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7500. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7501. + return;
  7502. + }
  7503. + else if (ip6.equals(ip1) || ip6.equals(ip2) || ip6.equals(ip3) || ip6.equals(ip4) || ip6.equals(ip5) || ip6.equals(ip7) || ip6.equals(ip8) || ip6.equals(ip9))
  7504. + {
  7505. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7506. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7507. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7508. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7509. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7510. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7511. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7512. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7513. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7514. + return;
  7515. + }
  7516. + else if (ip7.equals(ip1) || ip7.equals(ip2) || ip7.equals(ip3) || ip7.equals(ip4) || ip7.equals(ip5) || ip7.equals(ip6) || ip7.equals(ip8) || ip7.equals(ip9))
  7517. + {
  7518. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7519. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7520. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7521. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7522. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7523. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7524. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7525. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7526. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7527. + return;
  7528. + }
  7529. + else if (ip8.equals(ip1) || ip8.equals(ip2) || ip8.equals(ip3) || ip8.equals(ip4) || ip8.equals(ip5) || ip8.equals(ip6) || ip8.equals(ip7) || ip8.equals(ip9))
  7530. + {
  7531. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7532. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7533. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7534. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7535. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7536. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7537. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7538. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7539. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7540. + return;
  7541. + }
  7542. + else if (ip9.equals(ip1) || ip9.equals(ip2) || ip9.equals(ip3) || ip9.equals(ip4) || ip9.equals(ip5) || ip9.equals(ip6) || ip9.equals(ip7) || ip9.equals(ip8))
  7543. + {
  7544. + player.sendMessage("Tournament: Register only 1 player per Computer");
  7545. + assist.sendMessage("Tournament: Register only 1 player per Computer");
  7546. + assist2.sendMessage("Tournament: Register only 1 player per Computer");
  7547. + assist3.sendMessage("Tournament: Register only 1 player per Computer");
  7548. + assist4.sendMessage("Tournament: Register only 1 player per Computer");
  7549. + assist5.sendMessage("Tournament: Register only 1 player per Computer");
  7550. + assist6.sendMessage("Tournament: Register only 1 player per Computer");
  7551. + assist7.sendMessage("Tournament: Register only 1 player per Computer");
  7552. + assist8.sendMessage("Tournament: Register only 1 player per Computer");
  7553. + return;
  7554. + }
  7555. + }
  7556. + }
  7557. +
  7558. + for (L2Effect effect : player.getAllEffects())
  7559. + {
  7560. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7561. + player.stopSkillEffects(effect.getSkill().getId());
  7562. + }
  7563. +
  7564. + for (L2Effect effect : assist.getAllEffects())
  7565. + {
  7566. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7567. + assist.stopSkillEffects(effect.getSkill().getId());
  7568. + }
  7569. +
  7570. + for (L2Effect effect : assist2.getAllEffects())
  7571. + {
  7572. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7573. + assist2.stopSkillEffects(effect.getSkill().getId());
  7574. + }
  7575. +
  7576. + for (L2Effect effect : assist3.getAllEffects())
  7577. + {
  7578. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7579. + assist3.stopSkillEffects(effect.getSkill().getId());
  7580. + }
  7581. +
  7582. + for (L2Effect effect : assist4.getAllEffects())
  7583. + {
  7584. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7585. + assist4.stopSkillEffects(effect.getSkill().getId());
  7586. + }
  7587. +
  7588. + for (L2Effect effect : assist5.getAllEffects())
  7589. + {
  7590. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7591. + assist5.stopSkillEffects(effect.getSkill().getId());
  7592. + }
  7593. + for (L2Effect effect : assist6.getAllEffects())
  7594. + {
  7595. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7596. + assist6.stopSkillEffects(effect.getSkill().getId());
  7597. + }
  7598. + for (L2Effect effect : assist7.getAllEffects())
  7599. + {
  7600. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7601. + assist7.stopSkillEffects(effect.getSkill().getId());
  7602. + }
  7603. + for (L2Effect effect : assist8.getAllEffects())
  7604. + {
  7605. + if (ArenaConfig.ARENA_DISABLE_SKILL_LIST_PERM.contains(effect.getSkill().getId()))
  7606. + assist8.stopSkillEffects(effect.getSkill().getId());
  7607. + }
  7608. +
  7609. + ClasseCheck(player);
  7610. +
  7611. + if (player.duelist_cont > ArenaConfig.duelist_COUNT_9X9)
  7612. + {
  7613. + player.sendMessage("Tournament: Only " + ArenaConfig.duelist_COUNT_9X9 + " Duelist's or " + ArenaConfig.duelist_COUNT_9X9 + " Grand Khauatari's allowed per party.");
  7614. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.duelist_COUNT_9X9 + " Duelist's or " + ArenaConfig.duelist_COUNT_9X9 + " Grand Khauatari's allowed per party.", 6 * 1000));
  7615. + clean(player);
  7616. + return;
  7617. + }
  7618. + else if (player.dreadnought_cont > ArenaConfig.dreadnought_COUNT_9X9)
  7619. + {
  7620. + player.sendMessage("Tournament: Only " + ArenaConfig.dreadnought_COUNT_9X9 + " Dread Nought's allowed per party.");
  7621. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.dreadnought_COUNT_9X9 + " Dread Nought's allowed per party.", 6 * 1000));
  7622. + clean(player);
  7623. + return;
  7624. + }
  7625. + else if (player.tanker_cont > ArenaConfig.tanker_COUNT_9X9)
  7626. + {
  7627. + player.sendMessage("Tournament: Only " + ArenaConfig.tanker_COUNT_9X9 + " Tanker's allowed per party.");
  7628. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.tanker_COUNT_9X9 + " Tanker's allowed per party.", 6 * 1000));
  7629. + clean(player);
  7630. + return;
  7631. + }
  7632. + else if (player.dagger_cont > ArenaConfig.dagger_COUNT_9X9)
  7633. + {
  7634. + player.sendMessage("Tournament: Only " + ArenaConfig.dagger_COUNT_9X9 + " Dagger's allowed per party.");
  7635. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.dagger_COUNT_9X9 + " Dagger's allowed per party.", 6 * 1000));
  7636. + clean(player);
  7637. + return;
  7638. + }
  7639. + else if (player.archer_cont > ArenaConfig.archer_COUNT_9X9)
  7640. + {
  7641. + player.sendMessage("Tournament: Only " + ArenaConfig.archer_COUNT_9X9 + " Archer's allowed per party.");
  7642. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.archer_COUNT_9X9 + " Archer's allowed per party.", 6 * 1000));
  7643. + clean(player);
  7644. + return;
  7645. + }
  7646. + else if (player.bs_cont > ArenaConfig.bs_COUNT_9X9)
  7647. + {
  7648. + player.sendMessage("Tournament: Only " + ArenaConfig.bs_COUNT_9X9 + " Bishop's allowed per party.");
  7649. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.bs_COUNT_9X9 + " Bishop's allowed per party.", 6 * 1000));
  7650. + clean(player);
  7651. + return;
  7652. + }
  7653. + else if (player.archmage_cont > ArenaConfig.archmage_COUNT_9X9)
  7654. + {
  7655. + player.sendMessage("Tournament: Only " + ArenaConfig.archmage_COUNT_9X9 + " Archmage's allowed per party.");
  7656. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.archmage_COUNT_9X9 + " Archmage's allowed per party.", 6 * 1000));
  7657. + clean(player);
  7658. + return;
  7659. + }
  7660. + else if (player.soultaker_cont > ArenaConfig.soultaker_COUNT_9X9)
  7661. + {
  7662. + player.sendMessage("Tournament: Only " + ArenaConfig.soultaker_COUNT_9X9 + " Soultaker's allowed per party.");
  7663. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.soultaker_COUNT_9X9 + " Soultaker's allowed per party.", 6 * 1000));
  7664. + clean(player);
  7665. + return;
  7666. + }
  7667. + else if (player.mysticMuse_cont > ArenaConfig.mysticMuse_COUNT_9X9)
  7668. + {
  7669. + player.sendMessage("Tournament: Only " + ArenaConfig.mysticMuse_COUNT_9X9 + " Mystic Muse's allowed per party.");
  7670. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.mysticMuse_COUNT_9X9 + " Mystic Muse's allowed per party.", 6 * 1000));
  7671. + clean(player);
  7672. + return;
  7673. + }
  7674. + else if (player.stormScreamer_cont > ArenaConfig.stormScreamer_COUNT_9X9)
  7675. + {
  7676. + player.sendMessage("Tournament: Only " + ArenaConfig.stormScreamer_COUNT_9X9 + " Storm Screamer's allowed per party.");
  7677. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.stormScreamer_COUNT_9X9 + " Storm Screamer's allowed per party.", 6 * 1000));
  7678. + clean(player);
  7679. + return;
  7680. + }
  7681. + else if (player.titan_cont > ArenaConfig.titan_COUNT_9X9)
  7682. + {
  7683. + player.sendMessage("Tournament: Only " + ArenaConfig.titan_COUNT_9X9 + " Titan's allowed per party.");
  7684. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.titan_COUNT_9X9 + " Titan's allowed per party.", 6 * 1000));
  7685. + clean(player);
  7686. + return;
  7687. + }
  7688. + else if (player.dominator_cont > ArenaConfig.dominator_COUNT_9X9)
  7689. + {
  7690. + player.sendMessage("Tournament: Only " + ArenaConfig.dominator_COUNT_9X9 + " Dominator's or " + ArenaConfig.dominator_COUNT_9X9 + " Doomcryer's allowed per party.");
  7691. + player.sendPacket(new ExShowScreenMessage("Only " + ArenaConfig.dominator_COUNT_9X9 + " Dominator's or " + ArenaConfig.dominator_COUNT_9X9 + " Doomcryer's allowed per party.", 6 * 1000));
  7692. + clean(player);
  7693. + return;
  7694. + }
  7695. + else if (Arena9x9.getInstance().register(player, assist, assist2, assist3, assist4, assist5, assist6, assist7, assist8) && (player.getParty().getPartyMembers().get(1) != null && player.getParty().getPartyMembers().get(2) != null && player.getParty().getPartyMembers().get(3) != null && player.getParty().getPartyMembers().get(4) != null && player.getParty().getPartyMembers().get(5) != null && player.getParty().getPartyMembers().get(6) != null && player.getParty().getPartyMembers().get(7) != null && player.getParty().getPartyMembers().get(8) != null))
  7696. + {
  7697. + player.sendMessage("Tournament: Your participation has been approved.");
  7698. + assist.sendMessage("Tournament: Your participation has been approved.");
  7699. + assist2.sendMessage("Tournament: Your participation has been approved.");
  7700. + assist3.sendMessage("Tournament: Your participation has been approved.");
  7701. + assist4.sendMessage("Tournament: Your participation has been approved.");
  7702. + assist5.sendMessage("Tournament: Your participation has been approved.");
  7703. + assist6.sendMessage("Tournament: Your participation has been approved.");
  7704. + assist7.sendMessage("Tournament: Your participation has been approved.");
  7705. + assist8.sendMessage("Tournament: Your participation has been approved.");
  7706. +
  7707. + player.setArenaProtection(true);
  7708. + assist.setArenaProtection(true);
  7709. + assist2.setArenaProtection(true);
  7710. + assist3.setArenaProtection(true);
  7711. + assist4.setArenaProtection(true);
  7712. + assist5.setArenaProtection(true);
  7713. + assist6.setArenaProtection(true);
  7714. + assist7.setArenaProtection(true);
  7715. + assist8.setArenaProtection(true);
  7716. +
  7717. + player.setArena9x9(true);
  7718. + assist.setArena9x9(true);
  7719. + assist2.setArena9x9(true);
  7720. + assist3.setArena9x9(true);
  7721. + assist4.setArena9x9(true);
  7722. + assist5.setArena9x9(true);
  7723. + assist6.setArena9x9(true);
  7724. + assist7.setArena9x9(true);
  7725. + assist8.setArena9x9(true);
  7726. + clean(player);
  7727. + showChatWindow(player);
  7728. +
  7729. + }
  7730. + else
  7731. + player.sendMessage("Tournament: You or your member does not have the necessary requirements.");
  7732. + }
  7733. + else if (command.startsWith("remove"))
  7734. + {
  7735. + if (!player.isInParty() && !player.isArena1x1())
  7736. + {
  7737. + player.sendMessage("Tournament: You dont have a party.");
  7738. + return;
  7739. + }
  7740. + else if (player.getParty() != null && !player.getParty().isLeader(player))
  7741. + {
  7742. + player.sendMessage("Tournament: You are not the party leader!");
  7743. + return;
  7744. + }
  7745. +
  7746. + if (player.isArena1x1())
  7747. + Arena1x1.getInstance().remove(player);
  7748. + if (player.isArena3x3())
  7749. + Arena3x3.getInstance().remove(player);
  7750. + if (player.isArena5x5())
  7751. + Arena5x5.getInstance().remove(player);
  7752. + if (player.isArena9x9())
  7753. + Arena9x9.getInstance().remove(player);
  7754. + }
  7755. + else
  7756. + super.onBypassFeedback(player, command);
  7757. + }
  7758. +
  7759. + public void ClasseCheck(L2PcInstance activeChar)
  7760. + {
  7761. + L2Party plparty = activeChar.getParty();
  7762. + for (L2PcInstance player : plparty.getPartyMembers())
  7763. + {
  7764. + if (player != null)
  7765. + {
  7766. + if (player.getParty() != null)
  7767. + {
  7768. + if (player.getClassId() == ClassId.gladiator || player.getClassId() == ClassId.duelist || player.getClassId() == ClassId.grandKhauatari || player.getClassId() == ClassId.tyrant)
  7769. + activeChar.duelist_cont = activeChar.duelist_cont + 1;
  7770. +
  7771. + if (player.getClassId() == ClassId.warlord || player.getClassId() == ClassId.dreadnought)
  7772. + activeChar.dreadnought_cont = activeChar.dreadnought_cont + 1;
  7773. +
  7774. + if (player.getClassId() == ClassId.paladin || player.getClassId() == ClassId.phoenixKnight || player.getClassId() == ClassId.darkAvenger || player.getClassId() == ClassId.hellKnight || player.getClassId() == ClassId.evaTemplar || player.getClassId() == ClassId.templeKnight || player.getClassId() == ClassId.shillienKnight || player.getClassId() == ClassId.shillienTemplar)
  7775. + activeChar.tanker_cont = activeChar.tanker_cont + 1;
  7776. +
  7777. + if (player.getClassId() == ClassId.adventurer || player.getClassId() == ClassId.treasureHunter || player.getClassId() == ClassId.windRider || player.getClassId() == ClassId.plainsWalker || player.getClassId() == ClassId.ghostHunter || player.getClassId() == ClassId.abyssWalker)
  7778. + activeChar.dagger_cont = activeChar.dagger_cont + 1;
  7779. +
  7780. + if (player.getClassId() == ClassId.hawkeye || player.getClassId() == ClassId.sagittarius || player.getClassId() == ClassId.moonlightSentinel || player.getClassId() == ClassId.silverRanger || player.getClassId() == ClassId.ghostSentinel || player.getClassId() == ClassId.phantomRanger)
  7781. + activeChar.archer_cont = activeChar.archer_cont + 1;
  7782. +
  7783. + if (player.getClassId() == ClassId.shillenElder || player.getClassId() == ClassId.shillienSaint || player.getClassId() == ClassId.bishop || player.getClassId() == ClassId.cardinal || player.getClassId() == ClassId.elder || player.getClassId() == ClassId.evaSaint)
  7784. + activeChar.bs_cont = activeChar.bs_cont + 1;
  7785. +
  7786. + if (player.getClassId() == ClassId.archmage || player.getClassId() == ClassId.sorceror)
  7787. + activeChar.archmage_cont = activeChar.archmage_cont + 1;
  7788. +
  7789. + if (player.getClassId() == ClassId.soultaker || player.getClassId() == ClassId.necromancer)
  7790. + activeChar.soultaker_cont = activeChar.soultaker_cont + 1;
  7791. +
  7792. + if (player.getClassId() == ClassId.mysticMuse || player.getClassId() == ClassId.spellsinger)
  7793. + activeChar.mysticMuse_cont = activeChar.mysticMuse_cont + 1;
  7794. +
  7795. + if (player.getClassId() == ClassId.stormScreamer || player.getClassId() == ClassId.spellhowler)
  7796. + activeChar.stormScreamer_cont = activeChar.stormScreamer_cont + 1;
  7797. +
  7798. + if (player.getClassId() == ClassId.titan || player.getClassId() == ClassId.destroyer)
  7799. + activeChar.titan_cont = activeChar.titan_cont + 1;
  7800. +
  7801. + if (player.getClassId() == ClassId.dominator || player.getClassId() == ClassId.overlord || player.getClassId() == ClassId.doomcryer || player.getClassId() == ClassId.warcryer)
  7802. + activeChar.dominator_cont = activeChar.dominator_cont + 1;
  7803. +
  7804. + }
  7805. + }
  7806. + }
  7807. + }
  7808. +
  7809. + public void clean(L2PcInstance player)
  7810. + {
  7811. + player.duelist_cont = 0;
  7812. + player.dreadnought_cont = 0;
  7813. + player.tanker_cont = 0;
  7814. + player.dagger_cont = 0;
  7815. + player.archer_cont = 0;
  7816. + player.bs_cont = 0;
  7817. + player.archmage_cont = 0;
  7818. + player.soultaker_cont = 0;
  7819. + player.mysticMuse_cont = 0;
  7820. + player.stormScreamer_cont = 0;
  7821. + player.titan_cont = 0;
  7822. + player.grandKhauatari_cont = 0;
  7823. + player.dominator_cont = 0;
  7824. + player.doomcryer_cont = 0;
  7825. + }
  7826. +}
  7827. \ No newline at end of file
  7828. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2VillageMasterInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2VillageMasterInstance.java
  7829. index de9f073..039cad8 100644
  7830. --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2VillageMasterInstance.java
  7831. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2VillageMasterInstance.java
  7832. @@ -56,6 +56,8 @@
  7833. import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  7834. import com.l2jfrozen.gameserver.util.Util;
  7835.  
  7836. +import Dev.Tournament.properties.ArenaTask;
  7837. +
  7838. /**
  7839. * This class ...
  7840. * @version $Revision: 1.4.2.3.2.8 $ $Date: 2009/04/13 02:10:41 $
  7841. @@ -96,7 +98,14 @@
  7842. {
  7843. cmdParams2 = commandStr[2];
  7844. }
  7845. -
  7846. + if (player.isArenaProtection())
  7847. + {
  7848. + if (!ArenaTask.is_started())
  7849. + player.setArenaProtection(false);
  7850. + else
  7851. + player.sendMessage("Remove your participation from the Tournament Event!");
  7852. + return;
  7853. + }
  7854. commandStr = null;
  7855. if (player.isAio() && !Config.ALLOW_AIO_USE_CM)
  7856. {
  7857. diff --git a/head-src/com/l2jfrozen/gameserver/model/zone/L2ZoneType.java b/head-src/com/l2jfrozen/gameserver/model/zone/L2ZoneType.java
  7858. index 4d412ab..8367847 100644
  7859. --- a/head-src/com/l2jfrozen/gameserver/model/zone/L2ZoneType.java
  7860. +++ b/head-src/com/l2jfrozen/gameserver/model/zone/L2ZoneType.java
  7861. @@ -372,7 +372,7 @@
  7862.  
  7863. for (final L2Character character : _characterList.values())
  7864. {
  7865. - if (character instanceof L2PcInstance)
  7866. + if (character instanceof L2PcInstance && !(((L2PcInstance) character).isInsideZone(L2Character.TOURNAMENT) && !((L2PcInstance) character).inObserverMode()) && !((L2PcInstance) character).isArenaProtection() && !((L2PcInstance) character).isArenaObserv())
  7867. character.sendPacket(packet);
  7868. }
  7869. }
  7870. diff --git a/head-src/com/l2jfrozen/gameserver/model/zone/type/L2ArenaEventZone.java b/head-src/com/l2jfrozen/gameserver/model/zone/type/L2ArenaEventZone.java
  7871. new file mode 100644
  7872. index 0000000..2ea0a36
  7873. --- /dev/null
  7874. +++ b/head-src/com/l2jfrozen/gameserver/model/zone/type/L2ArenaEventZone.java
  7875. @@ -0,0 +1,206 @@
  7876. +/*
  7877. + * This program is free software: you can redistribute it and/or modify it under
  7878. + * the terms of the GNU General Public License as published by the Free Software
  7879. + * Foundation, either version 3 of the License, or (at your option) any later
  7880. + * version.
  7881. + *
  7882. + * This program is distributed in the hope that it will be useful, but WITHOUT
  7883. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  7884. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  7885. + * details.
  7886. + *
  7887. + * You should have received a copy of the GNU General Public License along with
  7888. + * this program. If not, see <[url="http://www.gnu.org/licenses/>."]http://www.gnu.org/licenses/>.[/url]
  7889. + */
  7890. +package com.l2jfrozen.gameserver.model.zone.type;
  7891. +
  7892. +import com.l2jfrozen.Config;
  7893. +import com.l2jfrozen.gameserver.datatables.SkillTable;
  7894. +import com.l2jfrozen.gameserver.model.L2Character;
  7895. +import com.l2jfrozen.gameserver.model.L2Skill;
  7896. +import com.l2jfrozen.gameserver.model.actor.instance.L2MonsterInstance;
  7897. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  7898. +import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
  7899. +import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
  7900. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  7901. +import com.l2jfrozen.util.random.Rnd;
  7902. +
  7903. +import java.util.concurrent.Future;
  7904. +
  7905. +public class L2ArenaEventZone extends L2ZoneType
  7906. +{
  7907. + int _skillId;
  7908. + private int _chance;
  7909. + private int _initialDelay;
  7910. + int _skillLvl;
  7911. + private int _reuse;
  7912. + private boolean _enabled;
  7913. + private String _target;
  7914. + private Future<?> _task;
  7915. +
  7916. + public L2ArenaEventZone(int id)
  7917. + {
  7918. + super(id);
  7919. + _skillId = 1323;
  7920. + _skillLvl = 1;
  7921. + _chance = 100;
  7922. + _initialDelay = 0;
  7923. + _reuse = 30000;
  7924. + _enabled = true;
  7925. + _target = "pc";
  7926. + }
  7927. +
  7928. + @Override
  7929. + public void setParameter(String name, String value)
  7930. + {
  7931. + if (name.equals("skillId"))
  7932. + {
  7933. + _skillId = Integer.parseInt(value);
  7934. + }
  7935. + else if (name.equals("skillLvl"))
  7936. + {
  7937. + _skillLvl = Integer.parseInt(value);
  7938. + }
  7939. + else if (name.equals("chance"))
  7940. + {
  7941. + _chance = Integer.parseInt(value);
  7942. + }
  7943. + else if (name.equals("initialDelay"))
  7944. + {
  7945. + _initialDelay = Integer.parseInt(value);
  7946. + }
  7947. + else if (name.equals("default_enabled"))
  7948. + {
  7949. + _enabled = Boolean.parseBoolean(value);
  7950. + }
  7951. + else if (name.equals("target"))
  7952. + {
  7953. + _target = String.valueOf(value);
  7954. + }
  7955. + else if (name.equals("reuse"))
  7956. + {
  7957. + _reuse = Integer.parseInt(value);
  7958. + }
  7959. + else
  7960. + {
  7961. + super.setParameter(name, value);
  7962. + }
  7963. + }
  7964. + /** The _pvp flag lasts. */
  7965. + private long _pvpFlagLasts;
  7966. +
  7967. + /**
  7968. + * Sets the pvp flag lasts.
  7969. + * @param time the new pvp flag lasts
  7970. + */
  7971. + public void setPvpFlagLasts(final long time)
  7972. + {
  7973. + _pvpFlagLasts = time;
  7974. + }
  7975. + /* Gets the pvp flag lasts.
  7976. + * @return the pvp flag lasts
  7977. + */
  7978. + public long getPvpFlagLasts()
  7979. + {
  7980. + return _pvpFlagLasts;
  7981. + }
  7982. + @Override
  7983. + protected void onEnter(L2Character character)
  7984. + {
  7985. + if (character instanceof L2PcInstance)
  7986. + {
  7987. + character.setInsideZone(L2Character.ARENA_EVENT, true);
  7988. + // Set pvp flag
  7989. + ((L2PcInstance) character).setPvpFlag(1);
  7990. + ((L2PcInstance) character).sendMessage("You are in pvp zone.");
  7991. + ((L2PcInstance) character).broadcastUserInfo();
  7992. + if ((character instanceof L2PlayableInstance && _target.equalsIgnoreCase("pc") || character instanceof L2PcInstance && _target.equalsIgnoreCase("pc_only") || character instanceof L2MonsterInstance && _target.equalsIgnoreCase("npc")) && _task == null)
  7993. + {
  7994. + _task = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ApplySkill(/* this */), _initialDelay, _reuse);
  7995. + }
  7996. + }
  7997. + }
  7998. +
  7999. + @Override
  8000. + protected void onExit(L2Character character)
  8001. + {
  8002. + if (character instanceof L2PcInstance)
  8003. + {
  8004. + character.setInsideZone(L2Character.ARENA_EVENT, false);
  8005. + setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_NORMAL_TIME);
  8006. + ((L2PcInstance) character).setPvpFlag(0);
  8007. + ((L2PcInstance) character).sendMessage("You are not in pvp zone, sissy.");
  8008. + ((L2PcInstance) character).broadcastUserInfo();
  8009. + }
  8010. + if (_characterList.isEmpty() && _task != null)
  8011. + {
  8012. + _task.cancel(true);
  8013. + _task = null;
  8014. + }
  8015. + }
  8016. +
  8017. + public L2Skill getSkill()
  8018. + {
  8019. + return SkillTable.getInstance().getInfo(_skillId, _skillLvl);
  8020. + }
  8021. +
  8022. + public String getTargetType()
  8023. + {
  8024. + return _target;
  8025. + }
  8026. +
  8027. + public boolean isEnabled()
  8028. + {
  8029. + return _enabled;
  8030. + }
  8031. +
  8032. + public int getChance()
  8033. + {
  8034. + return _chance;
  8035. + }
  8036. +
  8037. + public void setZoneEnabled(boolean val)
  8038. + {
  8039. + _enabled = val;
  8040. + }
  8041. +
  8042. + class ApplySkill implements Runnable
  8043. + {
  8044. + @Override
  8045. + public void run()
  8046. + {
  8047. + if (isEnabled())
  8048. + {
  8049. + for (L2Character temp : _characterList.values())
  8050. + {
  8051. + if (temp != null && !temp.isDead())
  8052. + {
  8053. + if ((temp instanceof L2PlayableInstance && getTargetType().equalsIgnoreCase("pc") || temp instanceof L2PcInstance && getTargetType().equalsIgnoreCase("pc_only") || temp instanceof L2MonsterInstance && getTargetType().equalsIgnoreCase("npc")) && Rnd.get(100) < getChance())
  8054. + {
  8055. + L2Skill skill = null;
  8056. + if ((skill = getSkill()) == null)
  8057. + {
  8058. + System.out.println("ATTENTION: error on zone with id " + getId());
  8059. + System.out.println("Skill " + _skillId + "," + _skillLvl + " not present between skills");
  8060. + }
  8061. + else
  8062. + skill.getEffects(temp, temp);
  8063. + }
  8064. + }
  8065. + }
  8066. + }
  8067. + }
  8068. + }
  8069. +
  8070. + @Override
  8071. + public void onDieInside(L2Character character)
  8072. + {
  8073. +
  8074. + }
  8075. +
  8076. + @Override
  8077. + public void onReviveInside(L2Character character)
  8078. + {
  8079. +
  8080. + }
  8081. +}
  8082. \ No newline at end of file
  8083. diff --git a/head-src/com/l2jfrozen/gameserver/model/zone/type/L2OlympiadStadiumZone.java b/head-src/com/l2jfrozen/gameserver/model/zone/type/L2OlympiadStadiumZone.java
  8084. index abcbd19..0720174 100644
  8085. --- a/head-src/com/l2jfrozen/gameserver/model/zone/type/L2OlympiadStadiumZone.java
  8086. +++ b/head-src/com/l2jfrozen/gameserver/model/zone/type/L2OlympiadStadiumZone.java
  8087. @@ -54,13 +54,15 @@
  8088. public void onEnter(final L2Character character)
  8089. {
  8090. character.setInsideZone(L2Character.ZONE_PVP, true);
  8091. -
  8092. +
  8093. if (character instanceof L2PcInstance)
  8094. {
  8095. - if ((((L2PcInstance) character).getOlympiadGameId() + 1) == getStadiumId())
  8096. - ((L2PcInstance) character).sendPacket(new SystemMessage(SystemMessageId.ENTERED_COMBAT_ZONE));
  8097. + final L2PcInstance player = character.getActingPlayer();
  8098. +
  8099. + if (player.getOlympiadGameId() + 1 == getStadiumId() || player.isArenaProtection() || player.isGM())
  8100. + player.sendPacket(new SystemMessage(SystemMessageId.ENTERED_COMBAT_ZONE));
  8101. else
  8102. - character.teleToLocation(TeleportWhereType.Town);
  8103. + player.teleToLocation(TeleportWhereType.Town);
  8104. }
  8105. }
  8106.  
  8107. diff --git a/head-src/com/l2jfrozen/gameserver/model/zone/type/L2TournamentZone.java b/head-src/com/l2jfrozen/gameserver/model/zone/type/L2TournamentZone.java
  8108. new file mode 100644
  8109. index 0000000..0da16e7
  8110. --- /dev/null
  8111. +++ b/head-src/com/l2jfrozen/gameserver/model/zone/type/L2TournamentZone.java
  8112. @@ -0,0 +1,90 @@
  8113. +/*
  8114. + * This program is free software: you can redistribute it and/or modify it under
  8115. + * the terms of the GNU General Public License as published by the Free Software
  8116. + * Foundation, either version 3 of the License, or (at your option) any later
  8117. + * version.
  8118. + *
  8119. + * This program is distributed in the hope that it will be useful, but WITHOUT
  8120. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8121. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  8122. + * details.
  8123. + *
  8124. + * You should have received a copy of the GNU General Public License along with
  8125. + * this program. If not, see <http://www.gnu.org/licenses/>.
  8126. + */
  8127. +package com.l2jfrozen.gameserver.model.zone.type;
  8128. +
  8129. +import com.l2jfrozen.gameserver.model.L2Character;
  8130. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  8131. +import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
  8132. +
  8133. +public class L2TournamentZone extends L2ZoneType
  8134. +{
  8135. + public L2TournamentZone(int id)
  8136. + {
  8137. + super(id);
  8138. + }
  8139. +
  8140. + @Override
  8141. + protected void onEnter(L2Character character)
  8142. + {
  8143. + character.setInsideZone(L2Character.ZONE_PEACE, true);
  8144. + character.setInsideZone(L2Character.TOURNAMENT, true);
  8145. +
  8146. + if (character instanceof L2PcInstance)
  8147. + {
  8148. + final L2PcInstance player = (L2PcInstance) character;
  8149. + player.setTournamentTeleport(true);
  8150. + if (!player.isOlympiadProtection())
  8151. + {
  8152. + player.sendMessage("You have entered a Tournament zone.");
  8153. + //player.getAppearance().setInvisible();
  8154. + player.broadcastUserInfo();
  8155. + }
  8156. +
  8157. + }
  8158. + }
  8159. +
  8160. + @Override
  8161. + protected void onExit(L2Character character)
  8162. + {
  8163. + character.setInsideZone(L2Character.TOURNAMENT, false);
  8164. + character.setInsideZone(L2Character.ZONE_PEACE, false);
  8165. +
  8166. + if (character instanceof L2PcInstance)
  8167. + {
  8168. + final L2PcInstance player = (L2PcInstance) character;
  8169. +
  8170. + if (!player.isArenaProtection() && !player.isOlympiadProtection())
  8171. + {
  8172. + player.setTournamentTeleport(false);
  8173. +
  8174. + if (!player.inObserverMode() && !player.isOlympiadProtection() && !player.isGM())
  8175. + player.getAppearance().setVisible();
  8176. +
  8177. + /*
  8178. + if (!player.inObserverMode())
  8179. + {
  8180. + player._player_n = 1;
  8181. + player.sendMessage("Tournament: You have been removed from the waiting list!");
  8182. + }
  8183. + */
  8184. +
  8185. + player.sendMessage("You left a Tournament zone.");
  8186. + player.broadcastUserInfo();
  8187. + }
  8188. +
  8189. + }
  8190. + }
  8191. +
  8192. + @Override
  8193. + public void onDieInside(L2Character character)
  8194. + {
  8195. + }
  8196. +
  8197. + @Override
  8198. + public void onReviveInside(L2Character character)
  8199. + {
  8200. + }
  8201. +
  8202. +}
  8203. \ No newline at end of file
  8204. diff --git a/head-src/com/l2jfrozen/gameserver/network/L2GameClient.java b/head-src/com/l2jfrozen/gameserver/network/L2GameClient.java
  8205. index 01020bc..3286c24 100644
  8206. --- a/head-src/com/l2jfrozen/gameserver/network/L2GameClient.java
  8207. +++ b/head-src/com/l2jfrozen/gameserver/network/L2GameClient.java
  8208. @@ -71,6 +71,8 @@
  8209. import com.l2jfrozen.util.database.DatabaseUtils;
  8210. import com.l2jfrozen.util.database.L2DatabaseFactory;
  8211.  
  8212. +import Dev.Tournament.properties.ArenaTask;
  8213. +
  8214. /**
  8215. * @author L2JFrozen dev
  8216. */
  8217. @@ -785,6 +787,17 @@
  8218. final L2PcInstance player = L2GameClient.this.getActiveChar();
  8219. if (player != null) // this should only happen on connection loss
  8220. {
  8221. + if (player.isArenaProtection())
  8222. + {
  8223. + player.setXYZ(ArenaTask.loc1x(), ArenaTask.loc1y(), ArenaTask.loc1z());
  8224. + if (player.isInArenaEvent())
  8225. + {
  8226. + player.getAppearance().setTitleColor(player._originalTitleColorTournament);
  8227. + player.setTitle(player._originalTitleTournament);
  8228. + player.broadcastUserInfo();
  8229. + player.broadcastTitleInfo();
  8230. + }
  8231. + }
  8232. if (Config.ENABLE_OLYMPIAD_DISCONNECTION_DEBUG)
  8233. {
  8234. if (player.isInOlympiadMode() || player.inObserverMode())
  8235. @@ -799,6 +812,11 @@
  8236. final String text = "Player " + player.getName() + ", Class:" + player.getClassId() + ", Level:" + player.getLevel() + ", Mode: Observer, Loc: " + player.getX() + " Y:" + player.getY() + " Z:" + player.getZ() + ", Critical?: " + _forcedToClose;
  8237. OlympiadLogger.add(text, "Olympiad_crash_debug");
  8238. }
  8239. + if (player.isInArenaEvent())
  8240. + {
  8241. + //player.increaseArenaDefeats();
  8242. + player.setXYZ(82698, 148638, -3473);
  8243. + }
  8244. else
  8245. {
  8246. final String text = "Player " + player.getName() + ", Class:" + player.getClassId() + ", Level:" + player.getLevel() + ", Mode: Default, Loc: " + player.getX() + " Y:" + player.getY() + " Z:" + player.getZ() + ", Critical?: " + _forcedToClose;
  8247. @@ -914,6 +932,17 @@
  8248. L2PcInstance player = L2GameClient.this.getActiveChar();
  8249. if (player != null) // this should only happen on connection loss
  8250. {
  8251. + if (player.isArenaProtection())
  8252. + {
  8253. + player.setXYZ(ArenaTask.loc1x(), ArenaTask.loc1y(), ArenaTask.loc1z());
  8254. + if (player.isInArenaEvent())
  8255. + {
  8256. + player.getAppearance().setTitleColor(player._originalTitleColorTournament);
  8257. + player.setTitle(player._originalTitleTournament);
  8258. + player.broadcastUserInfo();
  8259. + player.broadcastTitleInfo();
  8260. + }
  8261. + }
  8262. // Olympiad crash DEBUG
  8263. if (Config.ENABLE_OLYMPIAD_DISCONNECTION_DEBUG)
  8264. {
  8265. diff --git a/head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java b/head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java
  8266. index 13436ef..97643ef 100644
  8267. --- a/head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java
  8268. +++ b/head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java
  8269. @@ -31,6 +31,8 @@
  8270. import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  8271. import com.l2jfrozen.gameserver.taskmanager.AttackStanceTaskManager;
  8272.  
  8273. +import Dev.Tournament.properties.ArenaTask;
  8274. +
  8275. public final class Logout extends L2GameClientPacket
  8276. {
  8277. private static Logger LOGGER = Logger.getLogger(Logout.class);
  8278. @@ -55,7 +57,12 @@
  8279. player.sendPacket(ActionFailed.STATIC_PACKET);
  8280. return;
  8281. }
  8282. -
  8283. + if ((player.isInArenaEvent() || player.isArenaProtection()) && ArenaTask.is_started())
  8284. + {
  8285. + player.sendMessage("You cannot logout while in Tournament Event!");
  8286. + player.sendPacket(ActionFailed.STATIC_PACKET);
  8287. + return;
  8288. + }
  8289. if (player.isAway())
  8290. {
  8291. player.sendMessage("You can't restart in Away mode.");
  8292. diff --git a/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java b/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
  8293. index 7b6d64b..17ab26d 100644
  8294. --- a/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
  8295. +++ b/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestBypassToServer.java
  8296. @@ -63,8 +63,10 @@
  8297. import com.l2jfrozen.gameserver.util.GMAudit;
  8298. import com.l2jfrozen.util.StringUtil;
  8299. import com.l2jfrozen.util.database.L2DatabaseFactory;
  8300. +import com.l2jfrozen.util.random.Rnd;
  8301.  
  8302. import Dev.SpecialMods.DressMeData;
  8303. +import Dev.Tournament.properties.ArenaConfig;
  8304.  
  8305. public final class RequestBypassToServer extends L2GameClientPacket
  8306. {
  8307. @@ -176,6 +178,16 @@
  8308. VoicedBossSpawn.showHtml2(activeChar);
  8309.  
  8310. }
  8311. + else if (_command.startsWith("tele_tournament"))
  8312. + {
  8313. + if (activeChar.isOlympiadProtection())
  8314. + {
  8315. + activeChar.sendMessage("Are you participating in the Olympiad..");
  8316. + return;
  8317. + }
  8318. + activeChar.teleToLocation(ArenaConfig.Tournament_locx + Rnd.get(-100, 100), ArenaConfig.Tournament_locy + Rnd.get(-100, 100), ArenaConfig.Tournament_locz);
  8319. + activeChar.setTournamentTeleport(true);
  8320. + }
  8321. else if (_command.startsWith("returnboss"))
  8322. {
  8323. VoicedBossSpawn.showChatWindow(activeChar);
  8324. diff --git a/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java b/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java
  8325. index 978dec1..b0bc99a 100644
  8326. --- a/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java
  8327. +++ b/head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java
  8328. @@ -40,6 +40,8 @@
  8329. import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  8330. import com.l2jfrozen.gameserver.taskmanager.AttackStanceTaskManager;
  8331.  
  8332. +import Dev.Tournament.properties.ArenaTask;
  8333. +
  8334. public final class RequestRestart extends L2GameClientPacket
  8335. {
  8336. private static Logger LOGGER = Logger.getLogger(RequestRestart.class);
  8337. @@ -61,7 +63,13 @@
  8338. LOGGER.warn("[RequestRestart] activeChar null!?");
  8339. return;
  8340. }
  8341. -
  8342. + if ((player.isInArenaEvent() || player.isArenaProtection()) && ArenaTask.is_started())
  8343. + {
  8344. + player.sendMessage("You cannot restart while in Tournament Event!");
  8345. + player.sendPacket(ActionFailed.STATIC_PACKET);
  8346. + sendPacket(RestartResponse.valueOf(false));
  8347. + return;
  8348. + }
  8349. // Check if player is enchanting
  8350. if (player.getActiveEnchantItem() != null)
  8351. {
  8352. diff --git a/head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java b/head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
  8353. index bf89edd..41e32ed 100644
  8354. --- a/head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
  8355. +++ b/head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
  8356. @@ -168,7 +168,11 @@
  8357. return;
  8358. }
  8359. }
  8360. -
  8361. + if (activeChar.isInArenaEvent() && !activeChar.isArenaAttack())
  8362. + {
  8363. + activeChar.sendMessage("Wait for the battle to begin..");
  8364. + return;
  8365. + }
  8366. if (!getClient().getFloodProtectors().getSayAction().tryPerformAction("Say2"))
  8367. {
  8368. activeChar.sendMessage("You cannot speak too fast.");
  8369. diff --git a/head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java b/head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java
  8370. index abe77fc..9e90c97 100644
  8371. --- a/head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java
  8372. +++ b/head-src/com/l2jfrozen/gameserver/network/clientpackets/UseItem.java
  8373. @@ -51,6 +51,8 @@
  8374. import com.l2jfrozen.gameserver.templates.L2WeaponType;
  8375. import com.l2jfrozen.gameserver.util.Util;
  8376.  
  8377. +import Dev.Tournament.properties.ArenaConfig;
  8378. +
  8379. public final class UseItem extends L2GameClientPacket
  8380. {
  8381. private static Logger LOGGER = Logger.getLogger(UseItem.class);
  8382. @@ -293,7 +295,15 @@
  8383. {
  8384. LOGGER.debug(activeChar.getObjectId() + ": use item " + _objectId);
  8385. }
  8386. -
  8387. + if (activeChar.isInArenaEvent() || activeChar.isArenaProtection())
  8388. + {
  8389. + if (ArenaConfig.TOURNAMENT_LISTID_RESTRICT.contains(item.getItemId()))
  8390. + {
  8391. + activeChar.sendMessage("You can not use this item during Tournament Event.");
  8392. + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  8393. + return;
  8394. + }
  8395. + }
  8396. if (item.isEquipable())
  8397. {
  8398. // No unequipping/equipping while the player is in special conditions
  8399. diff --git a/head-src/com/l2jfrozen/gameserver/network/serverpackets/Die.java b/head-src/com/l2jfrozen/gameserver/network/serverpackets/Die.java
  8400. index 7e637b1..2ee48af 100644
  8401. --- a/head-src/com/l2jfrozen/gameserver/network/serverpackets/Die.java
  8402. +++ b/head-src/com/l2jfrozen/gameserver/network/serverpackets/Die.java
  8403. @@ -60,7 +60,7 @@
  8404. final L2PcInstance player = (L2PcInstance) cha;
  8405. _access = player.getAccessLevel();
  8406. _clan = player.getClan();
  8407. - _canTeleport = !((TvT.is_started() && player._inEventTvT) || (DM.is_started() && player._inEventDM) || (CTF.is_started() && player._inEventCTF) || player.isInFunEvent() || player.isPendingRevive());
  8408. + _canTeleport = !((TvT.is_started() && player._inEventTvT) || (DM.is_started() && player._inEventDM) || (CTF.is_started() && player._inEventCTF) || player.isInFunEvent() || player.isPendingRevive() || cha.isInArenaEvent());
  8409. }
  8410. _charObjId = cha.getObjectId();
  8411. _fake = !cha.isDead();
  8412. diff --git a/head-src/com/l2jfrozen/gameserver/network/serverpackets/ExShowScreenMessage.java b/head-src/com/l2jfrozen/gameserver/network/serverpackets/ExShowScreenMessage.java
  8413. index 96df2c9..d000935 100644
  8414. --- a/head-src/com/l2jfrozen/gameserver/network/serverpackets/ExShowScreenMessage.java
  8415. +++ b/head-src/com/l2jfrozen/gameserver/network/serverpackets/ExShowScreenMessage.java
  8416. @@ -1,46 +1,43 @@
  8417. -/*
  8418. - * L2jFrozen Project - www.l2jfrozen.com
  8419. - *
  8420. - * This program is free software: you can redistribute it and/or modify it under
  8421. - * the terms of the GNU General Public License as published by the Free Software
  8422. - * Foundation, either version 3 of the License, or (at your option) any later
  8423. - * version.
  8424. - *
  8425. - * This program is distributed in the hope that it will be useful, but WITHOUT
  8426. - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8427. - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  8428. - * details.
  8429. - *
  8430. - * You should have received a copy of the GNU General Public License along with
  8431. - * this program. If not, see <http://www.gnu.org/licenses/>.
  8432. - */
  8433. package com.l2jfrozen.gameserver.network.serverpackets;
  8434.  
  8435. /**
  8436. - * @author Kerberos
  8437. + * @author glory to Setekh for IL opcode ;p
  8438. */
  8439. public class ExShowScreenMessage extends L2GameServerPacket
  8440. {
  8441. + public static enum SMPOS
  8442. + {
  8443. + DUMMY,
  8444. + TOP_LEFT,
  8445. + TOP_CENTER,
  8446. + TOP_RIGHT,
  8447. + MIDDLE_LEFT,
  8448. + MIDDLE_CENTER,
  8449. + MIDDLE_RIGHT,
  8450. + BOTTOM_CENTER,
  8451. + BOTTOM_RIGHT,
  8452. + }
  8453. +
  8454. private final int _type;
  8455. private final int _sysMessageId;
  8456. - private final int _unk1;
  8457. + private final boolean _hide;
  8458. private final int _unk2;
  8459. private final int _unk3;
  8460. - private final int _unk4;
  8461. + private final boolean _fade;
  8462. private final int _size;
  8463. private final int _position;
  8464. private final boolean _effect;
  8465. private final String _text;
  8466. private final int _time;
  8467.  
  8468. - public ExShowScreenMessage(final String text, final int time)
  8469. + public ExShowScreenMessage(String text, int time)
  8470. {
  8471. _type = 1;
  8472. _sysMessageId = -1;
  8473. - _unk1 = 0;
  8474. + _hide = false;
  8475. _unk2 = 0;
  8476. _unk3 = 0;
  8477. - _unk4 = 0;
  8478. + _fade = false;
  8479. _position = 0x02;
  8480. _text = text;
  8481. _time = time;
  8482. @@ -48,14 +45,34 @@
  8483. _effect = false;
  8484. }
  8485.  
  8486. - public ExShowScreenMessage(final int type, final int messageId, final int position, final int unk1, final int size, final int unk2, final int unk3, final boolean showEffect, final int time, final int unk4, final String text)
  8487. + public ExShowScreenMessage(String text, int time, SMPOS pos, boolean effect)
  8488. + {
  8489. + this(text, time, pos.ordinal(), effect);
  8490. + }
  8491. +
  8492. + public ExShowScreenMessage(String text, int time, int pos, boolean effect)
  8493. + {
  8494. + _type = 1;
  8495. + _sysMessageId = -1;
  8496. + _hide = false;
  8497. + _unk2 = 0;
  8498. + _unk3 = 0;
  8499. + _fade = false;
  8500. + _position = pos;
  8501. + _text = text;
  8502. + _time = time;
  8503. + _size = 0;
  8504. + _effect = effect;
  8505. + }
  8506. +
  8507. + public ExShowScreenMessage(int type, int messageId, int position, boolean hide, int size, int unk2, int unk3, boolean showEffect, int time, boolean fade, String text)
  8508. {
  8509. _type = type;
  8510. _sysMessageId = messageId;
  8511. - _unk1 = unk1;
  8512. + _hide = hide;
  8513. _unk2 = unk2;
  8514. _unk3 = unk3;
  8515. - _unk4 = unk4;
  8516. + _fade = fade;
  8517. _position = position;
  8518. _text = text;
  8519. _time = time;
  8520. @@ -64,12 +81,6 @@
  8521. }
  8522.  
  8523. @Override
  8524. - public String getType()
  8525. - {
  8526. - return "[S]FE:39 ExShowScreenMessage";
  8527. - }
  8528. -
  8529. - @Override
  8530. protected void writeImpl()
  8531. {
  8532. writeC(0xfe);
  8533. @@ -77,13 +88,22 @@
  8534. writeD(_type); // 0 - system messages, 1 - your defined text
  8535. writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect)
  8536. writeD(_position); // message position
  8537. - writeD(_unk1); // ?
  8538. + writeD(_hide ? 1 : 0); // hide
  8539. writeD(_size); // font size 0 - normal, 1 - small
  8540. writeD(_unk2); // ?
  8541. writeD(_unk3); // ?
  8542. writeD(_effect ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect
  8543. writeD(_time); // time
  8544. - writeD(_unk4); // ?
  8545. + writeD(_fade ? 1 : 0); // fade effect (0 - disabled, 1 enabled)
  8546. writeS(_text); // your text (_type must be 1, otherwise no effect)
  8547. }
  8548. +
  8549. + /* (non-Javadoc)
  8550. + * @see com.l2jfrozen.gameserver.network.serverpackets.L2GameServerPacket#getType()
  8551. + */
  8552. + @Override
  8553. + public String getType()
  8554. + {
  8555. + return "[S]FE:39 ExShowScreenMessage";
  8556. + }
  8557. }
  8558. \ No newline at end of file
  8559.  
Add Comment
Please, Sign In to add comment