Advertisement
Reanimation06

L2jMobius C6 Interlude TVT Event

Feb 10th, 2024
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 177.90 KB | Gaming | 0 0
  1. diff --git a/L2J_Mobius_C6_Interlude/.gitignore b/L2J_Mobius_C6_Interlude/.gitignore
  2. new file mode 100644
  3. index 0000000..ae3c172
  4. --- /dev/null
  5. +++ b/L2J_Mobius_C6_Interlude/.gitignore
  6. @@ -0,0 +1 @@
  7. +/bin/
  8. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java
  9. index 407ede2..2fdc23c 100644
  10. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java
  11. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java
  12. @@ -112,6 +112,7 @@
  13.     private static final String PHYSICS_BALANCE_CONFIG_FILE = "./config/custom/PhysicsBalance.ini";
  14.     private static final String SCHEME_BUFFER_CONFIG_FILE = "./config/custom/SchemeBuffer.ini";
  15.     private static final String STARTING_LOCATION_CONFIG_FILE = "./config/custom/StartingLocation.ini";
  16. +   private static final String EVENT_TVT_CONFIG_FILE = "./config/custom/TvTEvents.ini";
  17.    
  18.     private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
  19.     private static final String HEXID_FILE = "./config/hexid.txt";
  20. @@ -1154,6 +1155,29 @@
  21.     public static boolean ACCEPT_NEW_GAMESERVER;
  22.     public static boolean AUTO_CREATE_ACCOUNTS;
  23.    
  24. +   public static String TVT_EVEN_TEAMS;
  25. +   public static boolean TVT_ALLOW_INTERFERENCE;
  26. +   public static boolean TVT_ALLOW_POTIONS;
  27. +   public static boolean TVT_ALLOW_SUMMON;
  28. +   public static boolean TVT_ON_START_REMOVE_ALL_EFFECTS;
  29. +   public static boolean TVT_ON_START_UNSUMMON_PET;
  30. +   public static boolean TVT_REVIVE_RECOVERY;
  31. +   public static boolean TVT_ANNOUNCE_TEAM_STATS;
  32. +   public static boolean TVT_ANNOUNCE_REWARD;
  33. +   public static boolean TVT_PRICE_NO_KILLS;
  34. +   public static boolean TVT_JOIN_CURSED;
  35. +   public static boolean TVT_COMMAND;
  36. +   public static long TVT_REVIVE_DELAY;
  37. +   public static boolean TVT_OPEN_FORT_DOORS;
  38. +   public static boolean TVT_CLOSE_FORT_DOORS;
  39. +   public static boolean TVT_OPEN_ADEN_COLOSSEUM_DOORS;
  40. +   public static boolean TVT_CLOSE_ADEN_COLOSSEUM_DOORS;
  41. +   public static int TVT_TOP_KILLER_REWARD;
  42. +   public static int TVT_TOP_KILLER_QTY;
  43. +   public static boolean TVT_AURA;
  44. +   public static boolean TVT_STATS_LOGGER;
  45. +   public static boolean TVT_REMOVE_BUFFS_ON_DIE;
  46. +  
  47.     public static boolean ENABLE_GUI;
  48.     public static boolean DARK_THEME;
  49.    
  50. @@ -2879,6 +2903,37 @@
  51.         ENABLE_EXP_GAIN_COMMANDS = characterConfig.getBoolean("EnableExpGainCommands", false);
  52.     }
  53.    
  54. +   public static void loadTVTConfig()
  55. +   {
  56. +       final PropertiesParser tvtConfig = new PropertiesParser(EVENT_TVT_CONFIG_FILE);
  57. +       TVT_EVEN_TEAMS = tvtConfig.getString("TvTEvenTeams", "BALANCE");
  58. +       TVT_ALLOW_INTERFERENCE = tvtConfig.getBoolean("TvTAllowInterference", false);
  59. +       TVT_ALLOW_POTIONS = tvtConfig.getBoolean("TvTAllowPotions", false);
  60. +       TVT_ALLOW_SUMMON = tvtConfig.getBoolean("TvTAllowSummon", false);
  61. +       TVT_ON_START_REMOVE_ALL_EFFECTS = tvtConfig.getBoolean("TvTOnStartRemoveAllEffects", true);
  62. +       TVT_ON_START_UNSUMMON_PET = tvtConfig.getBoolean("TvTOnStartUnsummonPet", true);
  63. +       TVT_REVIVE_RECOVERY = tvtConfig.getBoolean("TvTReviveRecovery", false);
  64. +       TVT_ANNOUNCE_TEAM_STATS = tvtConfig.getBoolean("TvTAnnounceTeamStats", false);
  65. +       TVT_ANNOUNCE_REWARD = tvtConfig.getBoolean("TvTAnnounceReward", false);
  66. +       TVT_PRICE_NO_KILLS = tvtConfig.getBoolean("TvTPriceNoKills", false);
  67. +       TVT_JOIN_CURSED = tvtConfig.getBoolean("TvTJoinWithCursedWeapon", true);
  68. +       TVT_COMMAND = tvtConfig.getBoolean("TvTCommand", true);
  69. +       TVT_REVIVE_DELAY = tvtConfig.getLong("TvTReviveDelay", 20000);
  70. +       if (TVT_REVIVE_DELAY < 1000)
  71. +       {
  72. +           TVT_REVIVE_DELAY = 1000; // can't be set less then 1 second
  73. +       }
  74. +       TVT_OPEN_FORT_DOORS = tvtConfig.getBoolean("TvTOpenFortDoors", false);
  75. +       TVT_CLOSE_FORT_DOORS = tvtConfig.getBoolean("TvTCloseFortDoors", false);
  76. +       TVT_OPEN_ADEN_COLOSSEUM_DOORS = tvtConfig.getBoolean("TvTOpenAdenColosseumDoors", false);
  77. +       TVT_CLOSE_ADEN_COLOSSEUM_DOORS = tvtConfig.getBoolean("TvTCloseAdenColosseumDoors", false);
  78. +       TVT_TOP_KILLER_REWARD = tvtConfig.getInt("TvTTopKillerRewardId", 5575);
  79. +       TVT_TOP_KILLER_QTY = tvtConfig.getInt("TvTTopKillerRewardQty", 2000000);
  80. +       TVT_AURA = tvtConfig.getBoolean("TvTAura", false);
  81. +       TVT_STATS_LOGGER = tvtConfig.getBoolean("TvTStatsLogger", true);
  82. +       TVT_REMOVE_BUFFS_ON_DIE = tvtConfig.getBoolean("TvTRemoveBuffsOnPlayerDie", false);
  83. +   }
  84. +  
  85.     /**
  86.      * Loads all Filter Words
  87.      */
  88. @@ -3079,6 +3134,7 @@
  89.             loadOlympConfig();
  90.             loadEnchantConfig();
  91.             loadBossConfig();
  92. +           loadTVTConfig();
  93.            
  94.             // Head functions
  95.             loadCustomServerConfig();
  96. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
  97. index 0aff7d1..f2c5091 100644
  98. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
  99. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
  100. @@ -106,6 +106,7 @@
  101.  import org.l2jmobius.gameserver.instancemanager.ServerRestartManager;
  102.  import org.l2jmobius.gameserver.instancemanager.SiegeManager;
  103.  import org.l2jmobius.gameserver.instancemanager.TradeManager;
  104. +import org.l2jmobius.gameserver.instancemanager.events.EventManager;
  105.  import org.l2jmobius.gameserver.instancemanager.events.PcPoint;
  106.  import org.l2jmobius.gameserver.instancemanager.games.Lottery;
  107.  import org.l2jmobius.gameserver.instancemanager.games.MonsterRace;
  108. @@ -402,6 +403,22 @@
  109.             CoupleManager.getInstance();
  110.         }
  111.        
  112. +       printSection("EventManager");
  113. +       EventManager.getInstance().startEventRegistration();
  114. +      
  115. +       if (EventManager.TVT_EVENT_ENABLED)
  116. +       {
  117. +           if (EventManager.TVT_EVENT_ENABLED)
  118. +           {
  119. +               LOGGER.info("TVT Event is Enabled.");
  120. +           }
  121. +          
  122. +       }
  123. +       else
  124. +       {
  125. +           LOGGER.info("All events are Disabled.");
  126. +       }
  127. +      
  128.         if (Config.PCB_ENABLE)
  129.         {
  130.             ThreadPool.scheduleAtFixedRate(PcPoint.getInstance(), Config.PCB_INTERVAL * 1000, Config.PCB_INTERVAL * 1000);
  131. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AdminCommandHandler.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AdminCommandHandler.java
  132. index 7c1d9da..573f86c 100644
  133. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AdminCommandHandler.java
  134. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/AdminCommandHandler.java
  135. @@ -81,6 +81,7 @@
  136.  import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminTarget;
  137.  import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminTeleport;
  138.  import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminTest;
  139. +import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminTvTEngine;
  140.  import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminZone;
  141.  
  142.  /**
  143. @@ -157,6 +158,7 @@
  144.         registerAdminCommandHandler(new AdminTeleport());
  145.         registerAdminCommandHandler(new AdminTest());
  146.         registerAdminCommandHandler(new AdminZone());
  147. +       registerAdminCommandHandler(new AdminTvTEngine());
  148.        
  149.         LOGGER.info("AdminCommandHandler: Loaded " + _datatable.size() + " handlers.");
  150.     }
  151. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/VoicedCommandHandler.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/VoicedCommandHandler.java
  152. index 466e2a6..53d5171 100644
  153. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/VoicedCommandHandler.java
  154. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/VoicedCommandHandler.java
  155. @@ -29,6 +29,7 @@
  156.  import org.l2jmobius.gameserver.handler.voicedcommandhandlers.OfflineShop;
  157.  import org.l2jmobius.gameserver.handler.voicedcommandhandlers.Online;
  158.  import org.l2jmobius.gameserver.handler.voicedcommandhandlers.StatsCmd;
  159. +import org.l2jmobius.gameserver.handler.voicedcommandhandlers.TvTCmd;
  160.  import org.l2jmobius.gameserver.handler.voicedcommandhandlers.VoiceCommand;
  161.  import org.l2jmobius.gameserver.handler.voicedcommandhandlers.Wedding;
  162.  
  163. @@ -89,6 +90,11 @@
  164.             registerVoicedCommandHandler(new AutoPotion());
  165.         }
  166.        
  167. +       if (Config.TVT_COMMAND)
  168. +       {
  169. +           registerVoicedCommandHandler(new TvTCmd());
  170. +       }
  171. +      
  172.         LOGGER.info("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers.");
  173.     }
  174.    
  175. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTvTEngine.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTvTEngine.java
  176. new file mode 100644
  177. index 0000000..0970af3
  178. --- /dev/null
  179. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/admincommandhandlers/AdminTvTEngine.java
  180. @@ -0,0 +1,474 @@
  181. +/*
  182. + * This file is part of the L2J Mobius project.
  183. + *
  184. + * This program is free software: you can redistribute it and/or modify
  185. + * it under the terms of the GNU General Public License as published by
  186. + * the Free Software Foundation, either version 3 of the License, or
  187. + * (at your option) any later version.
  188. + *
  189. + * This program is distributed in the hope that it will be useful,
  190. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  191. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  192. + * General Public License for more details.
  193. + *
  194. + * You should have received a copy of the GNU General Public License
  195. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  196. + */
  197. +package org.l2jmobius.gameserver.handler.admincommandhandlers;
  198. +
  199. +import java.util.StringTokenizer;
  200. +
  201. +import org.l2jmobius.Config;
  202. +import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
  203. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  204. +import org.l2jmobius.gameserver.model.Location;
  205. +import org.l2jmobius.gameserver.model.World;
  206. +import org.l2jmobius.gameserver.model.actor.Player;
  207. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  208. +import org.l2jmobius.gameserver.util.BuilderUtil;
  209. +
  210. +public class AdminTvTEngine implements IAdminCommandHandler
  211. +{
  212. +   private static final String[] ADMIN_COMMANDS =
  213. +   {
  214. +       "admin_tvt",
  215. +       "admin_tvt_name",
  216. +       "admin_tvt_desc",
  217. +       "admin_tvt_join_loc",
  218. +       "admin_tvt_minLevel",
  219. +       "admin_tvt_maxLevel",
  220. +       "admin_tvt_npc",
  221. +       "admin_tvt_npc_pos",
  222. +       "admin_tvt_reward",
  223. +       "admin_tvt_reward_amount",
  224. +       "admin_tvt_team_add",
  225. +       "admin_tvt_team_remove",
  226. +       "admin_tvt_team_pos",
  227. +       "admin_tvt_team_color",
  228. +       "admin_tvt_join",
  229. +       "admin_tvt_teleport",
  230. +       "admin_tvt_start",
  231. +       "admin_tvt_abort",
  232. +       "admin_tvt_finish",
  233. +       "admin_tvt_sit",
  234. +       "admin_tvt_dump",
  235. +       "admin_tvt_save",
  236. +       "admin_tvt_load",
  237. +       "admin_tvt_jointime",
  238. +       "admin_tvt_eventtime",
  239. +       "admin_tvt_autoevent",
  240. +       "admin_tvt_startevent",
  241. +       "admin_tvt_minplayers",
  242. +       "admin_tvt_maxplayers",
  243. +       "admin_tvtkick",
  244. +       "admin_tvt_interval"
  245. +   };
  246. +  
  247. +   @Override
  248. +   public boolean useAdminCommand(String command, Player activeChar)
  249. +   {
  250. +       if (command.equals("admin_tvt"))
  251. +       {
  252. +           showMainPage(activeChar);
  253. +       }
  254. +       else if (command.startsWith("admin_tvt_name "))
  255. +       {
  256. +           if (TvT.setEventName(command.substring(15)))
  257. +           {
  258. +               showMainPage(activeChar);
  259. +           }
  260. +           else
  261. +           {
  262. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  263. +           }
  264. +       }
  265. +       else if (command.startsWith("admin_tvt_desc "))
  266. +       {
  267. +           if (TvT.setEventDesc(command.substring(15)))
  268. +           {
  269. +               showMainPage(activeChar);
  270. +           }
  271. +           else
  272. +           {
  273. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  274. +           }
  275. +       }
  276. +       else if (command.startsWith("admin_tvt_minLevel "))
  277. +       {
  278. +           if (!TvT.checkMinLevel(Integer.parseInt(command.substring(17))))
  279. +           {
  280. +               return false;
  281. +           }
  282. +          
  283. +           if (TvT.setMinlvl(Integer.parseInt(command.substring(17))))
  284. +           {
  285. +               showMainPage(activeChar);
  286. +           }
  287. +           else
  288. +           {
  289. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  290. +           }
  291. +       }
  292. +       else if (command.startsWith("admin_tvt_maxLevel "))
  293. +       {
  294. +           if (!TvT.checkMaxLevel(Integer.parseInt(command.substring(17))))
  295. +           {
  296. +               return false;
  297. +           }
  298. +          
  299. +           if (TvT.setMaxlvl(Integer.parseInt(command.substring(17))))
  300. +           {
  301. +               showMainPage(activeChar);
  302. +           }
  303. +           else
  304. +           {
  305. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  306. +           }
  307. +       }
  308. +       else if (command.startsWith("admin_tvt_minplayers "))
  309. +       {
  310. +           if (TvT.setMinPlayers(Integer.parseInt(command.substring(21))))
  311. +           {
  312. +               showMainPage(activeChar);
  313. +           }
  314. +           else
  315. +           {
  316. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  317. +           }
  318. +       }
  319. +       else if (command.startsWith("admin_tvt_maxplayers "))
  320. +       {
  321. +           if (TvT.setMaxPlayers(Integer.parseInt(command.substring(21))))
  322. +           {
  323. +               showMainPage(activeChar);
  324. +           }
  325. +           else
  326. +           {
  327. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  328. +           }
  329. +       }
  330. +       else if (command.startsWith("admin_tvt_join_loc "))
  331. +       {
  332. +           if (TvT.setJoiningLocationName(command.substring(19)))
  333. +           {
  334. +               showMainPage(activeChar);
  335. +           }
  336. +           else
  337. +           {
  338. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  339. +           }
  340. +       }
  341. +       else if (command.startsWith("admin_tvt_npc "))
  342. +       {
  343. +           if (TvT.setNpcId(Integer.parseInt(command.substring(14))))
  344. +           {
  345. +               showMainPage(activeChar);
  346. +           }
  347. +           else
  348. +           {
  349. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  350. +           }
  351. +       }
  352. +       else if (command.equals("admin_tvt_npc_pos"))
  353. +       {
  354. +           TvT.setNpcPos(activeChar);
  355. +           showMainPage(activeChar);
  356. +       }
  357. +       else if (command.startsWith("admin_tvt_reward "))
  358. +       {
  359. +           if (TvT.setRewardId(Integer.parseInt(command.substring(17))))
  360. +           {
  361. +               showMainPage(activeChar);
  362. +           }
  363. +           else
  364. +           {
  365. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  366. +           }
  367. +       }
  368. +       else if (command.startsWith("admin_tvt_reward_amount "))
  369. +       {
  370. +           if (TvT.setRewardAmount(Integer.parseInt(command.substring(24))))
  371. +           {
  372. +               showMainPage(activeChar);
  373. +           }
  374. +           else
  375. +           {
  376. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  377. +           }
  378. +       }
  379. +       else if (command.startsWith("admin_tvt_jointime "))
  380. +       {
  381. +           if (TvT.setJoinTime(Integer.parseInt(command.substring(19))))
  382. +           {
  383. +               showMainPage(activeChar);
  384. +           }
  385. +           else
  386. +           {
  387. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  388. +           }
  389. +       }
  390. +       else if (command.startsWith("admin_tvt_eventtime "))
  391. +       {
  392. +           if (TvT.setEventTime(Integer.parseInt(command.substring(20))))
  393. +           {
  394. +               showMainPage(activeChar);
  395. +           }
  396. +           else
  397. +           {
  398. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  399. +           }
  400. +       }
  401. +       else if (command.startsWith("admin_tvt_interval "))
  402. +       {
  403. +           if (TvT.setIntervalBetweenMatches(Integer.parseInt(command.substring(20))))
  404. +           {
  405. +               showMainPage(activeChar);
  406. +           }
  407. +           else
  408. +           {
  409. +               BuilderUtil.sendSysMessage(activeChar, "Cannot perform requested operation, event in progress");
  410. +           }
  411. +       }
  412. +       else if (command.startsWith("admin_tvt_team_add "))
  413. +       {
  414. +           final String teamName = command.substring(19);
  415. +           TvT.addTeam(teamName);
  416. +           showMainPage(activeChar);
  417. +       }
  418. +       else if (command.startsWith("admin_tvt_team_remove "))
  419. +       {
  420. +           final String teamName = command.substring(22);
  421. +           TvT.removeTeam(teamName);
  422. +           showMainPage(activeChar);
  423. +       }
  424. +       else if (command.startsWith("admin_tvt_team_pos "))
  425. +       {
  426. +           final String teamName = command.substring(19);
  427. +           TvT.setTeamPos(teamName, activeChar);
  428. +           showMainPage(activeChar);
  429. +       }
  430. +       else if (command.startsWith("admin_tvt_team_color "))
  431. +       {
  432. +           String[] params;
  433. +           params = command.split(" ");
  434. +           if (params.length != 3)
  435. +           {
  436. +               BuilderUtil.sendSysMessage(activeChar, "Wrong usege: //tvt_team_color <colorHex> <teamName>");
  437. +               return false;
  438. +           }
  439. +          
  440. +           TvT.setTeamColor(command.substring(params[0].length() + params[1].length() + 2), Integer.decode("0x" + params[1]));
  441. +           showMainPage(activeChar);
  442. +       }
  443. +       else if (command.equals("admin_tvt_join"))
  444. +       {
  445. +           if (TvT.startJoin())
  446. +           {
  447. +               showMainPage(activeChar);
  448. +           }
  449. +           else
  450. +           {
  451. +               BuilderUtil.sendSysMessage(activeChar, "Cannot startJoin, check LOGGER for info..");
  452. +           }
  453. +       }
  454. +       else if (command.equals("admin_tvt_teleport"))
  455. +       {
  456. +           TvT.startTeleport();
  457. +           showMainPage(activeChar);
  458. +       }
  459. +       else if (command.equals("admin_tvt_start"))
  460. +       {
  461. +           if (TvT.startEvent())
  462. +           {
  463. +               showMainPage(activeChar);
  464. +           }
  465. +           else
  466. +           {
  467. +               BuilderUtil.sendSysMessage(activeChar, "Cannot startEvent, check LOGGER for info..");
  468. +           }
  469. +       }
  470. +       else if (command.equals("admin_tvt_startevent"))
  471. +       {
  472. +           TvT.eventOnceStart();
  473. +           showMainPage(activeChar);
  474. +       }
  475. +       else if (command.equals("admin_tvt_abort"))
  476. +       {
  477. +           BuilderUtil.sendSysMessage(activeChar, "Aborting event");
  478. +           TvT.abortEvent();
  479. +           showMainPage(activeChar);
  480. +       }
  481. +       else if (command.equals("admin_tvt_finish"))
  482. +       {
  483. +           TvT.finishEvent();
  484. +           showMainPage(activeChar);
  485. +       }
  486. +       else if (command.equals("admin_tvt_sit"))
  487. +       {
  488. +           TvT.sit();
  489. +           showMainPage(activeChar);
  490. +       }
  491. +       else if (command.equals("admin_tvt_load"))
  492. +       {
  493. +           TvT.loadData();
  494. +           showMainPage(activeChar);
  495. +       }
  496. +       else if (command.equals("admin_tvt_autoevent"))
  497. +       {
  498. +           if ((TvT.getJoinTime() > 0) && (TvT.getEventTime() > 0))
  499. +           {
  500. +               TvT.autoEvent();
  501. +           }
  502. +           else
  503. +           {
  504. +               BuilderUtil.sendSysMessage(activeChar, "Wrong usege: join time or event time invalid.");
  505. +           }
  506. +          
  507. +           showMainPage(activeChar);
  508. +       }
  509. +       else if (command.equals("admin_tvt_save"))
  510. +       {
  511. +           TvT.saveData();
  512. +           showMainPage(activeChar);
  513. +       }
  514. +       else if (command.equals("admin_tvt_dump"))
  515. +       {
  516. +           TvT.dumpData();
  517. +       }
  518. +       else if (command.startsWith("admin_tvtkick"))
  519. +       {
  520. +           final StringTokenizer st = new StringTokenizer(command);
  521. +           if (st.countTokens() > 1)
  522. +           {
  523. +               st.nextToken();
  524. +               final String plyr = st.nextToken();
  525. +               final Player playerToKick = World.getInstance().getPlayer(plyr);
  526. +               if (playerToKick != null)
  527. +               {
  528. +                   TvT.kickPlayerFromTvt(playerToKick);
  529. +                   BuilderUtil.sendSysMessage(activeChar, "You kicked " + playerToKick.getName() + " from the TvT.");
  530. +               }
  531. +               else
  532. +               {
  533. +                   BuilderUtil.sendSysMessage(activeChar, "Wrong usege: //tvtkick <player>");
  534. +               }
  535. +           }
  536. +       }
  537. +       return true;
  538. +   }
  539. +  
  540. +   @Override
  541. +   public String[] getAdminCommandList()
  542. +   {
  543. +       return ADMIN_COMMANDS;
  544. +   }
  545. +  
  546. +   public void showMainPage(Player activeChar)
  547. +   {
  548. +       final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  549. +       final StringBuilder replyMSG = new StringBuilder("<html><title>Team vs Team</title><body>");
  550. +       replyMSG.append("<center><font color=\"LEVEL\">[TvT Engine]</font></center><br><br><br>");
  551. +       replyMSG.append("<table><tr><td><edit var=\"input1\" width=\"125\"></td><td><edit var=\"input2\" width=\"125\"></td></tr></table>");
  552. +       replyMSG.append("<table border=\"0\"><tr>");
  553. +       replyMSG.append("<td width=\"100\"><button value=\"Name\" action=\"bypass -h admin_tvt_name $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  554. +       replyMSG.append("<td width=\"100\"><button value=\"Description\" action=\"bypass -h admin_tvt_desc $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  555. +       replyMSG.append("<td width=\"100\"><button value=\"Join Location\" action=\"bypass -h admin_tvt_join_loc $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  556. +       replyMSG.append("</tr></table><br><table><tr>");
  557. +       replyMSG.append("</tr></table><br><table><tr>");
  558. +       replyMSG.append("<td width=\"100\"><button value=\"Max lvl\" action=\"bypass -h admin_tvt_maxLevel $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  559. +       replyMSG.append("<td width=\"100\"><button value=\"Min lvl\" action=\"bypass -h admin_tvt_minLevel $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  560. +       replyMSG.append("</tr></table><br><table><tr>");
  561. +       replyMSG.append("</tr></table><br><table><tr>");
  562. +       replyMSG.append("<td width=\"100\"><button value=\"Max players\" action=\"bypass -h admin_tvt_maxplayers $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  563. +       replyMSG.append("<td width=\"100\"><button value=\"Min players\" action=\"bypass -h admin_tvt_minplayers $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  564. +       replyMSG.append("</tr></table><br><table><tr>");
  565. +       replyMSG.append("<td width=\"100\"><button value=\"NPC\" action=\"bypass -h admin_tvt_npc $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  566. +       replyMSG.append("<td width=\"100\"><button value=\"NPC Pos\" action=\"bypass -h admin_tvt_npc_pos\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  567. +       replyMSG.append("</tr></table><br><table><tr>");
  568. +       replyMSG.append("<td width=\"100\"><button value=\"Reward\" action=\"bypass -h admin_tvt_reward $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  569. +       replyMSG.append("<td width=\"100\"><button value=\"Reward Amount\" action=\"bypass -h admin_tvt_reward_amount $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  570. +       replyMSG.append("</tr></table><br><table><tr>");
  571. +       replyMSG.append("<td width=\"100\"><button value=\"Join Time\" action=\"bypass -h admin_tvt_jointime $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  572. +       replyMSG.append("<td width=\"100\"><button value=\"Event Time\" action=\"bypass -h admin_tvt_eventtime $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  573. +       replyMSG.append("<td width=\"100\"><button value=\"Interval Time\" action=\"bypass -h admin_tvt_interval $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  574. +       replyMSG.append("</tr></table><br><table><tr>");
  575. +       replyMSG.append("<td width=\"100\"><button value=\"Team Add\" action=\"bypass -h admin_tvt_team_add $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  576. +       replyMSG.append("<td width=\"100\"><button value=\"Team Color\" action=\"bypass -h admin_tvt_team_color $input1 $input2\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  577. +       replyMSG.append("<td width=\"100\"><button value=\"Team Pos\" action=\"bypass -h admin_tvt_team_pos $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  578. +       replyMSG.append("</tr></table><table><tr>");
  579. +       replyMSG.append("<td width=\"100\"><button value=\"Team Remove\" action=\"bypass -h admin_tvt_team_remove $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  580. +       replyMSG.append("</tr></table><br><table><tr>");
  581. +       replyMSG.append("<td width=\"100\"><button value=\"Join\" action=\"bypass -h admin_tvt_join\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  582. +       replyMSG.append("<td width=\"100\"><button value=\"Teleport\" action=\"bypass -h admin_tvt_teleport\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  583. +       replyMSG.append("<td width=\"100\"><button value=\"Start\" action=\"bypass -h admin_tvt_start\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  584. +       replyMSG.append("</tr></table><table><tr>");
  585. +       replyMSG.append("</tr></table><table><tr>");
  586. +       replyMSG.append("<td width=\"100\"><button value=\"StartEventOnceTime\" action=\"bypass -h admin_tvt_startevent\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  587. +       replyMSG.append("</tr></table><br><table><tr>");
  588. +       replyMSG.append("<td width=\"100\"><button value=\"Abort\" action=\"bypass -h admin_tvt_abort\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  589. +       replyMSG.append("<td width=\"100\"><button value=\"Finish\" action=\"bypass -h admin_tvt_finish\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  590. +       replyMSG.append("</tr></table><br><table><tr>");
  591. +       replyMSG.append("<td width=\"100\"><button value=\"Sit Force\" action=\"bypass -h admin_tvt_sit\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  592. +       replyMSG.append("<td width=\"100\"><button value=\"Dump\" action=\"bypass -h admin_tvt_dump\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  593. +       replyMSG.append("</tr></table><br><br><table><tr>");
  594. +       replyMSG.append("<td width=\"100\"><button value=\"Save\" action=\"bypass -h admin_tvt_save\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  595. +       replyMSG.append("<td width=\"100\"><button value=\"Load\" action=\"bypass -h admin_tvt_load\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  596. +       replyMSG.append("<td width=\"100\"><button value=\"Auto Event\" action=\"bypass -h admin_tvt_autoevent\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
  597. +       replyMSG.append("</tr></table><br><br>");
  598. +       replyMSG.append("Current event:<br1>");
  599. +       replyMSG.append("Name:&nbsp;<font color=\"00FF00\">" + TvT.getEventName() + "</font><br1>");
  600. +       replyMSG.append("Description:&nbsp;<font color=\"00FF00\">" + TvT.getEventDesc() + "</font><br1>");
  601. +       replyMSG.append("Joining location name:&nbsp;<font color=\"00FF00\">" + TvT.getJoiningLocationName() + "</font><br1>");
  602. +      
  603. +       final Location npcLoc = TvT.getNpcLocation();
  604. +       replyMSG.append("Joining NPC ID:&nbsp;<font color=\"00FF00\">" + TvT.getNpcId() + " on pos " + npcLoc.getX() + "," + npcLoc.getY() + "," + npcLoc.getZ() + "</font><br1>");
  605. +       replyMSG.append("Reward ID:&nbsp;<font color=\"00FF00\">" + TvT.getRewardId() + "</font><br1>");
  606. +       replyMSG.append("Reward Amount:&nbsp;<font color=\"00FF00\">" + TvT.getRewardAmount() + "</font><br><br>");
  607. +       replyMSG.append("Min lvl:&nbsp;<font color=\"00FF00\">" + TvT.getMinLevel() + "</font><br>");
  608. +       replyMSG.append("Max lvl:&nbsp;<font color=\"00FF00\">" + TvT.getMaxLevel() + "</font><br><br>");
  609. +       replyMSG.append("Min Players:&nbsp;<font color=\"00FF00\">" + TvT.getMinPlayers() + "</font><br>");
  610. +       replyMSG.append("Max Players:&nbsp;<font color=\"00FF00\">" + TvT.getMaxPlayers() + "</font><br><br>");
  611. +       replyMSG.append("Joining Time:&nbsp;<font color=\"00FF00\">" + TvT.getJoinTime() + "</font><br>");
  612. +       replyMSG.append("Event Timer:&nbsp;<font color=\"00FF00\">" + TvT.getEventTime() + "</font><br><br>");
  613. +       replyMSG.append("Interval Time:&nbsp;<font color=\"00FF00\">" + TvT.getIntervalBetweenMatches() + "</font><br><br>");
  614. +       replyMSG.append("Current teams:<br1>");
  615. +       replyMSG.append("<center><table border=\"0\">");
  616. +       for (String team : TvT._teams)
  617. +       {
  618. +           replyMSG.append("<tr><td width=\"100\"><font color=\"LEVEL\">" + team + "</font>");
  619. +           if (Config.TVT_EVEN_TEAMS.equals("NO") || Config.TVT_EVEN_TEAMS.equals("BALANCE"))
  620. +           {
  621. +               replyMSG.append("&nbsp;(" + TvT.teamPlayersCount(team) + " joined)");
  622. +           }
  623. +           else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  624. +           {
  625. +               if (TvT.isTeleport() || TvT.isStarted())
  626. +               {
  627. +                   replyMSG.append("&nbsp;(" + TvT.teamPlayersCount(team) + " in)");
  628. +               }
  629. +           }
  630. +          
  631. +           replyMSG.append("</td></tr><tr><td>");
  632. +           replyMSG.append(TvT._teamColors.get(TvT._teams.indexOf(team)));
  633. +           replyMSG.append("</td></tr><tr><td>");
  634. +           replyMSG.append(TvT._teamsX.get(TvT._teams.indexOf(team)) + ", " + TvT._teamsY.get(TvT._teams.indexOf(team)) + ", " + TvT._teamsZ.get(TvT._teams.indexOf(team)));
  635. +           replyMSG.append("</td></tr><tr><td width=\"60\"><button value=\"Remove\" action=\"bypass -h admin_tvt_team_remove " + team + "\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
  636. +       }
  637. +      
  638. +       replyMSG.append("</table></center>");
  639. +      
  640. +       if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  641. +       {
  642. +           if (!TvT.isStarted())
  643. +           {
  644. +               replyMSG.append("<br1>");
  645. +               replyMSG.append(TvT._playersShuffle.size() + " players participating. Waiting to shuffle in teams(done on teleport)!");
  646. +               replyMSG.append("<br><br>");
  647. +           }
  648. +       }
  649. +      
  650. +       replyMSG.append("</body></html>");
  651. +       adminReply.setHtml(replyMSG.toString());
  652. +       activeChar.sendPacket(adminReply);
  653. +   }
  654. +}
  655. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/itemhandlers/Potions.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/itemhandlers/Potions.java
  656. index 424c1cc..67e95ad 100644
  657. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/itemhandlers/Potions.java
  658. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/itemhandlers/Potions.java
  659. @@ -28,6 +28,7 @@
  660.  import org.l2jmobius.gameserver.data.ItemTable;
  661.  import org.l2jmobius.gameserver.data.SkillTable;
  662.  import org.l2jmobius.gameserver.handler.IItemHandler;
  663. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  664.  import org.l2jmobius.gameserver.model.Skill;
  665.  import org.l2jmobius.gameserver.model.actor.Playable;
  666.  import org.l2jmobius.gameserver.model.actor.Player;
  667. @@ -37,6 +38,7 @@
  668.  import org.l2jmobius.gameserver.model.effects.EffectType;
  669.  import org.l2jmobius.gameserver.model.item.instance.Item;
  670.  import org.l2jmobius.gameserver.network.SystemMessageId;
  671. +import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
  672.  import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
  673.  
  674.  public class Potions implements IItemHandler
  675. @@ -203,6 +205,11 @@
  676.         {
  677.             Player activeChar;
  678.             activeChar = (Player) playable;
  679. +           if (activeChar._inEventTvT && TvT.isStarted() && !Config.TVT_ALLOW_POTIONS)
  680. +           {
  681. +               activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  682. +               return;
  683. +           }
  684.             if (activeChar.isInOlympiadMode())
  685.             {
  686.                 activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_ITEM_IN_A_GRAND_OLYMPIAD_GAMES_MATCH);
  687. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Recall.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Recall.java
  688. index 316d52d..ab9f3f6 100644
  689. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Recall.java
  690. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Recall.java
  691. @@ -21,6 +21,7 @@
  692.  import org.l2jmobius.gameserver.enums.TeleportWhereType;
  693.  import org.l2jmobius.gameserver.handler.ISkillHandler;
  694.  import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
  695. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  696.  import org.l2jmobius.gameserver.model.Skill;
  697.  import org.l2jmobius.gameserver.model.actor.Creature;
  698.  import org.l2jmobius.gameserver.model.actor.Player;
  699. @@ -86,6 +87,11 @@
  700.                         targetChar.sendMessage("You can't use escape skill in an event.");
  701.                         continue;
  702.                     }
  703. +                   if ((targetChar._inEventTvT && TvT.isStarted()))
  704. +                   {
  705. +                       targetChar.sendMessage("You can't use escape skill in Event.");
  706. +                       continue;
  707. +                   }
  708.                    
  709.                     if (targetChar.isInJail())
  710.                     {
  711. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/usercommandhandlers/Escape.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/usercommandhandlers/Escape.java
  712. index 1ccf17c..df14c97 100644
  713. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/usercommandhandlers/Escape.java
  714. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/usercommandhandlers/Escape.java
  715. @@ -22,6 +22,7 @@
  716.  import org.l2jmobius.gameserver.enums.TeleportWhereType;
  717.  import org.l2jmobius.gameserver.handler.IUserCommandHandler;
  718.  import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
  719. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  720.  import org.l2jmobius.gameserver.model.actor.Player;
  721.  import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
  722.  import org.l2jmobius.gameserver.network.serverpackets.SetupGauge;
  723. @@ -46,7 +47,12 @@
  724.             player.sendMessage("You may not use an escape command in a festival.");
  725.             return false;
  726.         }
  727. -      
  728. +       // Check to see if the current player is in TVT Event.
  729. +       if (player._inEventTvT && TvT.isStarted())
  730. +       {
  731. +           player.sendMessage("You may not use an escape skill in TvT.");
  732. +           return false;
  733. +       }
  734.         // Check to see if the current player is in an event.
  735.         if (player.isOnEvent())
  736.         {
  737. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/TvTCmd.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/TvTCmd.java
  738. new file mode 100644
  739. index 0000000..2650121
  740. --- /dev/null
  741. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/TvTCmd.java
  742. @@ -0,0 +1,179 @@
  743. +/*
  744. + * This file is part of the L2J Mobius project.
  745. + *
  746. + * This program is free software: you can redistribute it and/or modify
  747. + * it under the terms of the GNU General Public License as published by
  748. + * the Free Software Foundation, either version 3 of the License, or
  749. + * (at your option) any later version.
  750. + *
  751. + * This program is distributed in the hope that it will be useful,
  752. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  753. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  754. + * General Public License for more details.
  755. + *
  756. + * You should have received a copy of the GNU General Public License
  757. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  758. + */
  759. +package org.l2jmobius.gameserver.handler.voicedcommandhandlers;
  760. +
  761. +import org.l2jmobius.gameserver.data.ItemTable;
  762. +import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
  763. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  764. +import org.l2jmobius.gameserver.model.actor.Player;
  765. +
  766. +public class TvTCmd implements IVoicedCommandHandler
  767. +{
  768. +   private static final String[] VOICED_COMMANDS =
  769. +   {
  770. +       "tvtjoin",
  771. +       "tvtleave",
  772. +       "tvtinfo"
  773. +   };
  774. +  
  775. +   @Override
  776. +   public boolean useVoicedCommand(String command, Player activeChar, String target)
  777. +   {
  778. +       if (command.startsWith("tvtjoin"))
  779. +       {
  780. +           JoinTvT(activeChar);
  781. +       }
  782. +       else if (command.startsWith("tvtleave"))
  783. +       {
  784. +           LeaveTvT(activeChar);
  785. +       }
  786. +      
  787. +       else if (command.startsWith("tvtinfo"))
  788. +       {
  789. +           TvTinfo(activeChar);
  790. +       }
  791. +      
  792. +       return true;
  793. +   }
  794. +  
  795. +   @Override
  796. +   public String[] getVoicedCommandList()
  797. +   {
  798. +       return VOICED_COMMANDS;
  799. +   }
  800. +  
  801. +   public boolean JoinTvT(Player activeChar)
  802. +   {
  803. +       if (activeChar == null)
  804. +       {
  805. +           return false;
  806. +       }
  807. +      
  808. +       if (!TvT.isJoining())
  809. +       {
  810. +           activeChar.sendMessage("There is no TvT Event in progress.");
  811. +           return false;
  812. +       }
  813. +       else if (TvT.isJoining() && activeChar._inEventTvT)
  814. +       {
  815. +           activeChar.sendMessage("You are already registered.");
  816. +           return false;
  817. +       }
  818. +       else if (activeChar.isCursedWeaponEquipped())
  819. +       {
  820. +           activeChar.sendMessage("You are not allowed to participate to the event because you are holding a Cursed Weapon.");
  821. +           return false;
  822. +       }
  823. +       else if (activeChar.isInOlympiadMode())
  824. +       {
  825. +           activeChar.sendMessage("You are not allowed to participate to the event because you are in Olympiad.");
  826. +           return false;
  827. +       }
  828. +       else if (activeChar.getLevel() < TvT.getMinLevel())
  829. +       {
  830. +           activeChar.sendMessage("You are not allowed to participate to the event because your level is too low.");
  831. +           return false;
  832. +       }
  833. +       else if (activeChar.getLevel() > TvT.getMaxLevel())
  834. +       {
  835. +           activeChar.sendMessage("You are not allowed to participate to the event because your level is too high.");
  836. +           return false;
  837. +       }
  838. +       else if (activeChar.getKarma() > 0)
  839. +       {
  840. +           activeChar.sendMessage("You are not allowed to participate to the event because you have Karma.");
  841. +           return false;
  842. +       }
  843. +       else if (TvT.isTeleport() || TvT.isStarted())
  844. +       {
  845. +           activeChar.sendMessage("TvT Event registration period is over. You can't register now.");
  846. +           return false;
  847. +       }
  848. +       else
  849. +       {
  850. +           activeChar.sendMessage("Your participation in the TvT event has been approved.");
  851. +           TvT.addPlayer(activeChar, "");
  852. +           return false;
  853. +       }
  854. +   }
  855. +  
  856. +   public boolean LeaveTvT(Player activeChar)
  857. +   {
  858. +       if (activeChar == null)
  859. +       {
  860. +           return false;
  861. +       }
  862. +      
  863. +       if (!TvT.isJoining())
  864. +       {
  865. +           activeChar.sendMessage("There is no TvT Event in progress.");
  866. +           return false;
  867. +       }
  868. +       else if ((TvT.isTeleport() || TvT.isStarted()) && activeChar._inEventTvT)
  869. +       {
  870. +           activeChar.sendMessage("You can not leave now because TvT event has started.");
  871. +           return false;
  872. +       }
  873. +       else if (TvT.isJoining() && !activeChar._inEventTvT)
  874. +       {
  875. +           activeChar.sendMessage("You aren't registered in the TvT Event.");
  876. +           return false;
  877. +       }
  878. +       else
  879. +       {
  880. +           TvT.removePlayer(activeChar);
  881. +           return true;
  882. +       }
  883. +   }
  884. +  
  885. +   public boolean TvTinfo(Player activeChar)
  886. +   {
  887. +       if (activeChar == null)
  888. +       {
  889. +           return false;
  890. +       }
  891. +      
  892. +       if (!TvT.isJoining())
  893. +       {
  894. +           activeChar.sendMessage("There is no TvT Event in progress.");
  895. +           return false;
  896. +       }
  897. +       else if (TvT.isTeleport() || TvT.isStarted())
  898. +       {
  899. +           activeChar.sendMessage("I can't provide you this info. Command available only in joining period.");
  900. +           return false;
  901. +       }
  902. +       else
  903. +       {
  904. +           if (TvT._playersShuffle.size() == 1)
  905. +           {
  906. +               activeChar.sendMessage("There is " + TvT._playersShuffle.size() + " player participating in this event.");
  907. +               activeChar.sendMessage("Reward: " + TvT.getRewardAmount() + " " + ItemTable.getInstance().getTemplate(TvT.getRewardId()).getName() + " !");
  908. +               activeChar.sendMessage("Player Min lvl: " + TvT.getMinLevel() + ".");
  909. +               activeChar.sendMessage("Player Max lvl: " + TvT.getMaxLevel() + ".");
  910. +           }
  911. +           else
  912. +           {
  913. +               activeChar.sendMessage("There are " + TvT._playersShuffle.size() + " players participating in this event.");
  914. +               activeChar.sendMessage("Reward: " + TvT.getRewardAmount() + " " + ItemTable.getInstance().getTemplate(TvT.getRewardId()).getName() + " !");
  915. +               activeChar.sendMessage("Player Min lvl: " + TvT.getMinLevel() + ".");
  916. +               activeChar.sendMessage("Player Max lvl: " + TvT.getMaxLevel() + ".");
  917. +           }
  918. +           return true;
  919. +       }
  920. +   }
  921. +}
  922. \ No newline at end of file
  923. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/Wedding.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/Wedding.java
  924. index 2dcc812..4cd7c7c 100644
  925. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/Wedding.java
  926. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/Wedding.java
  927. @@ -26,6 +26,7 @@
  928.  import org.l2jmobius.gameserver.instancemanager.CastleManager;
  929.  import org.l2jmobius.gameserver.instancemanager.CoupleManager;
  930.  import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
  931. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  932.  import org.l2jmobius.gameserver.model.Skill;
  933.  import org.l2jmobius.gameserver.model.World;
  934.  import org.l2jmobius.gameserver.model.actor.Player;
  935. @@ -263,6 +264,11 @@
  936.             activeChar.sendMessage("Your partner is in the Olympiad now.");
  937.             return false;
  938.         }
  939. +       if (activeChar._inEventTvT && TvT.isStarted())
  940. +       {
  941. +           activeChar.sendMessage("You may not use go to love in TvT.");
  942. +           return false;
  943. +       }
  944.         else if (partner.isOnEvent())
  945.         {
  946.             activeChar.sendMessage("Your partner is in an event.");
  947. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/EventManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/EventManager.java
  948. new file mode 100644
  949. index 0000000..ec5c32e
  950. --- /dev/null
  951. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/EventManager.java
  952. @@ -0,0 +1,143 @@
  953. +/*
  954. + * This file is part of the L2J Mobius project.
  955. + *
  956. + * This program is free software: you can redistribute it and/or modify
  957. + * it under the terms of the GNU General Public License as published by
  958. + * the Free Software Foundation, either version 3 of the License, or
  959. + * (at your option) any later version.
  960. + *
  961. + * This program is distributed in the hope that it will be useful,
  962. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  963. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  964. + * General Public License for more details.
  965. + *
  966. + * You should have received a copy of the GNU General Public License
  967. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  968. + */
  969. +package org.l2jmobius.gameserver.instancemanager.events;
  970. +
  971. +import java.io.File;
  972. +import java.io.FileInputStream;
  973. +import java.io.IOException;
  974. +import java.io.InputStream;
  975. +import java.util.ArrayList;
  976. +import java.util.List;
  977. +import java.util.Properties;
  978. +import java.util.logging.Logger;
  979. +
  980. +/**
  981. + * @author Shyla
  982. + */
  983. +public class EventManager
  984. +{
  985. +   protected static final Logger LOGGER = Logger.getLogger(EventManager.class.getName());
  986. +  
  987. +   private static final String EVENT_MANAGER_CONFIGURATION_FILE = "./config/custom/EventManager.ini";
  988. +  
  989. +   public static boolean TVT_EVENT_ENABLED;
  990. +   public static List<String> TVT_TIMES_LIST;
  991. +  
  992. +   public static boolean CTF_EVENT_ENABLED;
  993. +   public static List<String> CTF_TIMES_LIST;
  994. +  
  995. +   public static boolean DM_EVENT_ENABLED;
  996. +   public static List<String> DM_TIMES_LIST;
  997. +  
  998. +   private static EventManager instance = null;
  999. +  
  1000. +   private EventManager()
  1001. +   {
  1002. +       loadConfiguration();
  1003. +   }
  1004. +  
  1005. +   public static EventManager getInstance()
  1006. +   {
  1007. +       if (instance == null)
  1008. +       {
  1009. +           instance = new EventManager();
  1010. +       }
  1011. +       return instance;
  1012. +   }
  1013. +  
  1014. +   public static void loadConfiguration()
  1015. +   {
  1016. +       InputStream is = null;
  1017. +       try
  1018. +       {
  1019. +           final Properties eventSettings = new Properties();
  1020. +           is = new FileInputStream(new File(EVENT_MANAGER_CONFIGURATION_FILE));
  1021. +           eventSettings.load(is);
  1022. +          
  1023. +           TVT_EVENT_ENABLED = Boolean.parseBoolean(eventSettings.getProperty("TVTEventEnabled", "false"));
  1024. +           TVT_TIMES_LIST = new ArrayList<>();
  1025. +           String[] propertySplit;
  1026. +           propertySplit = eventSettings.getProperty("TVTStartTime", "").split(";");
  1027. +           for (String time : propertySplit)
  1028. +           {
  1029. +               TVT_TIMES_LIST.add(time);
  1030. +           }
  1031. +          
  1032. +           CTF_EVENT_ENABLED = Boolean.parseBoolean(eventSettings.getProperty("CTFEventEnabled", "false"));
  1033. +           CTF_TIMES_LIST = new ArrayList<>();
  1034. +           propertySplit = eventSettings.getProperty("CTFStartTime", "").split(";");
  1035. +           for (String time : propertySplit)
  1036. +           {
  1037. +               CTF_TIMES_LIST.add(time);
  1038. +           }
  1039. +          
  1040. +           DM_EVENT_ENABLED = Boolean.parseBoolean(eventSettings.getProperty("DMEventEnabled", "false"));
  1041. +           DM_TIMES_LIST = new ArrayList<>();
  1042. +           propertySplit = eventSettings.getProperty("DMStartTime", "").split(";");
  1043. +           for (String time : propertySplit)
  1044. +           {
  1045. +               DM_TIMES_LIST.add(time);
  1046. +           }
  1047. +       }
  1048. +       catch (Exception e)
  1049. +       {
  1050. +           LOGGER.warning(e.toString());
  1051. +       }
  1052. +       finally
  1053. +       {
  1054. +           if (is != null)
  1055. +           {
  1056. +               try
  1057. +               {
  1058. +                   is.close();
  1059. +               }
  1060. +               catch (IOException e)
  1061. +               {
  1062. +                   LOGGER.warning(e.toString());
  1063. +               }
  1064. +           }
  1065. +       }
  1066. +   }
  1067. +  
  1068. +   public void startEventRegistration()
  1069. +   {
  1070. +       if (TVT_EVENT_ENABLED)
  1071. +       {
  1072. +           registerTvT();
  1073. +       }
  1074. +      
  1075. +   }
  1076. +  
  1077. +   private void registerTvT()
  1078. +   {
  1079. +       TvT.loadData();
  1080. +       if (!TvT.checkStartJoinOk())
  1081. +       {
  1082. +           LOGGER.warning("registerTvT: TvT Event is not setted Properly");
  1083. +       }
  1084. +      
  1085. +       EventsGlobalTask.getInstance().clearEventTasksByEventName(TvT.getEventName());
  1086. +      
  1087. +       for (String time : TVT_TIMES_LIST)
  1088. +       {
  1089. +           final TvT newInstance = TvT.getNewInstance();
  1090. +           newInstance.setEventStartTime(time);
  1091. +           EventsGlobalTask.getInstance().registerNewEventTask(newInstance);
  1092. +       }
  1093. +   }
  1094. +  
  1095. +}
  1096. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java
  1097. new file mode 100644
  1098. index 0000000..f2c080f
  1099. --- /dev/null
  1100. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java
  1101. @@ -0,0 +1,358 @@
  1102. +/*
  1103. + * This file is part of the L2J Mobius project.
  1104. + *
  1105. + * This program is free software: you can redistribute it and/or modify
  1106. + * it under the terms of the GNU General Public License as published by
  1107. + * the Free Software Foundation, either version 3 of the License, or
  1108. + * (at your option) any later version.
  1109. + *
  1110. + * This program is distributed in the hope that it will be useful,
  1111. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1112. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1113. + * General Public License for more details.
  1114. + *
  1115. + * You should have received a copy of the GNU General Public License
  1116. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1117. + */
  1118. +package org.l2jmobius.gameserver.instancemanager.events;
  1119. +
  1120. +import java.io.BufferedInputStream;
  1121. +import java.io.BufferedReader;
  1122. +import java.io.DataInputStream;
  1123. +import java.io.FileInputStream;
  1124. +import java.io.InputStreamReader;
  1125. +import java.util.Iterator;
  1126. +import java.util.LinkedList;
  1127. +import java.util.List;
  1128. +import java.util.Map;
  1129. +import java.util.concurrent.ConcurrentHashMap;
  1130. +import java.util.logging.Logger;
  1131. +
  1132. +import org.l2jmobius.gameserver.data.sql.NpcTable;
  1133. +import org.l2jmobius.gameserver.data.sql.SpawnTable;
  1134. +import org.l2jmobius.gameserver.enums.ChatType;
  1135. +import org.l2jmobius.gameserver.model.World;
  1136. +import org.l2jmobius.gameserver.model.actor.Player;
  1137. +import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
  1138. +import org.l2jmobius.gameserver.model.spawn.Spawn;
  1139. +import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
  1140. +import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
  1141. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  1142. +import org.l2jmobius.gameserver.util.EventData;
  1143. +
  1144. +public class GameEvent
  1145. +{
  1146. +   protected static final Logger LOGGER = Logger.getLogger(GameEvent.class.getName());
  1147. +  
  1148. +   public static final Map<Integer, LinkedList<String>> players = new ConcurrentHashMap<>();
  1149. +   public static final Map<String, EventData> connectionLossData = new ConcurrentHashMap<>();
  1150. +   public static final Map<Integer, String> names = new ConcurrentHashMap<>();
  1151. +   public static final List<String> participatingPlayers = new LinkedList<>();
  1152. +   public static final List<String> npcs = new LinkedList<>();
  1153. +   public static String eventName = "";
  1154. +   public static int teamsNumber = 0;
  1155. +   public static boolean active = false;
  1156. +   public static int id = 12760;
  1157. +  
  1158. +   public static int getTeamOfPlayer(String name)
  1159. +   {
  1160. +       for (int i = 1; i <= players.size(); i++)
  1161. +       {
  1162. +           final LinkedList<String> temp = players.get(i);
  1163. +           final Iterator<String> it = temp.iterator();
  1164. +          
  1165. +           while (it.hasNext())
  1166. +           {
  1167. +               if (it.next().equals(name))
  1168. +               {
  1169. +                   return i;
  1170. +               }
  1171. +           }
  1172. +       }
  1173. +       return 0;
  1174. +   }
  1175. +  
  1176. +   public static String[] getTopNKillers(int n)
  1177. +   {
  1178. +       // this will return top N players sorted by kills, first element in the array will be the one with more kills
  1179. +       final String[] killers = new String[n];
  1180. +       String playerTemp = "";
  1181. +       int kills = 0;
  1182. +      
  1183. +       final LinkedList<String> killersTemp = new LinkedList<>();
  1184. +       for (int k = 0; k < n; k++)
  1185. +       {
  1186. +           kills = 0;
  1187. +           for (int i = 1; i <= teamsNumber; i++)
  1188. +           {
  1189. +               final LinkedList<String> temp = players.get(i);
  1190. +               final Iterator<String> it = temp.iterator();
  1191. +              
  1192. +               while (it.hasNext())
  1193. +               {
  1194. +                   try
  1195. +                   {
  1196. +                       final Player player = World.getInstance().getPlayer(it.next());
  1197. +                       if (!killersTemp.contains(player.getName()) && (player.kills.size() > kills))
  1198. +                       {
  1199. +                           kills = player.kills.size();
  1200. +                           playerTemp = player.getName();
  1201. +                       }
  1202. +                   }
  1203. +                   catch (Exception e)
  1204. +                   {
  1205. +                   }
  1206. +               }
  1207. +           }
  1208. +          
  1209. +           killersTemp.add(playerTemp);
  1210. +       }
  1211. +      
  1212. +       for (int i = 0; i < n; i++)
  1213. +       {
  1214. +           kills = 0;
  1215. +           final Iterator<String> it = killersTemp.iterator();
  1216. +          
  1217. +           while (it.hasNext())
  1218. +           {
  1219. +               try
  1220. +               {
  1221. +                   final Player player = World.getInstance().getPlayer(it.next());
  1222. +                   if (player.kills.size() > kills)
  1223. +                   {
  1224. +                       kills = player.kills.size();
  1225. +                       playerTemp = player.getName();
  1226. +                   }
  1227. +               }
  1228. +               catch (Exception e)
  1229. +               {
  1230. +               }
  1231. +           }
  1232. +          
  1233. +           killers[i] = playerTemp;
  1234. +           killersTemp.remove(playerTemp);
  1235. +       }
  1236. +      
  1237. +       return killers;
  1238. +   }
  1239. +  
  1240. +   public static void showEventHtml(Player player, String objectid)
  1241. +   {
  1242. +       FileInputStream fis = null;
  1243. +       BufferedInputStream buff = null;
  1244. +       DataInputStream in = null;
  1245. +       InputStreamReader isr = null;
  1246. +       BufferedReader inbr = null;
  1247. +      
  1248. +       try
  1249. +       {
  1250. +           final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  1251. +           fis = new FileInputStream("data/events/" + eventName);
  1252. +           buff = new BufferedInputStream(fis);
  1253. +           in = new DataInputStream(buff);
  1254. +           isr = new InputStreamReader(in);
  1255. +           inbr = new BufferedReader(isr);
  1256. +          
  1257. +           final StringBuilder replyMSG = new StringBuilder("<html><body>");
  1258. +           replyMSG.append("<center><font color=\"LEVEL\">" + eventName + "</font><font color=\"FF0000\"> bY " + inbr.readLine() + "</font></center><br>");
  1259. +           replyMSG.append("<br>" + inbr.readLine());
  1260. +           if (participatingPlayers.contains(player.getName()))
  1261. +           {
  1262. +               replyMSG.append("<br><center>You are already in the event players list !!</center></body></html>");
  1263. +           }
  1264. +           else
  1265. +           {
  1266. +               replyMSG.append("<br><center><button value=\"Participate !! \" action=\"bypass -h npc_" + objectid + "_event_participate\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
  1267. +           }
  1268. +          
  1269. +           adminReply.setHtml(replyMSG.toString());
  1270. +           player.sendPacket(adminReply);
  1271. +       }
  1272. +       catch (Exception e)
  1273. +       {
  1274. +           LOGGER.warning(e.getMessage());
  1275. +       }
  1276. +       finally
  1277. +       {
  1278. +           if (inbr != null)
  1279. +           {
  1280. +               try
  1281. +               {
  1282. +                   inbr.close();
  1283. +               }
  1284. +               catch (Exception e1)
  1285. +               {
  1286. +                   LOGGER.warning(e1.toString());
  1287. +               }
  1288. +           }
  1289. +          
  1290. +           if (isr != null)
  1291. +           {
  1292. +               try
  1293. +               {
  1294. +                   isr.close();
  1295. +               }
  1296. +               catch (Exception e1)
  1297. +               {
  1298. +                   LOGGER.warning(e1.toString());
  1299. +               }
  1300. +           }
  1301. +          
  1302. +           if (in != null)
  1303. +           {
  1304. +               try
  1305. +               {
  1306. +                   in.close();
  1307. +               }
  1308. +               catch (Exception e1)
  1309. +               {
  1310. +                   LOGGER.warning(e1.toString());
  1311. +               }
  1312. +           }
  1313. +          
  1314. +           if (buff != null)
  1315. +           {
  1316. +               try
  1317. +               {
  1318. +                   buff.close();
  1319. +               }
  1320. +               catch (Exception e1)
  1321. +               {
  1322. +                   LOGGER.warning(e1.toString());
  1323. +               }
  1324. +           }
  1325. +          
  1326. +           if (fis != null)
  1327. +           {
  1328. +               try
  1329. +               {
  1330. +                   fis.close();
  1331. +               }
  1332. +               catch (Exception e1)
  1333. +               {
  1334. +                   LOGGER.warning(e1.toString());
  1335. +               }
  1336. +           }
  1337. +       }
  1338. +   }
  1339. +  
  1340. +   public static void spawn(Player target, int npcid)
  1341. +   {
  1342. +       final NpcTemplate template1 = NpcTable.getInstance().getTemplate(npcid);
  1343. +      
  1344. +       try
  1345. +       {
  1346. +           final Spawn spawn = new Spawn(template1);
  1347. +           spawn.setX(target.getX() + 50);
  1348. +           spawn.setY(target.getY() + 50);
  1349. +           spawn.setZ(target.getZ());
  1350. +           spawn.setAmount(1);
  1351. +           spawn.setHeading(target.getHeading());
  1352. +           spawn.setRespawnDelay(1);
  1353. +          
  1354. +           SpawnTable.getInstance().addNewSpawn(spawn, false);
  1355. +           spawn.init();
  1356. +           spawn.getLastSpawn().getStatus().setCurrentHp(999999999);
  1357. +           spawn.getLastSpawn().setName("event inscriptor");
  1358. +           spawn.getLastSpawn().setTitle(eventName);
  1359. +           spawn.getLastSpawn().isEventMob = true;
  1360. +           spawn.getLastSpawn().isAggressive();
  1361. +           spawn.getLastSpawn().decayMe();
  1362. +           spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
  1363. +           spawn.getLastSpawn().broadcastPacket(new MagicSkillUse(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
  1364. +           npcs.add(String.valueOf(spawn.getLastSpawn().getObjectId()));
  1365. +       }
  1366. +       catch (Exception e)
  1367. +       {
  1368. +           LOGGER.warning(e.getMessage());
  1369. +       }
  1370. +   }
  1371. +  
  1372. +   public static void announceAllPlayers(String text)
  1373. +   {
  1374. +       final CreatureSay cs = new CreatureSay(0, ChatType.ANNOUNCEMENT, "", text);
  1375. +       for (Player player : World.getInstance().getAllPlayers())
  1376. +       {
  1377. +           player.sendPacket(cs);
  1378. +       }
  1379. +   }
  1380. +  
  1381. +   public static boolean isOnEvent(Player player)
  1382. +   {
  1383. +       for (int k = 0; k < teamsNumber; k++)
  1384. +       {
  1385. +           final Iterator<String> it = players.get(k + 1).iterator();
  1386. +           boolean temp = false;
  1387. +          
  1388. +           while (it.hasNext())
  1389. +           {
  1390. +               temp = player.getName().equalsIgnoreCase(it.next());
  1391. +               if (temp)
  1392. +               {
  1393. +                   return true;
  1394. +               }
  1395. +           }
  1396. +       }
  1397. +       return false;
  1398. +   }
  1399. +  
  1400. +   public static void inscribePlayer(Player player)
  1401. +   {
  1402. +       try
  1403. +       {
  1404. +           participatingPlayers.add(player.getName());
  1405. +           player.eventKarma = player.getKarma();
  1406. +           player.eventX = player.getX();
  1407. +           player.eventY = player.getY();
  1408. +           player.eventZ = player.getZ();
  1409. +           player.eventPkKills = player.getPkKills();
  1410. +           player.eventPvpKills = player.getPvpKills();
  1411. +           player.eventTitle = player.getTitle();
  1412. +           player.kills.clear();
  1413. +           player.atEvent = true;
  1414. +       }
  1415. +       catch (Exception e)
  1416. +       {
  1417. +           LOGGER.warning("error when signing in the event:" + e.getMessage());
  1418. +       }
  1419. +   }
  1420. +  
  1421. +   public static void restoreChar(Player player)
  1422. +   {
  1423. +       try
  1424. +       {
  1425. +           player.eventX = connectionLossData.get(player.getName()).eventX;
  1426. +           player.eventY = connectionLossData.get(player.getName()).eventY;
  1427. +           player.eventZ = connectionLossData.get(player.getName()).eventZ;
  1428. +           player.eventKarma = connectionLossData.get(player.getName()).eventKarma;
  1429. +           player.eventPvpKills = connectionLossData.get(player.getName()).eventPvpKills;
  1430. +           player.eventPkKills = connectionLossData.get(player.getName()).eventPkKills;
  1431. +           player.eventTitle = connectionLossData.get(player.getName()).eventTitle;
  1432. +           player.kills = connectionLossData.get(player.getName()).kills;
  1433. +           player.eventSitForced = connectionLossData.get(player.getName()).eventSitForced;
  1434. +           player.atEvent = true;
  1435. +       }
  1436. +       catch (Exception e)
  1437. +       {
  1438. +       }
  1439. +   }
  1440. +  
  1441. +   public static void restoreAndTeleChar(Player target)
  1442. +   {
  1443. +       try
  1444. +       {
  1445. +           restoreChar(target);
  1446. +           target.setTitle(target.eventTitle);
  1447. +           target.setKarma(target.eventKarma);
  1448. +           target.setPvpKills(target.eventPvpKills);
  1449. +           target.setPkKills(target.eventPkKills);
  1450. +           target.teleToLocation(target.eventX, target.eventY, target.eventZ);
  1451. +           target.kills.clear();
  1452. +           target.eventSitForced = false;
  1453. +           target.atEvent = false;
  1454. +       }
  1455. +       catch (Exception e)
  1456. +       {
  1457. +       }
  1458. +   }
  1459. +}
  1460. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java
  1461. new file mode 100644
  1462. index 0000000..16a7eef
  1463. --- /dev/null
  1464. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/events/TvT.java
  1465. @@ -0,0 +1,2770 @@
  1466. +/*
  1467. + * This file is part of the L2J Mobius project.
  1468. + *
  1469. + * This program is free software: you can redistribute it and/or modify
  1470. + * it under the terms of the GNU General Public License as published by
  1471. + * the Free Software Foundation, either version 3 of the License, or
  1472. + * (at your option) any later version.
  1473. + *
  1474. + * This program is distributed in the hope that it will be useful,
  1475. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1476. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1477. + * General Public License for more details.
  1478. + *
  1479. + * You should have received a copy of the GNU General Public License
  1480. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1481. + */
  1482. +package org.l2jmobius.gameserver.instancemanager.events;
  1483. +
  1484. +import java.sql.Connection;
  1485. +import java.sql.PreparedStatement;
  1486. +import java.sql.ResultSet;
  1487. +import java.util.ArrayList;
  1488. +import java.util.List;
  1489. +import java.util.logging.Logger;
  1490. +
  1491. +import org.l2jmobius.Config;
  1492. +import org.l2jmobius.commons.database.DatabaseFactory;
  1493. +import org.l2jmobius.commons.threads.ThreadPool;
  1494. +import org.l2jmobius.commons.util.Rnd;
  1495. +import org.l2jmobius.gameserver.data.ItemTable;
  1496. +import org.l2jmobius.gameserver.data.SkillTable;
  1497. +import org.l2jmobius.gameserver.data.sql.AnnouncementsTable;
  1498. +import org.l2jmobius.gameserver.data.sql.NpcTable;
  1499. +import org.l2jmobius.gameserver.data.sql.SpawnTable;
  1500. +import org.l2jmobius.gameserver.data.xml.DoorData;
  1501. +import org.l2jmobius.gameserver.instancemanager.CastleManager;
  1502. +import org.l2jmobius.gameserver.model.Location;
  1503. +import org.l2jmobius.gameserver.model.Party;
  1504. +import org.l2jmobius.gameserver.model.World;
  1505. +import org.l2jmobius.gameserver.model.actor.Player;
  1506. +import org.l2jmobius.gameserver.model.actor.Summon;
  1507. +import org.l2jmobius.gameserver.model.actor.instance.Pet;
  1508. +import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
  1509. +import org.l2jmobius.gameserver.model.olympiad.Olympiad;
  1510. +import org.l2jmobius.gameserver.model.siege.Castle;
  1511. +import org.l2jmobius.gameserver.model.spawn.Spawn;
  1512. +import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
  1513. +import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
  1514. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  1515. +import org.l2jmobius.gameserver.network.serverpackets.Ride;
  1516. +import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
  1517. +
  1518. +public class TvT implements EventTask
  1519. +{
  1520. +   protected static final Logger LOGGER = Logger.getLogger(TvT.class.getName());
  1521. +  
  1522. +   protected static String _eventName = "";
  1523. +   protected static String _eventDesc = "";
  1524. +   protected static String _joiningLocationName = "";
  1525. +   private static Spawn _npcSpawn;
  1526. +   protected static boolean _joining = false;
  1527. +   protected static boolean _teleport = false;
  1528. +   protected static boolean _started = false;
  1529. +   protected static boolean _aborted = false;
  1530. +   protected static boolean _sitForced = false;
  1531. +   protected static boolean _inProgress = false;
  1532. +   protected static int _npcId = 0;
  1533. +   protected static int _npcX = 0;
  1534. +   protected static int _npcY = 0;
  1535. +   protected static int _npcZ = 0;
  1536. +   protected static int _npcHeading = 0;
  1537. +   protected static int _rewardId = 0;
  1538. +   protected static int _rewardAmount = 0;
  1539. +   protected static int _minLevel = 0;
  1540. +   protected static int _maxLevel = 0;
  1541. +   protected static int _joinTime = 0;
  1542. +   protected static int _eventTime = 0;
  1543. +   protected static int _minPlayers = 0;
  1544. +   protected static int _maxPlayers = 0;
  1545. +   protected static long _intervalBetweenMatches = 0;
  1546. +   private String startEventTime;
  1547. +   private static boolean _teamEvent = true; // TODO to be integrated
  1548. +   public static List<Player> _players = new ArrayList<>();
  1549. +   private static String _topTeam = "";
  1550. +   public static List<Player> _playersShuffle = new ArrayList<>();
  1551. +   public static List<String> _teams = new ArrayList<>();
  1552. +   public static List<String> _savePlayers = new ArrayList<>();
  1553. +   public static List<String> _savePlayerTeams = new ArrayList<>();
  1554. +   public static List<Integer> _teamPlayersCount = new ArrayList<>();
  1555. +   public static List<Integer> _teamColors = new ArrayList<>();
  1556. +   public static List<Integer> _teamsX = new ArrayList<>();
  1557. +   public static List<Integer> _teamsY = new ArrayList<>();
  1558. +   public static List<Integer> _teamsZ = new ArrayList<>();
  1559. +   public static List<Integer> _teamPointsCount = new ArrayList<>();
  1560. +   public static int _topKills = 0;
  1561. +  
  1562. +   /**
  1563. +    * Instantiates a new tvt.
  1564. +    */
  1565. +   private TvT()
  1566. +   {
  1567. +   }
  1568. +  
  1569. +   /**
  1570. +    * Gets the new instance.
  1571. +    * @return the new instance
  1572. +    */
  1573. +   public static TvT getNewInstance()
  1574. +   {
  1575. +       return new TvT();
  1576. +   }
  1577. +  
  1578. +   /**
  1579. +    * Gets the _event name.
  1580. +    * @return the _eventName
  1581. +    */
  1582. +   public static String getEventName()
  1583. +   {
  1584. +       return _eventName;
  1585. +   }
  1586. +  
  1587. +   /**
  1588. +    * Set_event name.
  1589. +    * @param eventName the _eventName to set
  1590. +    * @return true, if successful
  1591. +    */
  1592. +   public static boolean setEventName(String eventName)
  1593. +   {
  1594. +       if (!_inProgress)
  1595. +       {
  1596. +           TvT._eventName = eventName;
  1597. +           return true;
  1598. +       }
  1599. +       return false;
  1600. +   }
  1601. +  
  1602. +   /**
  1603. +    * Gets the _event desc.
  1604. +    * @return the _eventDesc
  1605. +    */
  1606. +   public static String getEventDesc()
  1607. +   {
  1608. +       return _eventDesc;
  1609. +   }
  1610. +  
  1611. +   /**
  1612. +    * Set_event desc.
  1613. +    * @param eventDesc the _eventDesc to set
  1614. +    * @return true, if successful
  1615. +    */
  1616. +   public static boolean setEventDesc(String eventDesc)
  1617. +   {
  1618. +       if (!_inProgress)
  1619. +       {
  1620. +           TvT._eventDesc = eventDesc;
  1621. +           return true;
  1622. +       }
  1623. +       return false;
  1624. +   }
  1625. +  
  1626. +   /**
  1627. +    * Gets the _joining location name.
  1628. +    * @return the _joiningLocationName
  1629. +    */
  1630. +   public static String getJoiningLocationName()
  1631. +   {
  1632. +       return _joiningLocationName;
  1633. +   }
  1634. +  
  1635. +   /**
  1636. +    * Set_joining location name.
  1637. +    * @param joiningLocationName the _joiningLocationName to set
  1638. +    * @return true, if successful
  1639. +    */
  1640. +   public static boolean setJoiningLocationName(String joiningLocationName)
  1641. +   {
  1642. +       if (!_inProgress)
  1643. +       {
  1644. +           TvT._joiningLocationName = joiningLocationName;
  1645. +           return true;
  1646. +       }
  1647. +       return false;
  1648. +   }
  1649. +  
  1650. +   /**
  1651. +    * Gets the _npc id.
  1652. +    * @return the _npcId
  1653. +    */
  1654. +   public static int getNpcId()
  1655. +   {
  1656. +       return _npcId;
  1657. +   }
  1658. +  
  1659. +   /**
  1660. +    * Set_npc id.
  1661. +    * @param npcId the _npcId to set
  1662. +    * @return true, if successful
  1663. +    */
  1664. +   public static boolean setNpcId(int npcId)
  1665. +   {
  1666. +       if (!_inProgress)
  1667. +       {
  1668. +           TvT._npcId = npcId;
  1669. +           return true;
  1670. +       }
  1671. +       return false;
  1672. +   }
  1673. +  
  1674. +   /**
  1675. +    * Gets the _npc location.
  1676. +    * @return the _npc location
  1677. +    */
  1678. +   public static Location getNpcLocation()
  1679. +   {
  1680. +       return new Location(_npcX, _npcY, _npcZ, _npcHeading);
  1681. +   }
  1682. +  
  1683. +   /**
  1684. +    * Gets the _reward id.
  1685. +    * @return the _rewardId
  1686. +    */
  1687. +   public static int getRewardId()
  1688. +   {
  1689. +       return _rewardId;
  1690. +   }
  1691. +  
  1692. +   /**
  1693. +    * Set_reward id.
  1694. +    * @param rewardId the _rewardId to set
  1695. +    * @return true, if successful
  1696. +    */
  1697. +   public static boolean setRewardId(int rewardId)
  1698. +   {
  1699. +       if (!_inProgress)
  1700. +       {
  1701. +           TvT._rewardId = rewardId;
  1702. +           return true;
  1703. +       }
  1704. +       return false;
  1705. +   }
  1706. +  
  1707. +   /**
  1708. +    * Gets the _reward amount.
  1709. +    * @return the _rewardAmount
  1710. +    */
  1711. +   public static int getRewardAmount()
  1712. +   {
  1713. +       return _rewardAmount;
  1714. +   }
  1715. +  
  1716. +   /**
  1717. +    * Set_reward amount.
  1718. +    * @param rewardAmount the _rewardAmount to set
  1719. +    * @return true, if successful
  1720. +    */
  1721. +   public static boolean setRewardAmount(int rewardAmount)
  1722. +   {
  1723. +       if (!_inProgress)
  1724. +       {
  1725. +           TvT._rewardAmount = rewardAmount;
  1726. +           return true;
  1727. +       }
  1728. +       return false;
  1729. +   }
  1730. +  
  1731. +   /**
  1732. +    * Gets the _minLevel.
  1733. +    * @return the _minLevel
  1734. +    */
  1735. +   public static int getMinLevel()
  1736. +   {
  1737. +       return _minLevel;
  1738. +   }
  1739. +  
  1740. +   /**
  1741. +    * Set_minLevel.
  1742. +    * @param minLevel the _minLevel to set
  1743. +    * @return true, if successful
  1744. +    */
  1745. +   public static boolean setMinlvl(int minLevel)
  1746. +   {
  1747. +       if (!_inProgress)
  1748. +       {
  1749. +           TvT._minLevel = minLevel;
  1750. +           return true;
  1751. +       }
  1752. +       return false;
  1753. +   }
  1754. +  
  1755. +   /**
  1756. +    * Gets the _maxLevel.
  1757. +    * @return the _maxLevel
  1758. +    */
  1759. +   public static int getMaxLevel()
  1760. +   {
  1761. +       return _maxLevel;
  1762. +   }
  1763. +  
  1764. +   /**
  1765. +    * Set_maxLevel.
  1766. +    * @param maxLevel the _maxLevel to set
  1767. +    * @return true, if successful
  1768. +    */
  1769. +   public static boolean setMaxlvl(int maxLevel)
  1770. +   {
  1771. +       if (!_inProgress)
  1772. +       {
  1773. +           TvT._maxLevel = maxLevel;
  1774. +           return true;
  1775. +       }
  1776. +       return false;
  1777. +   }
  1778. +  
  1779. +   /**
  1780. +    * Gets the _join time.
  1781. +    * @return the _joinTime
  1782. +    */
  1783. +   public static int getJoinTime()
  1784. +   {
  1785. +       return _joinTime;
  1786. +   }
  1787. +  
  1788. +   /**
  1789. +    * Set_join time.
  1790. +    * @param joinTime the _joinTime to set
  1791. +    * @return true, if successful
  1792. +    */
  1793. +   public static boolean setJoinTime(int joinTime)
  1794. +   {
  1795. +       if (!_inProgress)
  1796. +       {
  1797. +           TvT._joinTime = joinTime;
  1798. +           return true;
  1799. +       }
  1800. +       return false;
  1801. +   }
  1802. +  
  1803. +   /**
  1804. +    * Gets the _event time.
  1805. +    * @return the _eventTime
  1806. +    */
  1807. +   public static int getEventTime()
  1808. +   {
  1809. +       return _eventTime;
  1810. +   }
  1811. +  
  1812. +   /**
  1813. +    * Set_event time.
  1814. +    * @param eventTime the _eventTime to set
  1815. +    * @return true, if successful
  1816. +    */
  1817. +   public static boolean setEventTime(int eventTime)
  1818. +   {
  1819. +       if (!_inProgress)
  1820. +       {
  1821. +           TvT._eventTime = eventTime;
  1822. +           return true;
  1823. +       }
  1824. +       return false;
  1825. +   }
  1826. +  
  1827. +   /**
  1828. +    * Gets the _min players.
  1829. +    * @return the _minPlayers
  1830. +    */
  1831. +   public static int getMinPlayers()
  1832. +   {
  1833. +       return _minPlayers;
  1834. +   }
  1835. +  
  1836. +   /**
  1837. +    * Set_min players.
  1838. +    * @param minPlayers the _minPlayers to set
  1839. +    * @return true, if successful
  1840. +    */
  1841. +   public static boolean setMinPlayers(int minPlayers)
  1842. +   {
  1843. +       if (!_inProgress)
  1844. +       {
  1845. +           TvT._minPlayers = minPlayers;
  1846. +           return true;
  1847. +       }
  1848. +       return false;
  1849. +   }
  1850. +  
  1851. +   /**
  1852. +    * Gets the _max players.
  1853. +    * @return the _maxPlayers
  1854. +    */
  1855. +   public static int getMaxPlayers()
  1856. +   {
  1857. +       return _maxPlayers;
  1858. +   }
  1859. +  
  1860. +   /**
  1861. +    * Set_max players.
  1862. +    * @param maxPlayers the _maxPlayers to set
  1863. +    * @return true, if successful
  1864. +    */
  1865. +   public static boolean setMaxPlayers(int maxPlayers)
  1866. +   {
  1867. +       if (!_inProgress)
  1868. +       {
  1869. +           TvT._maxPlayers = maxPlayers;
  1870. +           return true;
  1871. +       }
  1872. +       return false;
  1873. +   }
  1874. +  
  1875. +   /**
  1876. +    * Gets the _interval between matches.
  1877. +    * @return the _intervalBetweenMatches
  1878. +    */
  1879. +   public static long getIntervalBetweenMatches()
  1880. +   {
  1881. +       return _intervalBetweenMatches;
  1882. +   }
  1883. +  
  1884. +   /**
  1885. +    * Set_interval between matches.
  1886. +    * @param intervalBetweenMatches the _intervalBetweenMatches to set
  1887. +    * @return true, if successful
  1888. +    */
  1889. +   public static boolean setIntervalBetweenMatches(long intervalBetweenMatches)
  1890. +   {
  1891. +       if (!_inProgress)
  1892. +       {
  1893. +           TvT._intervalBetweenMatches = intervalBetweenMatches;
  1894. +           return true;
  1895. +       }
  1896. +       return false;
  1897. +   }
  1898. +  
  1899. +   /**
  1900. +    * Gets the start event time.
  1901. +    * @return the startEventTime
  1902. +    */
  1903. +   public String getStartEventTime()
  1904. +   {
  1905. +       return startEventTime;
  1906. +   }
  1907. +  
  1908. +   /**
  1909. +    * Sets the start event time.
  1910. +    * @param startEventTime the startEventTime to set
  1911. +    * @return true, if successful
  1912. +    */
  1913. +   public boolean setStartEventTime(String startEventTime)
  1914. +   {
  1915. +       if (!_inProgress)
  1916. +       {
  1917. +           this.startEventTime = startEventTime;
  1918. +           return true;
  1919. +       }
  1920. +       return false;
  1921. +   }
  1922. +  
  1923. +   /**
  1924. +    * Checks if is _joining.
  1925. +    * @return the _joining
  1926. +    */
  1927. +   public static boolean isJoining()
  1928. +   {
  1929. +       return _joining;
  1930. +   }
  1931. +  
  1932. +   /**
  1933. +    * Checks if is _teleport.
  1934. +    * @return the _teleport
  1935. +    */
  1936. +   public static boolean isTeleport()
  1937. +   {
  1938. +       return _teleport;
  1939. +   }
  1940. +  
  1941. +   /**
  1942. +    * Checks if is _started.
  1943. +    * @return the _started
  1944. +    */
  1945. +   public static boolean isStarted()
  1946. +   {
  1947. +       return _started;
  1948. +   }
  1949. +  
  1950. +   /**
  1951. +    * Checks if is _aborted.
  1952. +    * @return the _aborted
  1953. +    */
  1954. +   public static boolean isAborted()
  1955. +   {
  1956. +       return _aborted;
  1957. +   }
  1958. +  
  1959. +   /**
  1960. +    * Checks if is _sit forced.
  1961. +    * @return the _sitForced
  1962. +    */
  1963. +   public static boolean isSitForced()
  1964. +   {
  1965. +       return _sitForced;
  1966. +   }
  1967. +  
  1968. +   /**
  1969. +    * Checks if is _in progress.
  1970. +    * @return the _inProgress
  1971. +    */
  1972. +   public static boolean isInProgress()
  1973. +   {
  1974. +       return _inProgress;
  1975. +   }
  1976. +  
  1977. +   /**
  1978. +    * Check max level.
  1979. +    * @param maxLevel the maxLevel
  1980. +    * @return true, if successful
  1981. +    */
  1982. +   public static boolean checkMaxLevel(int maxLevel)
  1983. +   {
  1984. +       return _minLevel < maxLevel;
  1985. +   }
  1986. +  
  1987. +   /**
  1988. +    * Check min level.
  1989. +    * @param minLevel the minLevel
  1990. +    * @return true, if successful
  1991. +    */
  1992. +   public static boolean checkMinLevel(int minLevel)
  1993. +   {
  1994. +       return _maxLevel > minLevel;
  1995. +   }
  1996. +  
  1997. +   /**
  1998. +    * returns true if participated players is higher or equal then minimum needed players.
  1999. +    * @param players the players
  2000. +    * @return true, if successful
  2001. +    */
  2002. +   public static boolean checkMinPlayers(int players)
  2003. +   {
  2004. +       return _minPlayers <= players;
  2005. +   }
  2006. +  
  2007. +   /**
  2008. +    * returns true if max players is higher or equal then participated players.
  2009. +    * @param players the players
  2010. +    * @return true, if successful
  2011. +    */
  2012. +   public static boolean checkMaxPlayers(int players)
  2013. +   {
  2014. +       return _maxPlayers > players;
  2015. +   }
  2016. +  
  2017. +   /**
  2018. +    * Check start join ok.
  2019. +    * @return true, if successful
  2020. +    */
  2021. +   public static boolean checkStartJoinOk()
  2022. +   {
  2023. +       if (_started || _teleport || _joining || _eventName.equals("") || _joiningLocationName.equals("") || _eventDesc.equals("") || (_npcId == 0) || (_npcX == 0) || (_npcY == 0) || (_npcZ == 0) || (_rewardId == 0) || (_rewardAmount == 0))
  2024. +       {
  2025. +           return false;
  2026. +       }
  2027. +      
  2028. +       if (_teamEvent)
  2029. +       {
  2030. +           if (!checkStartJoinTeamInfo())
  2031. +           {
  2032. +               return false;
  2033. +           }
  2034. +       }
  2035. +       else if (!checkStartJoinPlayerInfo())
  2036. +       {
  2037. +           return false;
  2038. +       }
  2039. +      
  2040. +       if (!Config.ALLOW_EVENTS_DURING_OLY && Olympiad.getInstance().inCompPeriod())
  2041. +       {
  2042. +           return false;
  2043. +       }
  2044. +      
  2045. +       for (Castle castle : CastleManager.getInstance().getCastles())
  2046. +       {
  2047. +           if ((castle != null) && (castle.getSiege() != null) && castle.getSiege().isInProgress())
  2048. +           {
  2049. +               return false;
  2050. +           }
  2051. +       }
  2052. +      
  2053. +       if (!checkOptionalEventStartJoinOk())
  2054. +       {
  2055. +           return false;
  2056. +       }
  2057. +      
  2058. +       return true;
  2059. +   }
  2060. +  
  2061. +   /**
  2062. +    * Check start join team info.
  2063. +    * @return true, if successful
  2064. +    */
  2065. +   private static boolean checkStartJoinTeamInfo()
  2066. +   {
  2067. +       return (_teams.size() >= 2) && !_teamsX.contains(0) && !_teamsY.contains(0) && !_teamsZ.contains(0);
  2068. +   }
  2069. +  
  2070. +   /**
  2071. +    * Check start join player info.
  2072. +    * @return true, if successful
  2073. +    */
  2074. +   private static boolean checkStartJoinPlayerInfo()
  2075. +   {
  2076. +       // TODO be integrated
  2077. +       return true;
  2078. +   }
  2079. +  
  2080. +   /**
  2081. +    * Check auto event start join ok.
  2082. +    * @return true, if successful
  2083. +    */
  2084. +   protected static boolean checkAutoEventStartJoinOk()
  2085. +   {
  2086. +       return (_joinTime != 0) && (_eventTime != 0);
  2087. +   }
  2088. +  
  2089. +   /**
  2090. +    * Check optional event start join ok.
  2091. +    * @return true, if successful
  2092. +    */
  2093. +   private static boolean checkOptionalEventStartJoinOk()
  2094. +   {
  2095. +       // TODO be integrated
  2096. +       return true;
  2097. +   }
  2098. +  
  2099. +   /**
  2100. +    * Sets the npc pos.
  2101. +    * @param player the new npc pos
  2102. +    */
  2103. +   public static void setNpcPos(Player player)
  2104. +   {
  2105. +       _npcX = player.getX();
  2106. +       _npcY = player.getY();
  2107. +       _npcZ = player.getZ();
  2108. +       _npcHeading = player.getHeading();
  2109. +   }
  2110. +  
  2111. +   /**
  2112. +    * Spawn event npc.
  2113. +    */
  2114. +   private static void spawnEventNpc()
  2115. +   {
  2116. +       final NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_npcId);
  2117. +      
  2118. +       try
  2119. +       {
  2120. +           _npcSpawn = new Spawn(tmpl);
  2121. +           _npcSpawn.setX(_npcX);
  2122. +           _npcSpawn.setY(_npcY);
  2123. +           _npcSpawn.setZ(_npcZ);
  2124. +           _npcSpawn.setAmount(1);
  2125. +           _npcSpawn.setHeading(_npcHeading);
  2126. +           _npcSpawn.setRespawnDelay(1);
  2127. +          
  2128. +           SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  2129. +           _npcSpawn.init();
  2130. +           _npcSpawn.getLastSpawn().getStatus().setCurrentHp(999999999);
  2131. +           _npcSpawn.getLastSpawn().setTitle(_eventName);
  2132. +           _npcSpawn.getLastSpawn()._isEventMobTvT = true;
  2133. +           _npcSpawn.getLastSpawn().isAggressive();
  2134. +           _npcSpawn.getLastSpawn().decayMe();
  2135. +           _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
  2136. +           _npcSpawn.getLastSpawn().broadcastPacket(new MagicSkillUse(_npcSpawn.getLastSpawn(), _npcSpawn.getLastSpawn(), 1034, 1, 1, 1));
  2137. +       }
  2138. +       catch (Exception e)
  2139. +       {
  2140. +           LOGGER.warning(_eventName + " Engine[spawnEventNpc(exception: " + e.getMessage());
  2141. +       }
  2142. +   }
  2143. +  
  2144. +   /**
  2145. +    * Unspawn event npc.
  2146. +    */
  2147. +   private static void unspawnEventNpc()
  2148. +   {
  2149. +       if ((_npcSpawn == null) || (_npcSpawn.getLastSpawn() == null))
  2150. +       {
  2151. +           return;
  2152. +       }
  2153. +      
  2154. +       _npcSpawn.getLastSpawn().deleteMe();
  2155. +       _npcSpawn.stopRespawn();
  2156. +       SpawnTable.getInstance().deleteSpawn(_npcSpawn, true);
  2157. +   }
  2158. +  
  2159. +   /**
  2160. +    * Start join.
  2161. +    * @return true, if successful
  2162. +    */
  2163. +   public static boolean startJoin()
  2164. +   {
  2165. +       if (!checkStartJoinOk())
  2166. +       {
  2167. +           return false;
  2168. +       }
  2169. +      
  2170. +       _inProgress = true;
  2171. +       _joining = true;
  2172. +       spawnEventNpc();
  2173. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Event " + _eventName + "!");
  2174. +       if (Config.TVT_ANNOUNCE_REWARD && (ItemTable.getInstance().getTemplate(_rewardId) != null))
  2175. +       {
  2176. +           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Reward: " + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName());
  2177. +       }
  2178. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Recruiting levels: " + _minLevel + " to " + _maxLevel);
  2179. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + ".");
  2180. +       if (Config.TVT_COMMAND)
  2181. +       {
  2182. +           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Commands .tvtjoin .tvtleave .tvtinfo");
  2183. +       }
  2184. +      
  2185. +       return true;
  2186. +   }
  2187. +  
  2188. +   /**
  2189. +    * Start teleport.
  2190. +    * @return true, if successful
  2191. +    */
  2192. +   public static boolean startTeleport()
  2193. +   {
  2194. +       if (!_joining || _started || _teleport)
  2195. +       {
  2196. +           return false;
  2197. +       }
  2198. +      
  2199. +       removeOfflinePlayers();
  2200. +      
  2201. +       if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE") && checkMinPlayers(_playersShuffle.size()))
  2202. +       {
  2203. +           shuffleTeams();
  2204. +       }
  2205. +       else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size()))
  2206. +       {
  2207. +           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Not enough players for event. Min Requested : " + _minPlayers + ", Participating : " + _playersShuffle.size());
  2208. +          
  2209. +           return false;
  2210. +       }
  2211. +      
  2212. +       _joining = false;
  2213. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport to team spot in 20 seconds!");
  2214. +       setUserData();
  2215. +       ThreadPool.schedule(() ->
  2216. +       {
  2217. +           sit();
  2218. +          
  2219. +           synchronized (_players)
  2220. +           {
  2221. +               for (Player player : _players)
  2222. +               {
  2223. +                   if (player != null)
  2224. +                   {
  2225. +                       // Remove Summon's buffs
  2226. +                       if (Config.TVT_ON_START_UNSUMMON_PET && (player.getPet() != null))
  2227. +                       {
  2228. +                           final Summon summon = player.getPet();
  2229. +                           summon.stopAllEffects();
  2230. +                          
  2231. +                           if (summon instanceof Pet)
  2232. +                           {
  2233. +                               summon.unSummon(player);
  2234. +                           }
  2235. +                       }
  2236. +                      
  2237. +                       if (Config.TVT_ON_START_REMOVE_ALL_EFFECTS)
  2238. +                       {
  2239. +                           player.stopAllEffects();
  2240. +                       }
  2241. +                      
  2242. +                       // Remove player from his party
  2243. +                       if (player.getParty() != null)
  2244. +                       {
  2245. +                           final Party party = player.getParty();
  2246. +                           party.removePartyMember(player);
  2247. +                       }
  2248. +                      
  2249. +                       player.teleToLocation((_teamsX.get(_teams.indexOf(player._teamNameTvT)) + Rnd.get(201)) - 100, (_teamsY.get(_teams.indexOf(player._teamNameTvT)) + Rnd.get(201)) - 100, _teamsZ.get(_teams.indexOf(player._teamNameTvT)));
  2250. +                   }
  2251. +               }
  2252. +           }
  2253. +       }, 20000);
  2254. +       _teleport = true;
  2255. +       return true;
  2256. +   }
  2257. +  
  2258. +   /**
  2259. +    * Start event.
  2260. +    * @return true, if successful
  2261. +    */
  2262. +   public static boolean startEvent()
  2263. +   {
  2264. +       if (!startEventOk())
  2265. +       {
  2266. +           return false;
  2267. +       }
  2268. +      
  2269. +       _teleport = false;
  2270. +       sit();
  2271. +      
  2272. +       if (Config.TVT_CLOSE_FORT_DOORS)
  2273. +       {
  2274. +           closeFortDoors();
  2275. +       }
  2276. +      
  2277. +       if (Config.TVT_CLOSE_ADEN_COLOSSEUM_DOORS)
  2278. +       {
  2279. +           closeAdenColosseumDoors();
  2280. +       }
  2281. +      
  2282. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Started. Go to kill your enemies!");
  2283. +       _started = true;
  2284. +       return true;
  2285. +   }
  2286. +  
  2287. +   /**
  2288. +    * Restarts Event checks if event was aborted. and if true cancels restart task
  2289. +    */
  2290. +   public static synchronized void restartEvent()
  2291. +   {
  2292. +       LOGGER.info(_eventName + ": Event has been restarted...");
  2293. +       _joining = false;
  2294. +       _started = false;
  2295. +       _inProgress = false;
  2296. +       _aborted = false;
  2297. +       final long delay = _intervalBetweenMatches;
  2298. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": joining period will be avaible again in " + _intervalBetweenMatches + " minute(s)!");
  2299. +       waiter(delay);
  2300. +      
  2301. +       try
  2302. +       {
  2303. +           if (!_aborted)
  2304. +           {
  2305. +               autoEvent(); // start a new event
  2306. +           }
  2307. +           else
  2308. +           {
  2309. +               AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": next event aborted!");
  2310. +           }
  2311. +       }
  2312. +       catch (Exception e)
  2313. +       {
  2314. +           LOGGER.warning(_eventName + ": Error While Trying to restart Event... " + e);
  2315. +       }
  2316. +   }
  2317. +  
  2318. +   /**
  2319. +    * Finish event.
  2320. +    */
  2321. +   public static void finishEvent()
  2322. +   {
  2323. +       if (!finishEventOk())
  2324. +       {
  2325. +           return;
  2326. +       }
  2327. +      
  2328. +       _started = false;
  2329. +       _aborted = false;
  2330. +       unspawnEventNpc();
  2331. +      
  2332. +       afterFinishOperations();
  2333. +      
  2334. +       if (_teamEvent)
  2335. +       {
  2336. +           processTopTeam();
  2337. +           synchronized (_players)
  2338. +           {
  2339. +               final Player bestKiller = findBestKiller(_players);
  2340. +               final Player looser = findLooser(_players);
  2341. +               if (_topKills != 0)
  2342. +               {
  2343. +                   playKneelAnimation(_topTeam);
  2344. +                  
  2345. +                   if (Config.TVT_ANNOUNCE_TEAM_STATS)
  2346. +                   {
  2347. +                       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + " Team Statistics:");
  2348. +                       for (String team : _teams)
  2349. +                       {
  2350. +                           final int _kills = teamKillsCount(team);
  2351. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Team: " + team + " - Kills: " + _kills);
  2352. +                       }
  2353. +                      
  2354. +                       if (bestKiller != null)
  2355. +                       {
  2356. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Top killer: " + bestKiller.getName() + " - Kills: " + bestKiller._countTvTkills);
  2357. +                       }
  2358. +                       if ((looser != null) && (!looser.equals(bestKiller)))
  2359. +                       {
  2360. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Top looser: " + looser.getName() + " - Dies: " + looser._countTvTdies);
  2361. +                       }
  2362. +                   }
  2363. +                  
  2364. +                   if (_topTeam != null)
  2365. +                   {
  2366. +                       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + _topTeam + "'s win the match! " + _topKills + " kills.");
  2367. +                   }
  2368. +                   else
  2369. +                   {
  2370. +                       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: " + _topKills + " kills by each team!");
  2371. +                   }
  2372. +                   rewardTeam(_topTeam, bestKiller, looser);
  2373. +                   if (Config.TVT_STATS_LOGGER)
  2374. +                   {
  2375. +                       LOGGER.info("**** " + _eventName + " ****");
  2376. +                       LOGGER.info(_eventName + " Team Statistics:");
  2377. +                       for (String team : _teams)
  2378. +                       {
  2379. +                           final int _kills = teamKillsCount(team);
  2380. +                           LOGGER.info("Team: " + team + " - Kills: " + _kills);
  2381. +                       }
  2382. +                      
  2383. +                       if (bestKiller != null)
  2384. +                       {
  2385. +                           LOGGER.info("Top killer: " + bestKiller.getName() + " - Kills: " + bestKiller._countTvTkills);
  2386. +                       }
  2387. +                       if ((looser != null) && (!looser.equals(bestKiller)))
  2388. +                       {
  2389. +                           LOGGER.info("Top looser: " + looser.getName() + " - Dies: " + looser._countTvTdies);
  2390. +                       }
  2391. +                      
  2392. +                       LOGGER.info(_eventName + ": " + _topTeam + "'s win the match! " + _topKills + " kills.");
  2393. +                   }
  2394. +               }
  2395. +               else
  2396. +               {
  2397. +                   AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": The event finished with a TIE: No team wins the match(nobody killed)!");
  2398. +                   if (Config.TVT_STATS_LOGGER)
  2399. +                   {
  2400. +                       LOGGER.info(_eventName + ": No team win the match(nobody killed).");
  2401. +                   }
  2402. +                  
  2403. +                   rewardTeam(_topTeam, bestKiller, looser);
  2404. +               }
  2405. +           }
  2406. +       }
  2407. +       else
  2408. +       {
  2409. +           processTopPlayer();
  2410. +       }
  2411. +      
  2412. +       teleportFinish();
  2413. +   }
  2414. +  
  2415. +   /**
  2416. +    * After finish operations.
  2417. +    */
  2418. +   private static void afterFinishOperations()
  2419. +   {
  2420. +       if (Config.TVT_OPEN_FORT_DOORS)
  2421. +       {
  2422. +           openFortDoors();
  2423. +       }
  2424. +      
  2425. +       if (Config.TVT_OPEN_ADEN_COLOSSEUM_DOORS)
  2426. +       {
  2427. +           openAdenColosseumDoors();
  2428. +       }
  2429. +   }
  2430. +  
  2431. +   /**
  2432. +    * Abort event.
  2433. +    */
  2434. +   public static void abortEvent()
  2435. +   {
  2436. +       if (!_joining && !_teleport && !_started)
  2437. +       {
  2438. +           return;
  2439. +       }
  2440. +      
  2441. +       if (_joining && !_teleport && !_started)
  2442. +       {
  2443. +           unspawnEventNpc();
  2444. +           cleanTvT();
  2445. +           _joining = false;
  2446. +           _inProgress = false;
  2447. +           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
  2448. +           return;
  2449. +       }
  2450. +       _joining = false;
  2451. +       _teleport = false;
  2452. +       _started = false;
  2453. +       _aborted = true;
  2454. +       unspawnEventNpc();
  2455. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Match aborted!");
  2456. +       teleportFinish();
  2457. +   }
  2458. +  
  2459. +   /**
  2460. +    * Teleport finish.
  2461. +    */
  2462. +   public static void teleportFinish()
  2463. +   {
  2464. +       sit();
  2465. +       AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Teleport back to participation NPC in 20 seconds!");
  2466. +       ThreadPool.schedule(() ->
  2467. +       {
  2468. +           synchronized (_players)
  2469. +           {
  2470. +               for (Player player : _players)
  2471. +               {
  2472. +                   if (player != null)
  2473. +                   {
  2474. +                       if (player.isOnline())
  2475. +                       {
  2476. +                           player.teleToLocation(_npcX, _npcY, _npcZ);
  2477. +                       }
  2478. +                       else
  2479. +                       {
  2480. +                           try (Connection con = DatabaseFactory.getConnection())
  2481. +                           {
  2482. +                               final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
  2483. +                               statement.setInt(1, _npcX);
  2484. +                               statement.setInt(2, _npcY);
  2485. +                               statement.setInt(3, _npcZ);
  2486. +                               statement.setString(4, player.getName());
  2487. +                               statement.execute();
  2488. +                               statement.close();
  2489. +                           }
  2490. +                           catch (Exception e)
  2491. +                           {
  2492. +                               LOGGER.warning(e.getMessage());
  2493. +                           }
  2494. +                       }
  2495. +                   }
  2496. +               }
  2497. +           }
  2498. +          
  2499. +           sit();
  2500. +           cleanTvT();
  2501. +       }, 20000);
  2502. +   }
  2503. +  
  2504. +   protected static class AutoEventTask implements Runnable
  2505. +   {
  2506. +       @Override
  2507. +       public void run()
  2508. +       {
  2509. +           LOGGER.info("Starting " + _eventName + "!");
  2510. +           LOGGER.info("Matchs Are Restarted At Every: " + getIntervalBetweenMatchs() + " Minutes.");
  2511. +           if (checkAutoEventStartJoinOk() && startJoin() && !_aborted)
  2512. +           {
  2513. +               if (_joinTime > 0)
  2514. +               {
  2515. +                   waiter(_joinTime * 60 * 1000); // minutes for join event
  2516. +               }
  2517. +               else if (_joinTime <= 0)
  2518. +               {
  2519. +                   LOGGER.info(_eventName + ": join time <=0 aborting event.");
  2520. +                   abortEvent();
  2521. +                   return;
  2522. +               }
  2523. +               if (startTeleport() && !_aborted)
  2524. +               {
  2525. +                   waiter(30 * 1000); // 30 sec wait time until start fight after teleported
  2526. +                   if (startEvent() && !_aborted)
  2527. +                   {
  2528. +                       LOGGER.warning(_eventName + ": waiting.....minutes for event time " + _eventTime);
  2529. +                       waiter(_eventTime * 60 * 1000); // minutes for event time
  2530. +                       finishEvent();
  2531. +                      
  2532. +                       LOGGER.info(_eventName + ": waiting... delay for final messages ");
  2533. +                       waiter(60000); // just a give a delay delay for final messages
  2534. +                       sendFinalMessages();
  2535. +                      
  2536. +                       if (!_started && !_aborted) // if is not already started and it's not aborted
  2537. +                       {
  2538. +                           LOGGER.info(_eventName + ": waiting.....delay for restart event  " + _intervalBetweenMatches + " minutes.");
  2539. +                           waiter(60000); // just a give a delay to next restart
  2540. +                          
  2541. +                           try
  2542. +                           {
  2543. +                               if (!_aborted)
  2544. +                               {
  2545. +                                   restartEvent();
  2546. +                               }
  2547. +                           }
  2548. +                           catch (Exception e)
  2549. +                           {
  2550. +                               LOGGER.warning("Error while tying to Restart Event " + e);
  2551. +                           }
  2552. +                       }
  2553. +                   }
  2554. +               }
  2555. +               else if (!_aborted)
  2556. +               {
  2557. +                   abortEvent();
  2558. +                   restartEvent();
  2559. +               }
  2560. +           }
  2561. +       }
  2562. +   }
  2563. +  
  2564. +   /**
  2565. +    * Auto event.
  2566. +    */
  2567. +   public static void autoEvent()
  2568. +   {
  2569. +       ThreadPool.execute(new AutoEventTask());
  2570. +   }
  2571. +  
  2572. +   /**
  2573. +    * Event once start.
  2574. +    */
  2575. +   public static void eventOnceStart()
  2576. +   {
  2577. +       if (startJoin() && !_aborted)
  2578. +       {
  2579. +           if (_joinTime > 0)
  2580. +           {
  2581. +               waiter(_joinTime * 60 * 1000); // minutes for join event
  2582. +           }
  2583. +           else if (_joinTime <= 0)
  2584. +           {
  2585. +               abortEvent();
  2586. +               return;
  2587. +           }
  2588. +           if (startTeleport() && !_aborted)
  2589. +           {
  2590. +               waiter(1 * 60 * 1000); // 1 min wait time untill start fight after teleported
  2591. +               if (startEvent() && !_aborted)
  2592. +               {
  2593. +                   waiter(_eventTime * 60 * 1000); // minutes for event time
  2594. +                   finishEvent();
  2595. +               }
  2596. +           }
  2597. +           else if (!_aborted)
  2598. +           {
  2599. +               abortEvent();
  2600. +           }
  2601. +       }
  2602. +   }
  2603. +  
  2604. +   /**
  2605. +    * Waiter.
  2606. +    * @param interval the interval
  2607. +    */
  2608. +   protected static void waiter(long interval)
  2609. +   {
  2610. +       final long startWaiterTime = System.currentTimeMillis();
  2611. +       int seconds = (int) (interval / 1000);
  2612. +      
  2613. +       while (((startWaiterTime + interval) > System.currentTimeMillis()) && !_aborted)
  2614. +       {
  2615. +           seconds--; // Here because we don't want to see two time announce at the same time
  2616. +           if (_joining || _started || _teleport)
  2617. +           {
  2618. +               switch (seconds)
  2619. +               {
  2620. +                   case 3600: // 1 hour left
  2621. +                   {
  2622. +                       removeOfflinePlayers();
  2623. +                       if (_joining)
  2624. +                       {
  2625. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
  2626. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till registration close!");
  2627. +                       }
  2628. +                       else if (_started)
  2629. +                       {
  2630. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60 / 60) + " hour(s) till event finish!");
  2631. +                       }
  2632. +                       break;
  2633. +                   }
  2634. +                   case 1800: // 30 minutes left
  2635. +                   case 900: // 15 minutes left
  2636. +                   case 600: // 10 minutes left
  2637. +                   case 300: // 5 minutes left
  2638. +                   case 240: // 4 minutes left
  2639. +                   case 180: // 3 minutes left
  2640. +                   case 120: // 2 minutes left
  2641. +                   case 60: // 1 minute left
  2642. +                   {
  2643. +                       if (_joining)
  2644. +                       {
  2645. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Joinable in " + _joiningLocationName + "!");
  2646. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till registration close!");
  2647. +                       }
  2648. +                       else if (_started)
  2649. +                       {
  2650. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + (seconds / 60) + " minute(s) till event finish!");
  2651. +                       }
  2652. +                       break;
  2653. +                   }
  2654. +                   case 30: // 30 seconds left
  2655. +                   case 15: // 15 seconds left
  2656. +                   case 10: // 10 seconds left
  2657. +                   {
  2658. +                       removeOfflinePlayers();
  2659. +                       // fallthrough?
  2660. +                   }
  2661. +                   case 3: // 3 seconds left
  2662. +                   case 2: // 2 seconds left
  2663. +                   case 1: // 1 seconds left
  2664. +                   {
  2665. +                       if (_joining)
  2666. +                       {
  2667. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till registration close!");
  2668. +                       }
  2669. +                       else if (_teleport)
  2670. +                       {
  2671. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " seconds(s) till start fight!");
  2672. +                       }
  2673. +                       else if (_started)
  2674. +                       {
  2675. +                           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": " + seconds + " second(s) till event finish!");
  2676. +                       }
  2677. +                       break;
  2678. +                   }
  2679. +               }
  2680. +           }
  2681. +          
  2682. +           final long startOneSecondWaiterStartTime = System.currentTimeMillis();
  2683. +          
  2684. +           // Only the try catch with Thread.sleep(1000) give bad countdown on high wait times
  2685. +           while ((startOneSecondWaiterStartTime + 1000) > System.currentTimeMillis())
  2686. +           {
  2687. +               try
  2688. +               {
  2689. +                   Thread.sleep(1);
  2690. +               }
  2691. +               catch (InterruptedException e)
  2692. +               {
  2693. +               }
  2694. +           }
  2695. +       }
  2696. +   }
  2697. +  
  2698. +   /**
  2699. +    * Sit.
  2700. +    */
  2701. +   public static void sit()
  2702. +   {
  2703. +       if (_sitForced)
  2704. +       {
  2705. +           _sitForced = false;
  2706. +       }
  2707. +       else
  2708. +       {
  2709. +           _sitForced = true;
  2710. +       }
  2711. +      
  2712. +       synchronized (_players)
  2713. +       {
  2714. +           for (Player player : _players)
  2715. +           {
  2716. +               if (player != null)
  2717. +               {
  2718. +                   if (_sitForced)
  2719. +                   {
  2720. +                       player.stopMove(null, false);
  2721. +                       player.abortAttack();
  2722. +                       player.abortCast();
  2723. +                      
  2724. +                       if (!player.isSitting())
  2725. +                       {
  2726. +                           player.sitDown();
  2727. +                       }
  2728. +                   }
  2729. +                   else if (player.isSitting())
  2730. +                   {
  2731. +                       player.standUp();
  2732. +                   }
  2733. +               }
  2734. +           }
  2735. +       }
  2736. +   }
  2737. +  
  2738. +   /**
  2739. +    * Removes the offline players.
  2740. +    */
  2741. +   public static void removeOfflinePlayers()
  2742. +   {
  2743. +       try
  2744. +       {
  2745. +           if ((_playersShuffle == null) || _playersShuffle.isEmpty())
  2746. +           {
  2747. +               return;
  2748. +           }
  2749. +          
  2750. +           for (Player player : _playersShuffle)
  2751. +           {
  2752. +               if (player == null)
  2753. +               {
  2754. +                   _playersShuffle.remove(player);
  2755. +               }
  2756. +               else if (!player.isOnline() || player.isInJail() || player.isInOfflineMode())
  2757. +               {
  2758. +                   removePlayer(player);
  2759. +               }
  2760. +           }
  2761. +       }
  2762. +       catch (Exception e)
  2763. +       {
  2764. +           LOGGER.warning(e.getMessage());
  2765. +       }
  2766. +   }
  2767. +  
  2768. +   /**
  2769. +    * Start event ok.
  2770. +    * @return true, if successful
  2771. +    */
  2772. +   private static boolean startEventOk()
  2773. +   {
  2774. +       if (_joining || !_teleport || _started)
  2775. +       {
  2776. +           return false;
  2777. +       }
  2778. +      
  2779. +       if (Config.TVT_EVEN_TEAMS.equals("NO") || Config.TVT_EVEN_TEAMS.equals("BALANCE"))
  2780. +       {
  2781. +           if (_teamPlayersCount.contains(0))
  2782. +           {
  2783. +               return false;
  2784. +           }
  2785. +       }
  2786. +       else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  2787. +       {
  2788. +           final List<Player> playersShuffleTemp = new ArrayList<>();
  2789. +           int loopCount = 0;
  2790. +           loopCount = _playersShuffle.size();
  2791. +           for (int i = 0; i < loopCount; i++)
  2792. +           {
  2793. +               playersShuffleTemp.add(_playersShuffle.get(i));
  2794. +           }
  2795. +          
  2796. +           _playersShuffle = playersShuffleTemp;
  2797. +           playersShuffleTemp.clear();
  2798. +       }
  2799. +       return true;
  2800. +   }
  2801. +  
  2802. +   /**
  2803. +    * Finish event ok.
  2804. +    * @return true, if successful
  2805. +    */
  2806. +   private static boolean finishEventOk()
  2807. +   {
  2808. +       return _started;
  2809. +   }
  2810. +  
  2811. +   /**
  2812. +    * Adds the player ok.
  2813. +    * @param teamName the team name
  2814. +    * @param eventPlayer the event player
  2815. +    * @return true, if successful
  2816. +    */
  2817. +   private static boolean addPlayerOk(String teamName, Player eventPlayer)
  2818. +   {
  2819. +       if (eventPlayer.isAio() && !Config.ALLOW_AIO_IN_EVENTS)
  2820. +       {
  2821. +           eventPlayer.sendMessage("AIO charactes are not allowed to participate in events :/");
  2822. +       }
  2823. +       if (checkShufflePlayers(eventPlayer) || eventPlayer._inEventTvT)
  2824. +       {
  2825. +           eventPlayer.sendMessage("You already participated in the event!");
  2826. +           return false;
  2827. +       }
  2828. +      
  2829. +       if (Olympiad.getInstance().isRegistered(eventPlayer) || eventPlayer.isInOlympiadMode())
  2830. +       {
  2831. +           eventPlayer.sendMessage("You already participated in Olympiad!");
  2832. +           return false;
  2833. +       }
  2834. +      
  2835. +       if ((eventPlayer._activeBoxes > 1) && !Config.ALLOW_DUALBOX_EVENT)
  2836. +       {
  2837. +           final List<String> playerBoxes = eventPlayer._activeBoxCharacters;
  2838. +           if ((playerBoxes != null) && (playerBoxes.size() > 1))
  2839. +           {
  2840. +               for (String character_name : playerBoxes)
  2841. +               {
  2842. +                   final Player player = World.getInstance().getPlayer(character_name);
  2843. +                   if ((player != null) && player._inEventTvT)
  2844. +                   {
  2845. +                       eventPlayer.sendMessage("You already participated in event with another char!");
  2846. +                       return false;
  2847. +                   }
  2848. +               }
  2849. +           }
  2850. +       }
  2851. +      
  2852. +       synchronized (_players)
  2853. +       {
  2854. +           for (Player player : _players)
  2855. +           {
  2856. +               if (player.getObjectId() == eventPlayer.getObjectId())
  2857. +               {
  2858. +                   eventPlayer.sendMessage("You already participated in the event!");
  2859. +                   return false;
  2860. +               }
  2861. +               else if (player.getName().equalsIgnoreCase(eventPlayer.getName()))
  2862. +               {
  2863. +                   eventPlayer.sendMessage("You already participated in the event!");
  2864. +                   return false;
  2865. +               }
  2866. +           }
  2867. +          
  2868. +           if (_players.contains(eventPlayer))
  2869. +           {
  2870. +               eventPlayer.sendMessage("You already participated in the event!");
  2871. +               return false;
  2872. +           }
  2873. +       }
  2874. +      
  2875. +       if (Config.TVT_EVEN_TEAMS.equals("NO"))
  2876. +       {
  2877. +           return true;
  2878. +       }
  2879. +       else if (Config.TVT_EVEN_TEAMS.equals("BALANCE"))
  2880. +       {
  2881. +           boolean allTeamsEqual = true;
  2882. +           int countBefore = -1;
  2883. +           for (int playersCount : _teamPlayersCount)
  2884. +           {
  2885. +               if (countBefore == -1)
  2886. +               {
  2887. +                   countBefore = playersCount;
  2888. +               }
  2889. +              
  2890. +               if (countBefore != playersCount)
  2891. +               {
  2892. +                   allTeamsEqual = false;
  2893. +                   break;
  2894. +               }
  2895. +              
  2896. +               countBefore = playersCount;
  2897. +           }
  2898. +          
  2899. +           if (allTeamsEqual)
  2900. +           {
  2901. +               return true;
  2902. +           }
  2903. +          
  2904. +           countBefore = Integer.MAX_VALUE;
  2905. +           for (int teamPlayerCount : _teamPlayersCount)
  2906. +           {
  2907. +               if (teamPlayerCount < countBefore)
  2908. +               {
  2909. +                   countBefore = teamPlayerCount;
  2910. +               }
  2911. +           }
  2912. +          
  2913. +           final List<String> joinableTeams = new ArrayList<>();
  2914. +           for (String team : _teams)
  2915. +           {
  2916. +               if (teamPlayersCount(team) == countBefore)
  2917. +               {
  2918. +                   joinableTeams.add(team);
  2919. +               }
  2920. +           }
  2921. +          
  2922. +           if (joinableTeams.contains(teamName))
  2923. +           {
  2924. +               return true;
  2925. +           }
  2926. +       }
  2927. +       else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  2928. +       {
  2929. +           return true;
  2930. +       }
  2931. +      
  2932. +       eventPlayer.sendMessage("Too many players in team \"" + teamName + "\"");
  2933. +       return false;
  2934. +   }
  2935. +  
  2936. +   /**
  2937. +    * Sets the user data.
  2938. +    */
  2939. +   public static void setUserData()
  2940. +   {
  2941. +       synchronized (_players)
  2942. +       {
  2943. +           for (Player player : _players)
  2944. +           {
  2945. +               player._originalNameColorTvT = player.getAppearance().getNameColor();
  2946. +               player._originalKarmaTvT = player.getKarma();
  2947. +               player._originalTitleTvT = player.getTitle();
  2948. +               player.getAppearance().setNameColor(_teamColors.get(_teams.indexOf(player._teamNameTvT)));
  2949. +               player.setKarma(0);
  2950. +               player.setTitle("Kills: " + player._countTvTkills);
  2951. +               if (Config.TVT_AURA && (_teams.size() >= 2))
  2952. +               {
  2953. +                   player.setTeam(_teams.indexOf(player._teamNameTvT) + 1);
  2954. +               }
  2955. +              
  2956. +               if (player.isMounted() && player.setMountType(0))
  2957. +               {
  2958. +                   if (player.isFlying())
  2959. +                   {
  2960. +                       player.removeSkill(SkillTable.getInstance().getSkill(4289, 1));
  2961. +                   }
  2962. +                  
  2963. +                   player.broadcastPacket(new Ride(player.getObjectId(), Ride.ACTION_DISMOUNT, 0));
  2964. +                   player.setMountObjectID(0);
  2965. +               }
  2966. +               player.broadcastUserInfo();
  2967. +           }
  2968. +       }
  2969. +   }
  2970. +  
  2971. +   /**
  2972. +    * Dump data.
  2973. +    */
  2974. +   public static void dumpData()
  2975. +   {
  2976. +       LOGGER.info("");
  2977. +       LOGGER.info("");
  2978. +      
  2979. +       if (!_joining && !_teleport && !_started)
  2980. +       {
  2981. +           LOGGER.info("<<---------------------------------->>");
  2982. +           LOGGER.info(">> " + _eventName + " Engine infos dump (INACTIVE) <<");
  2983. +           LOGGER.info("<<--^----^^-----^----^^------^^----->>");
  2984. +       }
  2985. +       else if (_joining && !_teleport && !_started)
  2986. +       {
  2987. +           LOGGER.info("<<--------------------------------->>");
  2988. +           LOGGER.info(">> " + _eventName + " Engine infos dump (JOINING) <<");
  2989. +           LOGGER.info("<<--^----^^-----^----^^------^----->>");
  2990. +       }
  2991. +       else if (!_joining && _teleport && !_started)
  2992. +       {
  2993. +           LOGGER.info("<<---------------------------------->>");
  2994. +           LOGGER.info(">> " + _eventName + " Engine infos dump (TELEPORT) <<");
  2995. +           LOGGER.info("<<--^----^^-----^----^^------^^----->>");
  2996. +       }
  2997. +       else if (!_joining && !_teleport && _started)
  2998. +       {
  2999. +           LOGGER.info("<<--------------------------------->>");
  3000. +           LOGGER.info(">> " + _eventName + " Engine infos dump (STARTED) <<");
  3001. +           LOGGER.info("<<--^----^^-----^----^^------^----->>");
  3002. +       }
  3003. +      
  3004. +       LOGGER.info("Name: " + _eventName);
  3005. +       LOGGER.info("Desc: " + _eventDesc);
  3006. +       LOGGER.info("Join location: " + _joiningLocationName);
  3007. +       LOGGER.info("Min lvl: " + _minLevel);
  3008. +       LOGGER.info("Max lvl: " + _maxLevel);
  3009. +       LOGGER.info("");
  3010. +       LOGGER.info("##########################");
  3011. +       LOGGER.info("# _teams(List<String>) #");
  3012. +       LOGGER.info("##########################");
  3013. +      
  3014. +       for (String team : _teams)
  3015. +       {
  3016. +           LOGGER.info(team + " Kills Done :" + _teamPointsCount.get(_teams.indexOf(team)));
  3017. +       }
  3018. +      
  3019. +       if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  3020. +       {
  3021. +           LOGGER.info("");
  3022. +           LOGGER.info("#########################################");
  3023. +           LOGGER.info("# _playersShuffle(List<PlayerInstance>) #");
  3024. +           LOGGER.info("#########################################");
  3025. +          
  3026. +           for (Player player : _playersShuffle)
  3027. +           {
  3028. +               if (player != null)
  3029. +               {
  3030. +                   LOGGER.info("Name: " + player.getName());
  3031. +               }
  3032. +           }
  3033. +       }
  3034. +      
  3035. +       LOGGER.info("");
  3036. +       LOGGER.info("##################################");
  3037. +       LOGGER.info("# _players(List<PlayerInstance>) #");
  3038. +       LOGGER.info("##################################");
  3039. +      
  3040. +       synchronized (_players)
  3041. +       {
  3042. +           for (Player player : _players)
  3043. +           {
  3044. +               if (player != null)
  3045. +               {
  3046. +                   LOGGER.info("Name: " + player.getName() + "   Team: " + player._teamNameTvT + "  Kills Done:" + player._countTvTkills);
  3047. +               }
  3048. +           }
  3049. +       }
  3050. +      
  3051. +       LOGGER.info("");
  3052. +       LOGGER.info("#####################################################################");
  3053. +       LOGGER.info("# _savePlayers(List<String>) and _savePlayerTeams(List<String>) #");
  3054. +       LOGGER.info("#####################################################################");
  3055. +      
  3056. +       for (String player : _savePlayers)
  3057. +       {
  3058. +           LOGGER.info("Name: " + player + "   Team: " + _savePlayerTeams.get(_savePlayers.indexOf(player)));
  3059. +       }
  3060. +      
  3061. +       LOGGER.info("");
  3062. +       LOGGER.info("");
  3063. +      
  3064. +       dumpLocalEventInfo();
  3065. +   }
  3066. +  
  3067. +   /**
  3068. +    * Dump local event info.
  3069. +    */
  3070. +   private static void dumpLocalEventInfo()
  3071. +   {
  3072. +   }
  3073. +  
  3074. +   /**
  3075. +    * Load data.
  3076. +    */
  3077. +   public static void loadData()
  3078. +   {
  3079. +       _eventName = "";
  3080. +       _eventDesc = "";
  3081. +       _joiningLocationName = "";
  3082. +       _savePlayers = new ArrayList<>();
  3083. +       _players = new ArrayList<>();
  3084. +       _topTeam = "";
  3085. +       _teams = new ArrayList<>();
  3086. +       _savePlayerTeams = new ArrayList<>();
  3087. +       _playersShuffle = new ArrayList<>();
  3088. +       _teamPlayersCount = new ArrayList<>();
  3089. +       _teamPointsCount = new ArrayList<>();
  3090. +       _teamColors = new ArrayList<>();
  3091. +       _teamsX = new ArrayList<>();
  3092. +       _teamsY = new ArrayList<>();
  3093. +       _teamsZ = new ArrayList<>();
  3094. +       _joining = false;
  3095. +       _teleport = false;
  3096. +       _started = false;
  3097. +       _sitForced = false;
  3098. +       _aborted = false;
  3099. +       _inProgress = false;
  3100. +       _npcId = 0;
  3101. +       _npcX = 0;
  3102. +       _npcY = 0;
  3103. +       _npcZ = 0;
  3104. +       _npcHeading = 0;
  3105. +       _rewardId = 0;
  3106. +       _rewardAmount = 0;
  3107. +       _topKills = 0;
  3108. +       _minLevel = 0;
  3109. +       _maxLevel = 0;
  3110. +       _joinTime = 0;
  3111. +       _eventTime = 0;
  3112. +       _minPlayers = 0;
  3113. +       _maxPlayers = 0;
  3114. +       _intervalBetweenMatches = 0;
  3115. +      
  3116. +       try (Connection con = DatabaseFactory.getConnection())
  3117. +       {
  3118. +           PreparedStatement statement;
  3119. +           ResultSet rs;
  3120. +           statement = con.prepareStatement("Select * from tvt");
  3121. +           rs = statement.executeQuery();
  3122. +           int teams = 0;
  3123. +          
  3124. +           while (rs.next())
  3125. +           {
  3126. +               _eventName = rs.getString("eventName");
  3127. +               _eventDesc = rs.getString("eventDesc");
  3128. +               _joiningLocationName = rs.getString("joiningLocation");
  3129. +               _minLevel = rs.getInt("minLevel");
  3130. +               _maxLevel = rs.getInt("maxLevel");
  3131. +               _npcId = rs.getInt("npcId");
  3132. +               _npcX = rs.getInt("npcX");
  3133. +               _npcY = rs.getInt("npcY");
  3134. +               _npcZ = rs.getInt("npcZ");
  3135. +               _npcHeading = rs.getInt("npcHeading");
  3136. +               _rewardId = rs.getInt("rewardId");
  3137. +               _rewardAmount = rs.getInt("rewardAmount");
  3138. +               teams = rs.getInt("teamsCount");
  3139. +               _joinTime = rs.getInt("joinTime");
  3140. +               _eventTime = rs.getInt("eventTime");
  3141. +               _minPlayers = rs.getInt("minPlayers");
  3142. +               _maxPlayers = rs.getInt("maxPlayers");
  3143. +               _intervalBetweenMatches = rs.getLong("delayForNextEvent");
  3144. +           }
  3145. +           statement.close();
  3146. +          
  3147. +           int index = -1;
  3148. +           if (teams > 0)
  3149. +           {
  3150. +               index = 0;
  3151. +           }
  3152. +           while ((index < teams) && (index > -1))
  3153. +           {
  3154. +               statement = con.prepareStatement("Select * from tvt_teams where teamId = ?");
  3155. +               statement.setInt(1, index);
  3156. +               rs = statement.executeQuery();
  3157. +               while (rs.next())
  3158. +               {
  3159. +                   _teams.add(rs.getString("teamName"));
  3160. +                   _teamPlayersCount.add(0);
  3161. +                   _teamPointsCount.add(0);
  3162. +                   _teamColors.add(0);
  3163. +                   _teamsX.add(0);
  3164. +                   _teamsY.add(0);
  3165. +                   _teamsZ.add(0);
  3166. +                   _teamsX.set(index, rs.getInt("teamX"));
  3167. +                   _teamsY.set(index, rs.getInt("teamY"));
  3168. +                   _teamsZ.set(index, rs.getInt("teamZ"));
  3169. +                   _teamColors.set(index, rs.getInt("teamColor"));
  3170. +               }
  3171. +               index++;
  3172. +               statement.close();
  3173. +           }
  3174. +       }
  3175. +       catch (Exception e)
  3176. +       {
  3177. +           LOGGER.warning("Exception: loadData(): " + e.getMessage());
  3178. +       }
  3179. +   }
  3180. +  
  3181. +   /**
  3182. +    * Save data.
  3183. +    */
  3184. +   public static void saveData()
  3185. +   {
  3186. +       try (Connection con = DatabaseFactory.getConnection())
  3187. +       {
  3188. +           PreparedStatement statement;
  3189. +           statement = con.prepareStatement("Delete from tvt");
  3190. +           statement.execute();
  3191. +           statement.close();
  3192. +          
  3193. +           statement = con.prepareStatement("INSERT INTO tvt (eventName, eventDesc, joiningLocation, minLevel, maxLevel, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, teamsCount, joinTime, eventTime, minPlayers, maxPlayers,delayForNextEvent) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");
  3194. +           statement.setString(1, _eventName);
  3195. +           statement.setString(2, _eventDesc);
  3196. +           statement.setString(3, _joiningLocationName);
  3197. +           statement.setInt(4, _minLevel);
  3198. +           statement.setInt(5, _maxLevel);
  3199. +           statement.setInt(6, _npcId);
  3200. +           statement.setInt(7, _npcX);
  3201. +           statement.setInt(8, _npcY);
  3202. +           statement.setInt(9, _npcZ);
  3203. +           statement.setInt(10, _npcHeading);
  3204. +           statement.setInt(11, _rewardId);
  3205. +           statement.setInt(12, _rewardAmount);
  3206. +           statement.setInt(13, _teams.size());
  3207. +           statement.setInt(14, _joinTime);
  3208. +           statement.setInt(15, _eventTime);
  3209. +           statement.setInt(16, _minPlayers);
  3210. +           statement.setInt(17, _maxPlayers);
  3211. +           statement.setLong(18, _intervalBetweenMatches);
  3212. +           statement.execute();
  3213. +           statement.close();
  3214. +          
  3215. +           statement = con.prepareStatement("Delete from tvt_teams");
  3216. +           statement.execute();
  3217. +           statement.close();
  3218. +          
  3219. +           for (String teamName : _teams)
  3220. +           {
  3221. +               final int index = _teams.indexOf(teamName);
  3222. +               if (index == -1)
  3223. +               {
  3224. +                   con.close();
  3225. +                   return;
  3226. +               }
  3227. +               statement = con.prepareStatement("INSERT INTO tvt_teams (teamId ,teamName, teamX, teamY, teamZ, teamColor) VALUES (?, ?, ?, ?, ?, ?)");
  3228. +               statement.setInt(1, index);
  3229. +               statement.setString(2, teamName);
  3230. +               statement.setInt(3, _teamsX.get(index));
  3231. +               statement.setInt(4, _teamsY.get(index));
  3232. +               statement.setInt(5, _teamsZ.get(index));
  3233. +               statement.setInt(6, _teamColors.get(index));
  3234. +               statement.execute();
  3235. +               statement.close();
  3236. +           }
  3237. +       }
  3238. +       catch (Exception e)
  3239. +       {
  3240. +           LOGGER.warning("Exception: saveData(): " + e.getMessage());
  3241. +       }
  3242. +   }
  3243. +  
  3244. +   /**
  3245. +    * Show event html.
  3246. +    * @param eventPlayer the event player
  3247. +    * @param objectId the object id
  3248. +    */
  3249. +   public static void showEventHtml(Player eventPlayer, String objectId)
  3250. +   {
  3251. +       try
  3252. +       {
  3253. +           final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  3254. +           final StringBuilder replyMSG = new StringBuilder("<html><title>" + _eventName + "</title><body>");
  3255. +           replyMSG.append("<center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32></center><br1>");
  3256. +           replyMSG.append("<center><font color=\"3366CC\">Current event:</font></center><br1>");
  3257. +           replyMSG.append("<center>Name:&nbsp;<font color=\"00FF00\">" + _eventName + "</font></center><br1>");
  3258. +           replyMSG.append("<center>Description:&nbsp;<font color=\"00FF00\">" + _eventDesc + "</font></center><br><br>");
  3259. +           if (!_started && !_joining)
  3260. +           {
  3261. +               replyMSG.append("<center>Wait till the admin/gm start the participation.</center>");
  3262. +           }
  3263. +           else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE") && !checkMaxPlayers(_playersShuffle.size()))
  3264. +           {
  3265. +               if (!_started)
  3266. +               {
  3267. +                   replyMSG.append("Currently participated: <font color=\"00FF00\">" + _playersShuffle.size() + ".</font><br>");
  3268. +                   replyMSG.append("Max players: <font color=\"00FF00\">" + _maxPlayers + "</font><br><br>");
  3269. +                   replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
  3270. +               }
  3271. +           }
  3272. +           else if (eventPlayer.isCursedWeaponEquiped() && !Config.TVT_JOIN_CURSED)
  3273. +           {
  3274. +               replyMSG.append("<font color=\"FFFF00\">You can't participate to this event with a cursed Weapon.</font><br>");
  3275. +           }
  3276. +           else if (!_started && _joining && (eventPlayer.getLevel() >= _minLevel) && (eventPlayer.getLevel() <= _maxLevel))
  3277. +           {
  3278. +               synchronized (_players)
  3279. +               {
  3280. +                   if (_players.contains(eventPlayer) || _playersShuffle.contains(eventPlayer) || checkShufflePlayers(eventPlayer))
  3281. +                   {
  3282. +                       if (Config.TVT_EVEN_TEAMS.equals("NO") || Config.TVT_EVEN_TEAMS.equals("BALANCE"))
  3283. +                       {
  3284. +                           replyMSG.append("You participated already in team <font color=\"LEVEL\">" + eventPlayer._teamNameTvT + "</font><br><br>");
  3285. +                       }
  3286. +                       else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  3287. +                       {
  3288. +                           replyMSG.append("<center><font color=\"3366CC\">You participated already!</font></center><br><br>");
  3289. +                       }
  3290. +                      
  3291. +                       replyMSG.append("<center>Joined Players: <font color=\"00FF00\">" + _playersShuffle.size() + "</font></center><br>");
  3292. +                       replyMSG.append("<center><font color=\"3366CC\">Wait till event start or remove your participation!</font><center>");
  3293. +                       replyMSG.append("<center><button value=\"Remove\" action=\"bypass -h npc_" + objectId + "_tvt_player_leave\" width=85 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></center>");
  3294. +                   }
  3295. +                   else
  3296. +                   {
  3297. +                       replyMSG.append("<center><font color=\"3366CC\">You want to participate in the event?</font></center><br>");
  3298. +                       replyMSG.append("<center><td width=\"200\">Min lvl: <font color=\"00FF00\">" + _minLevel + "</font></center></td><br>");
  3299. +                       replyMSG.append("<center><td width=\"200\">Max lvl: <font color=\"00FF00\">" + _maxLevel + "</font></center></td><br><br>");
  3300. +                       replyMSG.append("<center><font color=\"3366CC\">Teams:</font></center><br>");
  3301. +                       if (Config.TVT_EVEN_TEAMS.equals("NO") || Config.TVT_EVEN_TEAMS.equals("BALANCE"))
  3302. +                       {
  3303. +                           replyMSG.append("<center><table border=\"0\">");
  3304. +                           for (String team : _teams)
  3305. +                           {
  3306. +                               replyMSG.append("<tr><td width=\"100\"><font color=\"LEVEL\">" + team + "</font>&nbsp;(" + teamPlayersCount(team) + " joined)</td>");
  3307. +                               replyMSG.append("<center><td width=\"60\"><button value=\"Join\" action=\"bypass -h npc_" + objectId + "_tvt_player_join " + team + "\" width=85 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></center></td></tr>");
  3308. +                           }
  3309. +                           replyMSG.append("</table></center>");
  3310. +                       }
  3311. +                       else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  3312. +                       {
  3313. +                           replyMSG.append("<center>");
  3314. +                          
  3315. +                           for (String team : _teams)
  3316. +                           {
  3317. +                               replyMSG.append("<tr><td width=\"100\"><font color=\"LEVEL\">" + team + "</font> &nbsp;</td>");
  3318. +                           }
  3319. +                          
  3320. +                           replyMSG.append("</center><br>");
  3321. +                          
  3322. +                           replyMSG.append("<center><button value=\"Join Event\" action=\"bypass -h npc_" + objectId + "_tvt_player_join eventShuffle\" width=85 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></center>");
  3323. +                           replyMSG.append("<center><font color=\"3366CC\">Teams will be reandomly generated!</font></center><br>");
  3324. +                           replyMSG.append("<center>Joined Players:</font> <font color=\"LEVEL\">" + _playersShuffle.size() + "</center></font><br>");
  3325. +                           replyMSG.append("<center>Reward: <font color=\"LEVEL\">" + _rewardAmount + " " + ItemTable.getInstance().getTemplate(_rewardId).getName() + "</center></font>");
  3326. +                       }
  3327. +                   }
  3328. +               }
  3329. +           }
  3330. +           else if (_started && !_joining)
  3331. +           {
  3332. +               replyMSG.append("<center>" + _eventName + " match is in progress.</center>");
  3333. +           }
  3334. +           else if ((eventPlayer.getLevel() < _minLevel) || (eventPlayer.getLevel() > _maxLevel))
  3335. +           {
  3336. +               replyMSG.append("Your lvl: <font color=\"00FF00\">" + eventPlayer.getLevel() + "</font><br>");
  3337. +               replyMSG.append("Min lvl: <font color=\"00FF00\">" + _minLevel + "</font><br>");
  3338. +               replyMSG.append("Max lvl: <font color=\"00FF00\">" + _maxLevel + "</font><br><br>");
  3339. +               replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
  3340. +           }
  3341. +          
  3342. +           replyMSG.append("</body></html>");
  3343. +           adminReply.setHtml(replyMSG.toString());
  3344. +           eventPlayer.sendPacket(adminReply);
  3345. +          
  3346. +           // Send a Server->Client ActionFailed to the PlayerInstance in order to avoid that the client wait another packet
  3347. +           eventPlayer.sendPacket(ActionFailed.STATIC_PACKET);
  3348. +       }
  3349. +       catch (Exception e)
  3350. +       {
  3351. +           LOGGER.warning(_eventName + " Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception" + e.getMessage());
  3352. +       }
  3353. +   }
  3354. +  
  3355. +   /**
  3356. +    * Adds the player.
  3357. +    * @param player the player
  3358. +    * @param teamName the team name
  3359. +    */
  3360. +   public static void addPlayer(Player player, String teamName)
  3361. +   {
  3362. +       if (!addPlayerOk(teamName, player))
  3363. +       {
  3364. +           return;
  3365. +       }
  3366. +      
  3367. +       synchronized (_players)
  3368. +       {
  3369. +           if (Config.TVT_EVEN_TEAMS.equals("NO") || Config.TVT_EVEN_TEAMS.equals("BALANCE"))
  3370. +           {
  3371. +               player._teamNameTvT = teamName;
  3372. +               _players.add(player);
  3373. +               setTeamPlayersCount(teamName, teamPlayersCount(teamName) + 1);
  3374. +           }
  3375. +           else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE"))
  3376. +           {
  3377. +               _playersShuffle.add(player);
  3378. +           }
  3379. +       }
  3380. +      
  3381. +       player._inEventTvT = true;
  3382. +       player._countTvTkills = 0;
  3383. +       player.sendMessage(_eventName + ": You successfully registered for the event.");
  3384. +   }
  3385. +  
  3386. +   /**
  3387. +    * Removes the player.
  3388. +    * @param player the player
  3389. +    */
  3390. +   public static void removePlayer(Player player)
  3391. +   {
  3392. +       if (player._inEventTvT)
  3393. +       {
  3394. +           if (!_joining)
  3395. +           {
  3396. +               player.getAppearance().setNameColor(player._originalNameColorTvT);
  3397. +               player.setTitle(player._originalTitleTvT);
  3398. +               player.setKarma(player._originalKarmaTvT);
  3399. +               if (Config.TVT_AURA && (_teams.size() >= 2))
  3400. +               {
  3401. +                   player.setTeam(0); // clear aura :P
  3402. +               }
  3403. +               player.broadcastUserInfo();
  3404. +           }
  3405. +          
  3406. +           // after remove, all event data must be cleaned in player
  3407. +           player._originalNameColorTvT = 0;
  3408. +           player._originalTitleTvT = null;
  3409. +           player._originalKarmaTvT = 0;
  3410. +           player._teamNameTvT = "";
  3411. +           player._countTvTkills = 0;
  3412. +           player._inEventTvT = false;
  3413. +          
  3414. +           synchronized (_players)
  3415. +           {
  3416. +               if ((Config.TVT_EVEN_TEAMS.equals("NO") || Config.TVT_EVEN_TEAMS.equals("BALANCE")) && _players.contains(player))
  3417. +               {
  3418. +                   setTeamPlayersCount(player._teamNameTvT, teamPlayersCount(player._teamNameTvT) - 1);
  3419. +                   _players.remove(player);
  3420. +               }
  3421. +               else if (Config.TVT_EVEN_TEAMS.equals("SHUFFLE") && (!_playersShuffle.isEmpty() && _playersShuffle.contains(player)))
  3422. +               {
  3423. +                   _playersShuffle.remove(player);
  3424. +               }
  3425. +           }
  3426. +          
  3427. +           player.sendMessage("Your participation in the TvT event has been removed.");
  3428. +       }
  3429. +   }
  3430. +  
  3431. +   /**
  3432. +    * Clean tvt.
  3433. +    */
  3434. +   public static void cleanTvT()
  3435. +   {
  3436. +       synchronized (_players)
  3437. +       {
  3438. +           for (Player player : _players)
  3439. +           {
  3440. +               if (player != null)
  3441. +               {
  3442. +                   cleanEventPlayer(player);
  3443. +                  
  3444. +                   removePlayer(player);
  3445. +                   if (_savePlayers.contains(player.getName()))
  3446. +                   {
  3447. +                       _savePlayers.remove(player.getName());
  3448. +                   }
  3449. +                   player._inEventTvT = false;
  3450. +               }
  3451. +           }
  3452. +       }
  3453. +      
  3454. +       if ((_playersShuffle != null) && !_playersShuffle.isEmpty())
  3455. +       {
  3456. +           for (Player player : _playersShuffle)
  3457. +           {
  3458. +               if (player != null)
  3459. +               {
  3460. +                   player._inEventTvT = false;
  3461. +               }
  3462. +           }
  3463. +       }
  3464. +      
  3465. +       _topKills = 0;
  3466. +       _topTeam = "";
  3467. +       _players = new ArrayList<>();
  3468. +       _playersShuffle = new ArrayList<>();
  3469. +       _savePlayers = new ArrayList<>();
  3470. +       _savePlayerTeams = new ArrayList<>();
  3471. +       _teamPointsCount = new ArrayList<>();
  3472. +       _teamPlayersCount = new ArrayList<>();
  3473. +       cleanLocalEventInfo();
  3474. +      
  3475. +       _inProgress = false;
  3476. +       loadData();
  3477. +   }
  3478. +  
  3479. +   /**
  3480. +    * Clean local event info.
  3481. +    */
  3482. +   private static void cleanLocalEventInfo()
  3483. +   {
  3484. +       // nothing
  3485. +   }
  3486. +  
  3487. +   /**
  3488. +    * Clean event player.
  3489. +    * @param player the player
  3490. +    */
  3491. +   private static void cleanEventPlayer(Player player)
  3492. +   {
  3493. +       // nothing
  3494. +   }
  3495. +  
  3496. +   /**
  3497. +    * Adds the disconnected player.
  3498. +    * @param player the player
  3499. +    */
  3500. +   public static synchronized void addDisconnectedPlayer(Player player)
  3501. +   {
  3502. +       if ((Config.TVT_EVEN_TEAMS.equals("SHUFFLE") && (_teleport || _started)) || (Config.TVT_EVEN_TEAMS.equals("NO") || (Config.TVT_EVEN_TEAMS.equals("BALANCE") && (_teleport || _started))))
  3503. +       {
  3504. +           if (Config.TVT_ON_START_REMOVE_ALL_EFFECTS)
  3505. +           {
  3506. +               player.stopAllEffects();
  3507. +           }
  3508. +          
  3509. +           player._teamNameTvT = _savePlayerTeams.get(_savePlayers.indexOf(player.getName()));
  3510. +          
  3511. +           synchronized (_players)
  3512. +           {
  3513. +               for (Player p : _players)
  3514. +               {
  3515. +                   if (p == null)
  3516. +                   {
  3517. +                       continue;
  3518. +                   }
  3519. +                  
  3520. +                   // check by name incase player got new objectId
  3521. +                   if (p.getName().equals(player.getName()))
  3522. +                   {
  3523. +                       player._originalNameColorTvT = player.getAppearance().getNameColor();
  3524. +                       player._originalTitleTvT = player.getTitle();
  3525. +                       player._originalKarmaTvT = player.getKarma();
  3526. +                       player._inEventTvT = true;
  3527. +                       player._countTvTkills = p._countTvTkills;
  3528. +                       _players.remove(p); // removing old object id from vector
  3529. +                       _players.add(player); // adding new objectId to vector
  3530. +                       break;
  3531. +                   }
  3532. +               }
  3533. +           }
  3534. +          
  3535. +           player.getAppearance().setNameColor(_teamColors.get(_teams.indexOf(player._teamNameTvT)));
  3536. +           player.setKarma(0);
  3537. +           if (Config.TVT_AURA && (_teams.size() >= 2))
  3538. +           {
  3539. +               player.setTeam(_teams.indexOf(player._teamNameTvT) + 1);
  3540. +           }
  3541. +           player.broadcastUserInfo();
  3542. +          
  3543. +           player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameTvT)), _teamsY.get(_teams.indexOf(player._teamNameTvT)), _teamsZ.get(_teams.indexOf(player._teamNameTvT)));
  3544. +           afterAddDisconnectedPlayerOperations(player);
  3545. +       }
  3546. +   }
  3547. +  
  3548. +   /**
  3549. +    * After add disconnected player operations.
  3550. +    * @param player the player
  3551. +    */
  3552. +   private static void afterAddDisconnectedPlayerOperations(Player player)
  3553. +   {
  3554. +       // nothing
  3555. +   }
  3556. +  
  3557. +   /**
  3558. +    * Shuffle teams.
  3559. +    */
  3560. +   public static void shuffleTeams()
  3561. +   {
  3562. +       int teamCount = 0;
  3563. +       int playersCount = 0;
  3564. +      
  3565. +       synchronized (_players)
  3566. +       {
  3567. +           for (;;)
  3568. +           {
  3569. +               if (_playersShuffle.isEmpty())
  3570. +               {
  3571. +                   break;
  3572. +               }
  3573. +              
  3574. +               final int playerToAddIndex = Rnd.get(_playersShuffle.size());
  3575. +               Player player = null;
  3576. +               player = _playersShuffle.get(playerToAddIndex);
  3577. +               _players.add(player);
  3578. +               _players.get(playersCount)._teamNameTvT = _teams.get(teamCount);
  3579. +               _savePlayers.add(_players.get(playersCount).getName());
  3580. +               _savePlayerTeams.add(_teams.get(teamCount));
  3581. +               playersCount++;
  3582. +              
  3583. +               if (teamCount == (_teams.size() - 1))
  3584. +               {
  3585. +                   teamCount = 0;
  3586. +               }
  3587. +               else
  3588. +               {
  3589. +                   teamCount++;
  3590. +               }
  3591. +              
  3592. +               _playersShuffle.remove(playerToAddIndex);
  3593. +           }
  3594. +       }
  3595. +   }
  3596. +  
  3597. +   /**
  3598. +    * Play kneel animation.
  3599. +    * @param teamName the team name
  3600. +    */
  3601. +   public static void playKneelAnimation(String teamName)
  3602. +   {
  3603. +       synchronized (_players)
  3604. +       {
  3605. +           for (Player player : _players)
  3606. +           {
  3607. +               if (player != null)
  3608. +               {
  3609. +                   if (!player._teamNameTvT.equals(teamName))
  3610. +                   {
  3611. +                       player.broadcastPacket(new SocialAction(player.getObjectId(), 7));
  3612. +                   }
  3613. +                   else if (player._teamNameTvT.equals(teamName))
  3614. +                   {
  3615. +                       player.broadcastPacket(new SocialAction(player.getObjectId(), 3));
  3616. +                   }
  3617. +               }
  3618. +           }
  3619. +       }
  3620. +   }
  3621. +  
  3622. +   /**
  3623. +    * Reward team.
  3624. +    * @param teamName the team name
  3625. +    * @param bestKiller the best killer
  3626. +    * @param looser the looser
  3627. +    */
  3628. +   public static void rewardTeam(String teamName, Player bestKiller, Player looser)
  3629. +   {
  3630. +       synchronized (_players)
  3631. +       {
  3632. +           for (Player player : _players)
  3633. +           {
  3634. +               if ((player != null) && player.isOnline() && (player._inEventTvT) && (!player.equals(looser)) && ((player._countTvTkills > 0) || Config.TVT_PRICE_NO_KILLS))
  3635. +               {
  3636. +                   if ((bestKiller != null) && (bestKiller.equals(player)))
  3637. +                   {
  3638. +                       player.addItem(_eventName + " Event: " + _eventName, _rewardId, _rewardAmount, player, true);
  3639. +                       player.addItem(_eventName + " Event: " + _eventName, Config.TVT_TOP_KILLER_REWARD, Config.TVT_TOP_KILLER_QTY, player, true);
  3640. +                   }
  3641. +                   else if ((teamName != null) && (player._teamNameTvT.equals(teamName)))
  3642. +                   {
  3643. +                       player.addItem(_eventName + " Event: " + _eventName, _rewardId, _rewardAmount, player, true);
  3644. +                      
  3645. +                       final NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  3646. +                       final StringBuilder replyMSG = new StringBuilder("");
  3647. +                       replyMSG.append("<html><body>");
  3648. +                       replyMSG.append("<font color=\"FFFF00\">Your team wins the event. Look in your inventory for the reward.</font>");
  3649. +                       replyMSG.append("</body></html>");
  3650. +                      
  3651. +                       nhm.setHtml(replyMSG.toString());
  3652. +                       player.sendPacket(nhm);
  3653. +                      
  3654. +                       // Send a Server->Client ActionFailed to the PlayerInstance in order to avoid that the client wait another packet
  3655. +                       player.sendPacket(ActionFailed.STATIC_PACKET);
  3656. +                   }
  3657. +                   else if (teamName == null)
  3658. +                   {
  3659. +                       int minusReward = 0;
  3660. +                       if (_topKills != 0)
  3661. +                       {
  3662. +                           minusReward = _rewardAmount / 2;
  3663. +                       }
  3664. +                       else
  3665. +                       {
  3666. +                           // nobody killed
  3667. +                           minusReward = _rewardAmount / 4;
  3668. +                       }
  3669. +                      
  3670. +                       player.addItem(_eventName + " Event: " + _eventName, _rewardId, minusReward, player, true);
  3671. +                      
  3672. +                       final NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  3673. +                       final StringBuilder replyMSG = new StringBuilder("");
  3674. +                       replyMSG.append("<html><body>");
  3675. +                       replyMSG.append("<font color=\"FFFF00\">Your team had a tie in the event. Look in your inventory for the reward.</font>");
  3676. +                       replyMSG.append("</body></html>");
  3677. +                      
  3678. +                       nhm.setHtml(replyMSG.toString());
  3679. +                       player.sendPacket(nhm);
  3680. +                      
  3681. +                       // Send a Server->Client ActionFailed to the PlayerInstance in order to avoid that the client wait another packet
  3682. +                       player.sendPacket(ActionFailed.STATIC_PACKET);
  3683. +                   }
  3684. +               }
  3685. +           }
  3686. +       }
  3687. +   }
  3688. +  
  3689. +   /**
  3690. +    * Process top player.
  3691. +    */
  3692. +   private static void processTopPlayer()
  3693. +   {
  3694. +       // nothing
  3695. +   }
  3696. +  
  3697. +   /**
  3698. +    * Process top team.
  3699. +    */
  3700. +   private static void processTopTeam()
  3701. +   {
  3702. +       _topTeam = null;
  3703. +       for (String team : _teams)
  3704. +       {
  3705. +           if ((teamKillsCount(team) == _topKills) && (_topKills > 0))
  3706. +           {
  3707. +               _topTeam = null;
  3708. +           }
  3709. +          
  3710. +           if (teamKillsCount(team) > _topKills)
  3711. +           {
  3712. +               _topTeam = team;
  3713. +               _topKills = teamKillsCount(team);
  3714. +           }
  3715. +       }
  3716. +   }
  3717. +  
  3718. +   /**
  3719. +    * Adds the team.
  3720. +    * @param teamName the team name
  3721. +    */
  3722. +   public static void addTeam(String teamName)
  3723. +   {
  3724. +       if (_inProgress)
  3725. +       {
  3726. +           return;
  3727. +       }
  3728. +      
  3729. +       if (teamName.equals(" "))
  3730. +       {
  3731. +           return;
  3732. +       }
  3733. +      
  3734. +       _teams.add(teamName);
  3735. +       _teamPlayersCount.add(0);
  3736. +       _teamPointsCount.add(0);
  3737. +       _teamColors.add(0);
  3738. +       _teamsX.add(0);
  3739. +       _teamsY.add(0);
  3740. +       _teamsZ.add(0);
  3741. +      
  3742. +       addTeamEventOperations(teamName);
  3743. +   }
  3744. +  
  3745. +   /**
  3746. +    * Adds the team event operations.
  3747. +    * @param teamName the team name
  3748. +    */
  3749. +   private static void addTeamEventOperations(String teamName)
  3750. +   {
  3751. +       // nothing
  3752. +   }
  3753. +  
  3754. +   /**
  3755. +    * Removes the team.
  3756. +    * @param teamName the team name
  3757. +    */
  3758. +   public static void removeTeam(String teamName)
  3759. +   {
  3760. +       if (_inProgress || _teams.isEmpty())
  3761. +       {
  3762. +           return;
  3763. +       }
  3764. +      
  3765. +       if (teamPlayersCount(teamName) > 0)
  3766. +       {
  3767. +           return;
  3768. +       }
  3769. +      
  3770. +       final int index = _teams.indexOf(teamName);
  3771. +       if (index == -1)
  3772. +       {
  3773. +           return;
  3774. +       }
  3775. +      
  3776. +       _teamsZ.remove(index);
  3777. +       _teamsY.remove(index);
  3778. +       _teamsX.remove(index);
  3779. +       _teamColors.remove(index);
  3780. +       _teamPointsCount.remove(index);
  3781. +       _teamPlayersCount.remove(index);
  3782. +       _teams.remove(index);
  3783. +      
  3784. +       removeTeamEventItems(teamName);
  3785. +   }
  3786. +  
  3787. +   /**
  3788. +    * Removes the team event items.
  3789. +    * @param teamName the team name
  3790. +    */
  3791. +   private static void removeTeamEventItems(String teamName)
  3792. +   {
  3793. +       _teams.indexOf(teamName);
  3794. +      
  3795. +       //
  3796. +   }
  3797. +  
  3798. +   /**
  3799. +    * Sets the team pos.
  3800. +    * @param teamName the team name
  3801. +    * @param player the player
  3802. +    */
  3803. +   public static void setTeamPos(String teamName, Player player)
  3804. +   {
  3805. +       final int index = _teams.indexOf(teamName);
  3806. +       if (index == -1)
  3807. +       {
  3808. +           return;
  3809. +       }
  3810. +      
  3811. +       _teamsX.set(index, player.getX());
  3812. +       _teamsY.set(index, player.getY());
  3813. +       _teamsZ.set(index, player.getZ());
  3814. +   }
  3815. +  
  3816. +   /**
  3817. +    * Sets the team pos.
  3818. +    * @param teamName the team name
  3819. +    * @param x the x
  3820. +    * @param y the y
  3821. +    * @param z the z
  3822. +    */
  3823. +   public static void setTeamPos(String teamName, int x, int y, int z)
  3824. +   {
  3825. +       final int index = _teams.indexOf(teamName);
  3826. +       if (index == -1)
  3827. +       {
  3828. +           return;
  3829. +       }
  3830. +      
  3831. +       _teamsX.set(index, x);
  3832. +       _teamsY.set(index, y);
  3833. +       _teamsZ.set(index, z);
  3834. +   }
  3835. +  
  3836. +   /**
  3837. +    * Sets the team color.
  3838. +    * @param teamName the team name
  3839. +    * @param color the color
  3840. +    */
  3841. +   public static void setTeamColor(String teamName, int color)
  3842. +   {
  3843. +       if (_inProgress)
  3844. +       {
  3845. +           return;
  3846. +       }
  3847. +      
  3848. +       final int index = _teams.indexOf(teamName);
  3849. +       if (index == -1)
  3850. +       {
  3851. +           return;
  3852. +       }
  3853. +      
  3854. +       _teamColors.set(index, color);
  3855. +   }
  3856. +  
  3857. +   /**
  3858. +    * Team players count.
  3859. +    * @param teamName the team name
  3860. +    * @return the int
  3861. +    */
  3862. +   public static int teamPlayersCount(String teamName)
  3863. +   {
  3864. +       final int index = _teams.indexOf(teamName);
  3865. +       if (index == -1)
  3866. +       {
  3867. +           return -1;
  3868. +       }
  3869. +       return _teamPlayersCount.get(index);
  3870. +   }
  3871. +  
  3872. +   /**
  3873. +    * Sets the team players count.
  3874. +    * @param teamName the team name
  3875. +    * @param teamPlayersCount the team players count
  3876. +    */
  3877. +   public static void setTeamPlayersCount(String teamName, int teamPlayersCount)
  3878. +   {
  3879. +       final int index = _teams.indexOf(teamName);
  3880. +       if (index == -1)
  3881. +       {
  3882. +           return;
  3883. +       }
  3884. +      
  3885. +       _teamPlayersCount.set(index, teamPlayersCount);
  3886. +   }
  3887. +  
  3888. +   /**
  3889. +    * Check shuffle players.
  3890. +    * @param eventPlayer the event player
  3891. +    * @return true, if successful
  3892. +    */
  3893. +   public static boolean checkShufflePlayers(Player eventPlayer)
  3894. +   {
  3895. +       try
  3896. +       {
  3897. +           for (Player player : _playersShuffle)
  3898. +           {
  3899. +               if ((player == null) || !player.isOnline())
  3900. +               {
  3901. +                   _playersShuffle.remove(player);
  3902. +                   eventPlayer._inEventTvT = false;
  3903. +               }
  3904. +               else if (player.getObjectId() == eventPlayer.getObjectId())
  3905. +               {
  3906. +                   eventPlayer._inEventTvT = true;
  3907. +                   eventPlayer._countTvTkills = 0;
  3908. +                   return true;
  3909. +               }
  3910. +               // This 1 is incase player got new objectid after DC or reconnect
  3911. +               else if (player.getName().equals(eventPlayer.getName()))
  3912. +               {
  3913. +                   _playersShuffle.remove(player);
  3914. +                   _playersShuffle.add(eventPlayer);
  3915. +                   eventPlayer._inEventTvT = true;
  3916. +                   eventPlayer._countTvTkills = 0;
  3917. +                   return true;
  3918. +               }
  3919. +           }
  3920. +       }
  3921. +       catch (Exception e)
  3922. +       {
  3923. +       }
  3924. +       return false;
  3925. +   }
  3926. +  
  3927. +   /**
  3928. +    * just an announcer to send termination messages.
  3929. +    */
  3930. +   public static void sendFinalMessages()
  3931. +   {
  3932. +       if (!_started && !_aborted)
  3933. +       {
  3934. +           AnnouncementsTable.getInstance().criticalAnnounceToAll(_eventName + ": Thank you For Participating At, " + _eventName + " Event.");
  3935. +       }
  3936. +   }
  3937. +  
  3938. +   /**
  3939. +    * returns the interval between each event.
  3940. +    * @return the interval between matchs
  3941. +    */
  3942. +   public static int getIntervalBetweenMatchs()
  3943. +   {
  3944. +       final long actualTime = System.currentTimeMillis();
  3945. +       final long totalTime = actualTime + _intervalBetweenMatches;
  3946. +       final long interval = totalTime - actualTime;
  3947. +       final int seconds = (int) (interval / 1000);
  3948. +       return seconds / 60;
  3949. +   }
  3950. +  
  3951. +   @Override
  3952. +   public void run()
  3953. +   {
  3954. +       LOGGER.info(_eventName + ": Event notification start");
  3955. +       eventOnceStart();
  3956. +   }
  3957. +  
  3958. +   @Override
  3959. +   public String getEventIdentifier()
  3960. +   {
  3961. +       return _eventName;
  3962. +   }
  3963. +  
  3964. +   @Override
  3965. +   public String getEventStartTime()
  3966. +   {
  3967. +       return startEventTime;
  3968. +   }
  3969. +  
  3970. +   /**
  3971. +    * Sets the event start time.
  3972. +    * @param newTime the new event start time
  3973. +    */
  3974. +   public void setEventStartTime(String newTime)
  3975. +   {
  3976. +       startEventTime = newTime;
  3977. +   }
  3978. +  
  3979. +   /**
  3980. +    * On disconnect.
  3981. +    * @param player the player
  3982. +    */
  3983. +   public static void onDisconnect(Player player)
  3984. +   {
  3985. +       if (player._inEventTvT)
  3986. +       {
  3987. +           removePlayer(player);
  3988. +           player.teleToLocation(_npcX, _npcY, _npcZ);
  3989. +       }
  3990. +   }
  3991. +  
  3992. +   /**
  3993. +    * Team kills count.
  3994. +    * @param teamName the team name
  3995. +    * @return the int
  3996. +    */
  3997. +   public static int teamKillsCount(String teamName)
  3998. +   {
  3999. +       final int index = _teams.indexOf(teamName);
  4000. +       if (index == -1)
  4001. +       {
  4002. +           return -1;
  4003. +       }
  4004. +       return _teamPointsCount.get(index);
  4005. +   }
  4006. +  
  4007. +   /**
  4008. +    * Sets the team kills count.
  4009. +    * @param teamName the team name
  4010. +    * @param teamKillsCount the team kills count
  4011. +    */
  4012. +   public static void setTeamKillsCount(String teamName, int teamKillsCount)
  4013. +   {
  4014. +       final int index = _teams.indexOf(teamName);
  4015. +       if (index == -1)
  4016. +       {
  4017. +           return;
  4018. +       }
  4019. +      
  4020. +       _teamPointsCount.set(index, teamKillsCount);
  4021. +   }
  4022. +  
  4023. +   /**
  4024. +    * Kick player from tvt.
  4025. +    * @param playerToKick the player to kick
  4026. +    */
  4027. +   public static void kickPlayerFromTvt(Player playerToKick)
  4028. +   {
  4029. +       if (playerToKick == null)
  4030. +       {
  4031. +           return;
  4032. +       }
  4033. +      
  4034. +       synchronized (_players)
  4035. +       {
  4036. +           if (_joining)
  4037. +           {
  4038. +               _playersShuffle.remove(playerToKick);
  4039. +               _players.remove(playerToKick);
  4040. +               playerToKick._inEventTvT = false;
  4041. +               playerToKick._teamNameTvT = "";
  4042. +               playerToKick._countTvTkills = 0;
  4043. +           }
  4044. +       }
  4045. +      
  4046. +       if (_started || _teleport)
  4047. +       {
  4048. +           _playersShuffle.remove(playerToKick);
  4049. +           removePlayer(playerToKick);
  4050. +           if (playerToKick.isOnline())
  4051. +           {
  4052. +               playerToKick.getAppearance().setNameColor(playerToKick._originalNameColorTvT);
  4053. +               playerToKick.setKarma(playerToKick._originalKarmaTvT);
  4054. +               playerToKick.setTitle(playerToKick._originalTitleTvT);
  4055. +               playerToKick.broadcastUserInfo();
  4056. +               playerToKick.sendMessage("You have been kicked from the TvT.");
  4057. +               playerToKick.teleToLocation(_npcX, _npcY, _npcZ);
  4058. +               playerToKick.teleToLocation((_npcX + Rnd.get(201)) - 100, (_npcY + Rnd.get(201)) - 100, _npcZ);
  4059. +           }
  4060. +       }
  4061. +   }
  4062. +  
  4063. +   /**
  4064. +    * Find best killer.
  4065. +    * @param players the players
  4066. +    * @return the pc instance
  4067. +    */
  4068. +   public static Player findBestKiller(List<Player> players)
  4069. +   {
  4070. +       if (players == null)
  4071. +       {
  4072. +           return null;
  4073. +       }
  4074. +       Player bestKiller = null;
  4075. +       for (Player player : players)
  4076. +       {
  4077. +           if ((bestKiller == null) || (bestKiller._countTvTkills < player._countTvTkills))
  4078. +           {
  4079. +               bestKiller = player;
  4080. +           }
  4081. +       }
  4082. +       return bestKiller;
  4083. +   }
  4084. +  
  4085. +   /**
  4086. +    * Find looser.
  4087. +    * @param players the players
  4088. +    * @return the pc instance
  4089. +    */
  4090. +   public static Player findLooser(List<Player> players)
  4091. +   {
  4092. +       if (players == null)
  4093. +       {
  4094. +           return null;
  4095. +       }
  4096. +       Player looser = null;
  4097. +       for (Player player : players)
  4098. +       {
  4099. +           if ((looser == null) || (looser._countTvTdies < player._countTvTdies))
  4100. +           {
  4101. +               looser = player;
  4102. +           }
  4103. +       }
  4104. +       return looser;
  4105. +   }
  4106. +  
  4107. +   /**
  4108. +    * The Class TvTTeam.
  4109. +    */
  4110. +   public static class TvTTeam
  4111. +   {
  4112. +       /** The kill count. */
  4113. +       private int killCount = -1;
  4114. +      
  4115. +       /** The name. */
  4116. +       private String name = null;
  4117. +      
  4118. +       /**
  4119. +        * Instantiates a new tvt team.
  4120. +        * @param name the name
  4121. +        * @param killCount the kill count
  4122. +        */
  4123. +       TvTTeam(String name, int killCount)
  4124. +       {
  4125. +           this.killCount = killCount;
  4126. +           this.name = name;
  4127. +       }
  4128. +      
  4129. +       /**
  4130. +        * Gets the kill count.
  4131. +        * @return the kill count
  4132. +        */
  4133. +       public int getKillCount()
  4134. +       {
  4135. +           return killCount;
  4136. +       }
  4137. +      
  4138. +       /**
  4139. +        * Sets the kill count.
  4140. +        * @param killCount the new kill count
  4141. +        */
  4142. +       public void setKillCount(int killCount)
  4143. +       {
  4144. +           this.killCount = killCount;
  4145. +       }
  4146. +      
  4147. +       /**
  4148. +        * Gets the name.
  4149. +        * @return the name
  4150. +        */
  4151. +       public String getName()
  4152. +       {
  4153. +           return name;
  4154. +       }
  4155. +      
  4156. +       /**
  4157. +        * Sets the name.
  4158. +        * @param name the new name
  4159. +        */
  4160. +       public void setName(String name)
  4161. +       {
  4162. +           this.name = name;
  4163. +       }
  4164. +   }
  4165. +  
  4166. +   /**
  4167. +    * Close fort doors.
  4168. +    */
  4169. +   private static void closeFortDoors()
  4170. +   {
  4171. +       DoorData.getInstance().getDoor(23170004).closeMe();
  4172. +       DoorData.getInstance().getDoor(23170005).closeMe();
  4173. +       DoorData.getInstance().getDoor(23170002).closeMe();
  4174. +       DoorData.getInstance().getDoor(23170003).closeMe();
  4175. +       DoorData.getInstance().getDoor(23170006).closeMe();
  4176. +       DoorData.getInstance().getDoor(23170007).closeMe();
  4177. +       DoorData.getInstance().getDoor(23170008).closeMe();
  4178. +       DoorData.getInstance().getDoor(23170009).closeMe();
  4179. +       DoorData.getInstance().getDoor(23170010).closeMe();
  4180. +       DoorData.getInstance().getDoor(23170011).closeMe();
  4181. +      
  4182. +       try
  4183. +       {
  4184. +           Thread.sleep(20);
  4185. +       }
  4186. +       catch (InterruptedException ie)
  4187. +       {
  4188. +           LOGGER.warning("Error, " + ie.getMessage());
  4189. +       }
  4190. +   }
  4191. +  
  4192. +   /**
  4193. +    * Open fort doors.
  4194. +    */
  4195. +   private static void openFortDoors()
  4196. +   {
  4197. +       DoorData.getInstance().getDoor(23170004).openMe();
  4198. +       DoorData.getInstance().getDoor(23170005).openMe();
  4199. +       DoorData.getInstance().getDoor(23170002).openMe();
  4200. +       DoorData.getInstance().getDoor(23170003).openMe();
  4201. +       DoorData.getInstance().getDoor(23170006).openMe();
  4202. +       DoorData.getInstance().getDoor(23170007).openMe();
  4203. +       DoorData.getInstance().getDoor(23170008).openMe();
  4204. +       DoorData.getInstance().getDoor(23170009).openMe();
  4205. +       DoorData.getInstance().getDoor(23170010).openMe();
  4206. +       DoorData.getInstance().getDoor(23170011).openMe();
  4207. +   }
  4208. +  
  4209. +   /**
  4210. +    * Close aden colosseum doors.
  4211. +    */
  4212. +   private static void closeAdenColosseumDoors()
  4213. +   {
  4214. +       DoorData.getInstance().getDoor(24190002).closeMe();
  4215. +       DoorData.getInstance().getDoor(24190003).closeMe();
  4216. +      
  4217. +       try
  4218. +       {
  4219. +           Thread.sleep(20);
  4220. +       }
  4221. +       catch (InterruptedException ie)
  4222. +       {
  4223. +           LOGGER.warning("Error, " + ie.getMessage());
  4224. +       }
  4225. +   }
  4226. +  
  4227. +   /**
  4228. +    * Open aden colosseum doors.
  4229. +    */
  4230. +   private static void openAdenColosseumDoors()
  4231. +   {
  4232. +       DoorData.getInstance().getDoor(24190002).openMe();
  4233. +       DoorData.getInstance().getDoor(24190003).openMe();
  4234. +   }
  4235. +}
  4236. \ No newline at end of file
  4237. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CursedWeapon.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CursedWeapon.java
  4238. index fae94a4..0fb1b39 100644
  4239. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CursedWeapon.java
  4240. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/CursedWeapon.java
  4241. @@ -22,11 +22,13 @@
  4242.  import java.util.concurrent.ScheduledFuture;
  4243.  import java.util.logging.Logger;
  4244.  
  4245. +import org.l2jmobius.Config;
  4246.  import org.l2jmobius.commons.database.DatabaseFactory;
  4247.  import org.l2jmobius.commons.threads.ThreadPool;
  4248.  import org.l2jmobius.commons.util.Rnd;
  4249.  import org.l2jmobius.gameserver.data.SkillTable;
  4250.  import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
  4251. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  4252.  import org.l2jmobius.gameserver.model.actor.Attackable;
  4253.  import org.l2jmobius.gameserver.model.actor.Creature;
  4254.  import org.l2jmobius.gameserver.model.actor.Player;
  4255. @@ -345,6 +347,10 @@
  4256.                 return;
  4257.             }
  4258.         }
  4259. +       if ((player._inEventTvT && !Config.TVT_JOIN_CURSED) && player._inEventTvT)
  4260. +       {
  4261. +           TvT.removePlayer(player);
  4262. +       }
  4263.        
  4264.         _isActivated = true;
  4265.        
  4266. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java
  4267. index 9958f07..55a674b 100644
  4268. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java
  4269. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java
  4270. @@ -23,11 +23,13 @@
  4271.  import java.util.StringTokenizer;
  4272.  import java.util.logging.Logger;
  4273.  
  4274. +import org.l2jmobius.Config;
  4275.  import org.l2jmobius.gameserver.data.SkillTable;
  4276.  import org.l2jmobius.gameserver.data.sql.SkillTreeTable;
  4277.  import org.l2jmobius.gameserver.enums.ClassId;
  4278.  import org.l2jmobius.gameserver.geoengine.GeoEngine;
  4279.  import org.l2jmobius.gameserver.instancemanager.SiegeManager;
  4280. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  4281.  import org.l2jmobius.gameserver.model.actor.Attackable;
  4282.  import org.l2jmobius.gameserver.model.actor.Creature;
  4283.  import org.l2jmobius.gameserver.model.actor.Npc;
  4284. @@ -1568,11 +1570,32 @@
  4285.                                     continue;
  4286.                                 }
  4287.                                 // if src is in event and trg not or viceversa
  4288. -                               if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4289. +                               // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4290. +                               if (((src.isOnEvent() || src._inEventTvT) && (!trg.isOnEvent() && !trg._inEventTvT)) || ((trg.isOnEvent() || trg._inEventTvT) && (!src.isOnEvent() && !src._inEventTvT)))
  4291.                                 {
  4292.                                     continue;
  4293.                                 }
  4294. +                              
  4295. +                               // // if src is in event and trg not or viceversa
  4296. +                               // if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4297. +                               // {
  4298. +                               // continue;
  4299. +                               // }
  4300.                             }
  4301. +                           // else if (obj instanceof Summon)
  4302. +                           // {
  4303. +                           // final Player trg = ((Summon) obj).getOwner();
  4304. +                           // if (trg == src)
  4305. +                           // {
  4306. +                           // continue;
  4307. +                           // }
  4308. +                           // // if src is in event and trg not or viceversa
  4309. +                           // if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4310. +                           // {
  4311. +                           // continue;
  4312. +                           // }
  4313. +                           // }
  4314. +                          
  4315.                             else if (obj instanceof Summon)
  4316.                             {
  4317.                                 final Player trg = ((Summon) obj).getOwner();
  4318. @@ -1581,7 +1604,8 @@
  4319.                                     continue;
  4320.                                 }
  4321.                                 // if src is in event and trg not or viceversa
  4322. -                               if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4323. +                               // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4324. +                               if (((src.isOnEvent() || src._inEventTvT) && (!trg.isOnEvent() && !trg._inEventTvT)) || ((trg.isOnEvent() || trg._inEventTvT) && (!src.isOnEvent() && !src._inEventTvT)))
  4325.                                 {
  4326.                                     continue;
  4327.                                 }
  4328. @@ -1710,8 +1734,28 @@
  4329.                             {
  4330.                                 continue;
  4331.                             }
  4332. +                           // // if src is in event and trg not or viceversa
  4333. +                           // if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4334. +                           // {
  4335. +                           // continue;
  4336. +                           // }
  4337. +                           // }
  4338. +                           // else if (obj instanceof Summon)
  4339. +                           // {
  4340. +                           // final Player trg = ((Summon) obj).getOwner();
  4341. +                           // if (trg == src)
  4342. +                           // {
  4343. +                           // continue;
  4344. +                           // }
  4345. +                           // // if src is in event and trg not or viceversa
  4346. +                           // if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4347. +                           // {
  4348. +                           // continue;
  4349. +                           // }
  4350. +                           // }
  4351.                             // if src is in event and trg not or viceversa
  4352. -                           if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4353. +                           // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4354. +                           if (((src.isOnEvent() || src._inEventTvT) && (!trg.isOnEvent() && !trg._inEventTvT)) || ((trg.isOnEvent() || trg._inEventTvT) && (!src.isOnEvent() && !src._inEventTvT)))
  4355.                             {
  4356.                                 continue;
  4357.                             }
  4358. @@ -1724,7 +1768,8 @@
  4359.                                 continue;
  4360.                             }
  4361.                             // if src is in event and trg not or viceversa
  4362. -                           if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4363. +                           // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4364. +                           if (((src.isOnEvent() || src._inEventTvT) && (!trg.isOnEvent() && !trg._inEventTvT)) || ((trg.isOnEvent() || trg._inEventTvT) && (!src.isOnEvent() && !src._inEventTvT)))
  4365.                             {
  4366.                                 continue;
  4367.                             }
  4368. @@ -1779,7 +1824,14 @@
  4369.                         {
  4370.                             continue;
  4371.                         }
  4372. -                      
  4373. +                       // check if allow interference is allowed if player is not on event but target is on event
  4374. +                       if (((TvT.isStarted() && !Config.TVT_ALLOW_INTERFERENCE))/* && !player.isGM() */)
  4375. +                       {
  4376. +                           if ((partyMember._inEventTvT && !player._inEventTvT) || (!partyMember._inEventTvT && player._inEventTvT))
  4377. +                           {
  4378. +                               continue;
  4379. +                           }
  4380. +                       }
  4381.                         if (!partyMember.isDead() && Util.checkIfInRange(_skillRadius, creature, partyMember, true))
  4382.                         {
  4383.                             Player src = null;
  4384. @@ -1791,13 +1843,19 @@
  4385.                             {
  4386.                                 src = ((Summon) creature).getOwner();
  4387.                             }
  4388. +                          
  4389.                             final Player trg = partyMember;
  4390. +                           // // if src is in event and trg not or viceversa
  4391. +                           // if ((src != null) && ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent())))
  4392. +                           // {
  4393. +                           // continue;
  4394. +                           // }
  4395.                             // if src is in event and trg not or viceversa
  4396. -                           if ((src != null) && ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent())))
  4397. +                           // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4398. +                           if ((src != null) && (((src.isOnEvent() || src._inEventTvT) && (!trg.isOnEvent() && !trg._inEventTvT)) || ((trg.isOnEvent() || trg._inEventTvT) && (!src.isOnEvent() && !src._inEventTvT))))
  4399.                             {
  4400.                                 continue;
  4401.                             }
  4402. -                          
  4403.                             targetList.add(partyMember);
  4404.                             if ((partyMember.getPet() != null) && !partyMember.getPet().isDead())
  4405.                             {
  4406. @@ -1926,11 +1984,15 @@
  4407.                             final Player trg = newTarget;
  4408.                             final Player src = player;
  4409.                             // if src is in event and trg not or viceversa
  4410. -                           if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4411. +                           // if ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent()))
  4412. +                           // {
  4413. +                           // continue;
  4414. +                           // }
  4415. +                           // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4416. +                           if (((src.isOnEvent() || src._inEventTvT) && (!trg.isOnEvent() && !trg._inEventTvT)) || ((trg.isOnEvent() || trg._inEventTvT) && (!src.isOnEvent() && !src._inEventTvT)))
  4417.                             {
  4418.                                 continue;
  4419.                             }
  4420. -                          
  4421.                             final Summon pet = newTarget.getPet();
  4422.                             if ((pet != null) && Util.checkIfInRange(radius, creature, pet, true) && !onlyFirst && (((_targetType == SkillTargetType.CORPSE_CLAN) && pet.isDead()) || ((_targetType == SkillTargetType.CLAN) && !pet.isDead())) && player.checkPvpSkill(newTarget, this))
  4423.                             {
  4424. @@ -2176,11 +2238,15 @@
  4425.                         }
  4426.                        
  4427.                         // if src is in event and trg not or viceversa
  4428. -                       if ((src != null) && (trg != null) && ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent())))
  4429. +                       // if ((src != null) && (trg != null) && ((src.isOnEvent() && !trg.isOnEvent()) || (trg.isOnEvent() && !src.isOnEvent())))
  4430. +                       // {
  4431. +                       // continue;
  4432. +                       // }
  4433. +                       // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4434. +                       if ((src != null) && (trg != null) && (((src.isOnEvent() || src._inEventTvT) && (!trg.isOnEvent() && !trg._inEventTvT)) || ((trg.isOnEvent() || trg._inEventTvT) && (!src.isOnEvent() && !src._inEventTvT))))
  4435.                         {
  4436.                             continue;
  4437.                         }
  4438. -                      
  4439.                         targetList.add((Creature) obj);
  4440.                     }
  4441.                 }
  4442. @@ -2654,16 +2720,25 @@
  4443.             }
  4444.            
  4445.             // if src is in event and trg not OR viceversa, the target must be not attackable
  4446. -           if ((activeCh.isOnEvent() && !targetChar.isOnEvent()) || (targetChar.isOnEvent() && !activeCh.isOnEvent()))
  4447. +           // if ((activeCh.isOnEvent() && !targetChar.isOnEvent()) || (targetChar.isOnEvent() && !activeCh.isOnEvent()))
  4448. +           // {
  4449. +           // return true;
  4450. +           // }
  4451. +           //
  4452. +           // if (activeCh.isOnEvent() && targetChar.isOnEvent())
  4453. +           // {
  4454. +           // return false;
  4455. +           // }
  4456. +           // to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
  4457. +           if (((activeCh.isOnEvent() || activeCh._inEventTvT) && (!targetChar.isOnEvent() && !targetChar._inEventTvT)) || ((targetChar.isOnEvent() || targetChar._inEventTvT) && (!activeCh.isOnEvent() && !activeCh._inEventTvT)))
  4458.             {
  4459.                 return true;
  4460.             }
  4461.            
  4462. -           if (activeCh.isOnEvent() && targetChar.isOnEvent())
  4463. +           if ((activeCh.isOnEvent() && targetChar.isOnEvent()) || (activeCh._inEventTvT && targetChar._inEventTvT))
  4464.             {
  4465.                 return false;
  4466.             }
  4467. -          
  4468.             // Is in the same party?
  4469.             if ((activeCh.getParty() != null) && (targetChar.getParty() != null) && (activeCh.getParty().getPartyLeaderOID() == targetChar.getParty().getPartyLeaderOID()))
  4470.             {
  4471. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java
  4472. index e6fc06d..676b25a 100644
  4473. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java
  4474. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java
  4475. @@ -53,6 +53,8 @@
  4476.  import org.l2jmobius.gameserver.instancemanager.DuelManager;
  4477.  import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
  4478.  import org.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
  4479. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
  4480. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  4481.  import org.l2jmobius.gameserver.model.Duel;
  4482.  import org.l2jmobius.gameserver.model.ForceBuff;
  4483.  import org.l2jmobius.gameserver.model.Location;
  4484. @@ -1845,6 +1847,21 @@
  4485.         }
  4486.         else if (this instanceof Player)
  4487.         {
  4488. +           final Player player = (Player) this;
  4489. +          
  4490. +           // to avoid Event Remove buffs on die
  4491. +           if (player._inEventTvT && TvT.isStarted())
  4492. +           {
  4493. +               if (Config.TVT_REMOVE_BUFFS_ON_DIE)
  4494. +               {
  4495. +                   stopAllEffects();
  4496. +               }
  4497. +           }
  4498. +          
  4499. +       }
  4500. +      
  4501. +       else if (this instanceof Player)
  4502. +       {
  4503.             if (Config.LEAVE_BUFFS_ON_DIE)
  4504.             {
  4505.                 stopAllEffects();
  4506. @@ -5361,6 +5378,22 @@
  4507.      */
  4508.     protected void moveToLocation(int xValue, int yValue, int zValue, int offsetValue)
  4509.     {
  4510. +       // Block movement during Event start
  4511. +       if (isPlayer())
  4512. +       {
  4513. +           if (GameEvent.active && getActingPlayer().eventSitForced)
  4514. +           {
  4515. +               getActingPlayer().sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up...");
  4516. +               getActingPlayer().getClient().sendPacket(ActionFailed.STATIC_PACKET);
  4517. +               return;
  4518. +           }
  4519. +           else if ((TvT.isSitForced() && getActingPlayer()._inEventTvT))
  4520. +           {
  4521. +               getActingPlayer().sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up...");
  4522. +               getActingPlayer().getClient().sendPacket(ActionFailed.STATIC_PACKET);
  4523. +               return;
  4524. +           }
  4525. +       }
  4526.         // Get the Move Speed of the Creature
  4527.         final float speed = getStat().getMoveSpeed();
  4528.         if ((speed <= 0) || isMovementDisabled())
  4529. @@ -6484,6 +6517,13 @@
  4530.             {
  4531.                 return false;
  4532.             }
  4533. +           if (dst.isInFunEvent() && src.isInFunEvent())
  4534. +           {
  4535. +               if (src.isInStartedTVTEvent() && dst.isInStartedTVTEvent())
  4536. +               {
  4537. +                   return false;
  4538. +               }
  4539. +           }
  4540.            
  4541.             if (dst.isOnEvent() && src.isOnEvent())
  4542.             {
  4543. @@ -7176,6 +7216,102 @@
  4544.         }
  4545.     }
  4546.    
  4547. +   private boolean _ArenaProtection;
  4548. +  
  4549. +   public void setArenaProtection(boolean comm)
  4550. +   {
  4551. +       _ArenaProtection = comm;
  4552. +   }
  4553. +  
  4554. +   public boolean isArenaProtection()
  4555. +   {
  4556. +       return _ArenaProtection;
  4557. +   }
  4558. +  
  4559. +   private boolean inArenaEvent = false;
  4560. +  
  4561. +   public void setInArenaEvent(boolean val)
  4562. +   {
  4563. +       inArenaEvent = val;
  4564. +   }
  4565. +  
  4566. +   public boolean isInArenaEvent()
  4567. +   {
  4568. +       return inArenaEvent;
  4569. +   }
  4570. +  
  4571. +   private boolean _ArenaAttack;
  4572. +  
  4573. +   public void setArenaAttack(boolean comm)
  4574. +   {
  4575. +       _ArenaAttack = comm;
  4576. +   }
  4577. +  
  4578. +   public boolean isArenaAttack()
  4579. +   {
  4580. +       return _ArenaAttack;
  4581. +   }
  4582. +  
  4583. +   private boolean _Arena1x1;
  4584. +  
  4585. +   public void setArena1x1(boolean comm)
  4586. +   {
  4587. +       _Arena1x1 = comm;
  4588. +   }
  4589. +  
  4590. +   public boolean isArena1x1()
  4591. +   {
  4592. +       return _Arena1x1;
  4593. +   }
  4594. +  
  4595. +   private boolean _Arena3x3;
  4596. +  
  4597. +   public void setArena3x3(boolean comm)
  4598. +   {
  4599. +       _Arena3x3 = comm;
  4600. +   }
  4601. +  
  4602. +   public boolean isArena3x3()
  4603. +   {
  4604. +       return _Arena3x3;
  4605. +   }
  4606. +  
  4607. +   private boolean _Arena5x5;
  4608. +  
  4609. +   public void setArena5x5(boolean comm)
  4610. +   {
  4611. +       _Arena5x5 = comm;
  4612. +   }
  4613. +  
  4614. +   public boolean isArena5x5()
  4615. +   {
  4616. +       return _Arena5x5;
  4617. +   }
  4618. +  
  4619. +   private boolean _Arena9x9;
  4620. +  
  4621. +   public void setArena9x9(boolean comm)
  4622. +   {
  4623. +       _Arena9x9 = comm;
  4624. +   }
  4625. +  
  4626. +   public boolean isArena9x9()
  4627. +   {
  4628. +       return _Arena9x9;
  4629. +   }
  4630. +  
  4631. +   private boolean _ArenaObserv;
  4632. +  
  4633. +   public void setArenaObserv(boolean comm)
  4634. +   {
  4635. +       _ArenaObserv = comm;
  4636. +   }
  4637. +  
  4638. +   public boolean isArenaObserv()
  4639. +   {
  4640. +       return _ArenaObserv;
  4641. +   }
  4642. +  
  4643.     /**
  4644.      * On magic hit timer.
  4645.      * @param targets the targets
  4646. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java
  4647. index a47a65f..1bfb32d 100644
  4648. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java
  4649. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java
  4650. @@ -41,6 +41,8 @@
  4651.  import org.l2jmobius.gameserver.instancemanager.IdManager;
  4652.  import org.l2jmobius.gameserver.instancemanager.QuestManager;
  4653.  import org.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
  4654. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
  4655. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  4656.  import org.l2jmobius.gameserver.instancemanager.games.Lottery;
  4657.  import org.l2jmobius.gameserver.model.DropCategory;
  4658.  import org.l2jmobius.gameserver.model.DropData;
  4659. @@ -118,6 +120,10 @@
  4660.     private boolean _isSpoil = false;
  4661.     private int _castleIndex = -2;
  4662.     private int _fortIndex = -2;
  4663. +   public boolean isEventMob = false;
  4664. +   public boolean _isEventMobTvT = false;
  4665. +   public boolean _isEventVIPNPC = false;
  4666. +   public boolean _isEventVIPNPCEnd = false;
  4667.     private boolean _isInTown = false;
  4668.     private final boolean _isQuestMonster = getTemplate().isQuestMonster();
  4669.     private int _isSpoiledBy = 0;
  4670. @@ -654,6 +660,15 @@
  4671.                    
  4672.                     // Send a Server->Client packet SocialAction to the all Player on the _knownPlayer of the Npc to display a social action of the Npc on their client
  4673.                     broadcastSocialAction(Rnd.get(8));
  4674. +                   // Open a chat window on client with the text of the NpcInstance
  4675. +                   if (isEventMob)
  4676. +                   {
  4677. +                       GameEvent.showEventHtml(player, String.valueOf(getObjectId()));
  4678. +                   }
  4679. +                   else if (_isEventMobTvT)
  4680. +                   {
  4681. +                       TvT.showEventHtml(player, String.valueOf(getObjectId()));
  4682. +                   }
  4683.                    
  4684.                     final List<Quest> questList = getTemplate().getEventQuests(EventType.NPC_FIRST_TALK);
  4685.                     if (questList.size() == 1)
  4686. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Playable.java
  4687. index 15b726b..84d70d6 100644
  4688. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Playable.java
  4689. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Playable.java
  4690. @@ -458,6 +458,16 @@
  4691.         _lastCharmOfLuckEffect = null;
  4692.     }
  4693.    
  4694. +   /**
  4695. +    * Checks if is in fun event.
  4696. +    * @return true, if is in fun event
  4697. +    */
  4698. +   public boolean isInFunEvent()
  4699. +   {
  4700. +       final Player player = getActingPlayer();
  4701. +       return (player != null) && player.isInFunEvent();
  4702. +   }
  4703. +  
  4704.     public boolean isOnEvent()
  4705.     {
  4706.         return false;
  4707. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java
  4708. index ce1f47c..9deda4a 100644
  4709. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java
  4710. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java
  4711. @@ -24,6 +24,7 @@
  4712.  import java.util.Collection;
  4713.  import java.util.Date;
  4714.  import java.util.HashMap;
  4715. +import java.util.LinkedList;
  4716.  import java.util.List;
  4717.  import java.util.Map;
  4718.  import java.util.Map.Entry;
  4719. @@ -84,6 +85,8 @@
  4720.  import org.l2jmobius.gameserver.instancemanager.RebirthManager;
  4721.  import org.l2jmobius.gameserver.instancemanager.RecipeManager;
  4722.  import org.l2jmobius.gameserver.instancemanager.SiegeManager;
  4723. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
  4724. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  4725.  import org.l2jmobius.gameserver.model.AccessLevel;
  4726.  import org.l2jmobius.gameserver.model.BlockList;
  4727.  import org.l2jmobius.gameserver.model.Duel;
  4728. @@ -204,6 +207,7 @@
  4729.  import org.l2jmobius.gameserver.network.serverpackets.ObservationReturn;
  4730.  import org.l2jmobius.gameserver.network.serverpackets.PartySmallWindowUpdate;
  4731.  import org.l2jmobius.gameserver.network.serverpackets.PetInventoryUpdate;
  4732. +import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
  4733.  import org.l2jmobius.gameserver.network.serverpackets.PledgeShowInfoUpdate;
  4734.  import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListDelete;
  4735.  import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
  4736. @@ -326,6 +330,29 @@
  4737.     private boolean _isAio = false;
  4738.     private long _aioEndTime = 0;
  4739.     private boolean _expGain = true;
  4740. +   // event mod
  4741. +   public int eventX;
  4742. +   public int eventY;
  4743. +   public int eventZ;
  4744. +   public int eventKarma;
  4745. +   public int eventPvpKills;
  4746. +   public int eventPkKills;
  4747. +   public String eventTitle;
  4748. +   public List<String> kills = new LinkedList<>();
  4749. +   public boolean eventSitForced = false;
  4750. +   public boolean atEvent = false;
  4751. +   public String _teamNameTvT;
  4752. +   public String _originalTitleTvT;
  4753. +   public int _originalNameColorTvT = 0;
  4754. +   public int _countTvTkills;
  4755. +   public int _countTvTdies;
  4756. +   public int _originalKarmaTvT;
  4757. +   public boolean _inEventTvT = false;
  4758. +   public int _originalNameColor;
  4759. +   public int _countKills;
  4760. +   public int _originalKarma;
  4761. +   public int _eventKills;
  4762. +   public boolean _inEvent = false;
  4763.     private boolean _inOlympiadMode = false;
  4764.     private boolean _olympiadStart = false;
  4765.     private int[] _olympiadPosition;
  4766. @@ -411,6 +438,7 @@
  4767.     private boolean _messageRefusal = false; // message refusal mode
  4768.     private boolean _dietMode = false; // ignore weight penalty
  4769.     private boolean _exchangeRefusal = false; // Exchange refusal
  4770. +   private boolean _isPartyInRefuse = false; // Party Refusal Mode
  4771.     private Party _party;
  4772.     private Player _activeRequester;
  4773.     private long _requestExpireTime = 0;
  4774. @@ -639,6 +667,13 @@
  4775.                 return;
  4776.             }
  4777.            
  4778. +           // during teleport phase, players cant do any attack
  4779. +           if ((TvT.isTeleport() && _inEventTvT))
  4780. +           {
  4781. +               sendPacket(ActionFailed.STATIC_PACKET);
  4782. +               return;
  4783. +           }
  4784. +          
  4785.             // Pk protection config
  4786.             if (Config.ALLOW_CHAR_KILL_PROTECT && !isGM() && target.isPlayer() && (target.getActingPlayer().getPvpFlag() == 0) && (target.getActingPlayer().getKarma() == 0))
  4787.             {
  4788. @@ -685,7 +720,12 @@
  4789.                 sendPacket(ActionFailed.STATIC_PACKET);
  4790.                 return;
  4791.             }
  4792. -          
  4793. +           // during teleport phase, players cant do any attack
  4794. +           if ((TvT.isTeleport() && _inEventTvT))
  4795. +           {
  4796. +               sendPacket(ActionFailed.STATIC_PACKET);
  4797. +               return;
  4798. +           }
  4799.             super.doCast(skill);
  4800.            
  4801.             if (!skill.isOffensive())
  4802. @@ -3174,7 +3214,14 @@
  4803.             ThreadPool.schedule(new StandUpTask(this), 2000);
  4804.             stopFakeDeath(null);
  4805.         }
  4806. -      
  4807. +       if (GameEvent.active && eventSitForced)
  4808. +       {
  4809. +           sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ...");
  4810. +       }
  4811. +       else if ((TvT.isSitForced() && _inEventTvT))
  4812. +       {
  4813. +           sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up...");
  4814. +       }
  4815.         if (_waitTypeSitting && !isInStoreMode() && !isAlikeDead())
  4816.         {
  4817.             if (_relax)
  4818. @@ -4250,6 +4297,15 @@
  4819.     @Override
  4820.     public void onAction(Player player)
  4821.     {
  4822. +       // no Interaction with not participant to events
  4823. +       if (((TvT.isStarted() || TvT.isTeleport()) && !Config.TVT_ALLOW_INTERFERENCE))
  4824. +       {
  4825. +           if ((_inEventTvT && !player._inEventTvT) || (!_inEventTvT && player._inEventTvT))
  4826. +           {
  4827. +               player.sendPacket(ActionFailed.STATIC_PACKET);
  4828. +               return;
  4829. +           }
  4830. +       }
  4831.         // Check if the Player is confused
  4832.         if (player.isOutOfControl())
  4833.         {
  4834. @@ -4349,6 +4405,14 @@
  4835.         }
  4836.         else // Like L2OFF set the target of the Player player
  4837.         {
  4838. +           if (((TvT.isStarted() || TvT.isTeleport()) && !Config.TVT_ALLOW_INTERFERENCE))
  4839. +           {
  4840. +               if ((_inEventTvT && !player._inEventTvT) || (!_inEventTvT && player._inEventTvT))
  4841. +               {
  4842. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  4843. +                   return;
  4844. +               }
  4845. +           }
  4846.             // Check if the Player is confused
  4847.             if (player.isOutOfControl())
  4848.             {
  4849. @@ -4453,6 +4517,31 @@
  4850.         }
  4851.     }
  4852.    
  4853. +   @Override
  4854. +   public boolean isInFunEvent()
  4855. +   {
  4856. +       return (atEvent || isInStartedTVTEvent());
  4857. +   }
  4858. +  
  4859. +   public boolean isInStartedTVTEvent()
  4860. +   {
  4861. +       return (TvT.isStarted() && _inEventTvT);
  4862. +   }
  4863. +  
  4864. +   public boolean isRegisteredInTVTEvent()
  4865. +   {
  4866. +       return _inEventTvT;
  4867. +   }
  4868. +  
  4869. +   /**
  4870. +    * Checks if is registered in fun event.
  4871. +    * @return true, if is registered in fun event
  4872. +    */
  4873. +   public boolean isRegisteredInFunEvent()
  4874. +   {
  4875. +       return (atEvent || (_inEventTvT) || Olympiad.getInstance().isRegistered(this));
  4876. +   }
  4877. +  
  4878.     /**
  4879.      * Are player offensive skills locked.
  4880.      * @return true, if successful
  4881. @@ -5532,6 +5621,54 @@
  4882.         if (killer != null)
  4883.         {
  4884.             final Player pk = killer.getActingPlayer();
  4885. +           if (pk != null)
  4886. +           {
  4887. +              
  4888. +               if (atEvent)
  4889. +               {
  4890. +                   pk.kills.add(getName());
  4891. +               }
  4892. +              
  4893. +               if (_inEventTvT && pk._inEventTvT)
  4894. +               {
  4895. +                   if (TvT.isTeleport() || TvT.isStarted())
  4896. +                   {
  4897. +                       if (!(pk._teamNameTvT.equals(_teamNameTvT)))
  4898. +                       {
  4899. +                           _countTvTdies++;
  4900. +                           pk._countTvTkills++;
  4901. +                           pk.setTitle("Kills: " + pk._countTvTkills);
  4902. +                           pk.sendPacket(new PlaySound(0, "ItemSound.quest_itemget", this));
  4903. +                           pk.broadcastUserInfo();
  4904. +                           TvT.setTeamKillsCount(pk._teamNameTvT, TvT.teamKillsCount(pk._teamNameTvT) + 1);
  4905. +                           pk.broadcastUserInfo();
  4906. +                       }
  4907. +                       else
  4908. +                       {
  4909. +                           pk.sendMessage("You are a teamkiller !!! Teamkills not counting.");
  4910. +                       }
  4911. +                       sendMessage("You will be revived and teleported to team spot in " + (Config.TVT_REVIVE_DELAY / 1000) + " seconds!");
  4912. +                       ThreadPool.schedule(() ->
  4913. +                       {
  4914. +                           teleToLocation((TvT._teamsX.get(TvT._teams.indexOf(_teamNameTvT)) + Rnd.get(201)) - 100, (TvT._teamsY.get(TvT._teams.indexOf(_teamNameTvT)) + Rnd.get(201)) - 100, TvT._teamsZ.get(TvT._teams.indexOf(_teamNameTvT)));
  4915. +                           doRevive();
  4916. +                       }, Config.TVT_REVIVE_DELAY);
  4917. +                   }
  4918. +               }
  4919. +               else if (_inEventTvT)
  4920. +               {
  4921. +                   if (TvT.isTeleport() || TvT.isStarted())
  4922. +                   {
  4923. +                       sendMessage("You will be revived and teleported to team spot in " + (Config.TVT_REVIVE_DELAY / 1000) + " seconds!");
  4924. +                       ThreadPool.schedule(() ->
  4925. +                       {
  4926. +                           teleToLocation(TvT._teamsX.get(TvT._teams.indexOf(_teamNameTvT)), TvT._teamsY.get(TvT._teams.indexOf(_teamNameTvT)), TvT._teamsZ.get(TvT._teams.indexOf(_teamNameTvT)));
  4927. +                           doRevive();
  4928. +                           broadcastPacket(new SocialAction(getObjectId(), 15));
  4929. +                       }, Config.TVT_REVIVE_DELAY);
  4930. +                   }
  4931. +               }
  4932. +           }
  4933.            
  4934.             // Clear resurrect xp calculation
  4935.             setExpBeforeDeath(0);
  4936. @@ -5637,11 +5774,14 @@
  4937.      */
  4938.     private void onDieDropItem(Creature killer)
  4939.     {
  4940. -       if (isOnEvent())
  4941. +       // if (isOnEvent())
  4942. +       // {
  4943. +       // return;
  4944. +       // }
  4945. +       if (atEvent || (TvT.isStarted() && _inEventTvT) || (killer == null))
  4946.         {
  4947.             return;
  4948.         }
  4949. -      
  4950.         if ((getKarma() <= 0) && (killer instanceof Player) && (((Player) killer).getClan() != null) && (getClan() != null) && ((Player) killer).getClan().isAtWarWith(getClanId()))
  4951.         {
  4952.             return;
  4953. @@ -5759,11 +5899,14 @@
  4954.             return;
  4955.         }
  4956.        
  4957. -       if (isOnEvent())
  4958. +       // if (isOnEvent())
  4959. +       // {
  4960. +       // return;
  4961. +       // }
  4962. +       if ((_inEventTvT && TvT.isStarted()))
  4963.         {
  4964.             return;
  4965.         }
  4966. -      
  4967.         if (isCursedWeaponEquipped())
  4968.         {
  4969.             CursedWeaponsManager.getInstance().increaseKills(_cursedWeaponEquipedId);
  4970. @@ -5842,6 +5985,41 @@
  4971.                 {
  4972.                     AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " hunted Player " + target.getName());
  4973.                 }
  4974. +               // 'No war' or 'One way war' -> 'Normal PK'
  4975. +               if ((!_inEventTvT || !TvT.isStarted()))
  4976. +               {
  4977. +                   if (targetPlayer.getKarma() > 0) // Target player has karma
  4978. +                   {
  4979. +                       if (Config.KARMA_AWARD_PK_KILL)
  4980. +                       {
  4981. +                           increasePvpKills();
  4982. +                       }
  4983. +                      
  4984. +                       if ((target instanceof Player) && Config.ANNOUNCE_PVP_KILL)
  4985. +                       {
  4986. +                           AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " hunted Player " + target.getName());
  4987. +                       }
  4988. +                   }
  4989. +                   else if (targetPlayer.getPvpFlag() == 0) // Target player doesn't have karma
  4990. +                   {
  4991. +                       if (Config.FACTION_SYSTEM_ENABLED)
  4992. +                       {
  4993. +                           if ((_isGood && targetPlayer.isGood()) || (_isEvil && targetPlayer.isEvil()))
  4994. +                           {
  4995. +                               increasePkKillsAndKarma(targetPlayer.getLevel());
  4996. +                           }
  4997. +                       }
  4998. +                       else
  4999. +                       {
  5000. +                           increasePkKillsAndKarma(targetPlayer.getLevel());
  5001. +                       }
  5002. +                      
  5003. +                       if ((target instanceof Player) && Config.ANNOUNCE_PK_KILL)
  5004. +                       {
  5005. +                           AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " has assassinated Player " + target.getName());
  5006. +                       }
  5007. +                   }
  5008. +               }
  5009.                 else if ((target instanceof Player) && Config.ANNOUNCE_ALL_KILL)
  5010.                 {
  5011.                     AnnouncementsTable.getInstance().announceToAll("Player " + getName() + " killed Player " + target.getName());
  5012. @@ -6038,7 +6216,10 @@
  5013.         {
  5014.             return;
  5015.         }
  5016. -      
  5017. +       if ((TvT.isStarted() && _inEventTvT))
  5018. +       {
  5019. +           return;
  5020. +       }
  5021.         // Add karma to attacker and increase its PK counter
  5022.         setPvpKills(getPvpKills() + 1);
  5023.        
  5024. @@ -6080,6 +6261,10 @@
  5025.         {
  5026.             return;
  5027.         }
  5028. +       if ((TvT.isStarted() && _inEventTvT))
  5029. +       {
  5030. +           return;
  5031. +       }
  5032.        
  5033.         final int baseKarma = Config.KARMA_MIN_KARMA;
  5034.         int newKarma = baseKarma;
  5035. @@ -6198,6 +6383,10 @@
  5036.      */
  5037.     public void updatePvPStatus()
  5038.     {
  5039. +       if ((TvT.isStarted() && _inEventTvT))
  5040. +       {
  5041. +           return;
  5042. +       }
  5043.         if (isInsideZone(ZoneId.PVP))
  5044.         {
  5045.             return;
  5046. @@ -6236,6 +6425,10 @@
  5047.             return;
  5048.         }
  5049.        
  5050. +       if ((TvT.isStarted() && _inEventTvT && targetPlayer._inEventTvT))
  5051. +       {
  5052. +           return;
  5053. +       }
  5054.         if (Config.FACTION_SYSTEM_ENABLED && target.isPlayer() && ((isGood() && targetPlayer.isEvil()) || (isEvil() && targetPlayer.isGood())))
  5055.         {
  5056.             return;
  5057. @@ -6318,6 +6511,18 @@
  5058.        
  5059.         // Calculate the Experience loss
  5060.         long lostExp = 0;
  5061. +       if (!atEvent && (!_inEventTvT || !TvT.isStarted()))
  5062. +       {
  5063. +           final byte maxLevel = ExperienceData.getInstance().getMaxLevel();
  5064. +           if (lvl < maxLevel)
  5065. +           {
  5066. +               lostExp = Math.round(((getStat().getExpForLevel(lvl + 1) - getStat().getExpForLevel(lvl)) * percentLost) / 100);
  5067. +           }
  5068. +           else
  5069. +           {
  5070. +               lostExp = Math.round(((getStat().getExpForLevel(maxLevel) - getStat().getExpForLevel(maxLevel - 1)) * percentLost) / 100);
  5071. +           }
  5072. +       }
  5073.         if (!isOnEvent())
  5074.         {
  5075.             final byte maxLevel = ExperienceData.getInstance().getMaxLevel();
  5076. @@ -9090,6 +9295,36 @@
  5077.         {
  5078.             return false;
  5079.         }
  5080. +       // Check if the attacker is in an event
  5081. +       if (isOnEvent() && (attacker instanceof Playable))
  5082. +       {
  5083. +           final Player player = attacker.getActingPlayer();
  5084. +           if ((player != null) && player.isOnEvent())
  5085. +           {
  5086. +               return isOnSoloEvent() || (getTeam() != player.getTeam()) || (_inEventTvT && player._inEventTvT && TvT.isStarted() && !_teamNameTvT.equals(player._teamNameTvT));
  5087. +           }
  5088. +       }
  5089. +       if (attacker.isInArenaEvent())
  5090. +       {
  5091. +           Player player = null;
  5092. +           if (attacker instanceof Player)
  5093. +           {
  5094. +               player = (Player) attacker;
  5095. +           }
  5096. +           else if (attacker instanceof Summon)
  5097. +           {
  5098. +               player = ((Summon) attacker).getOwner();
  5099. +           }
  5100. +           if (player != null)
  5101. +           {
  5102. +               if (isArenaAttack() && player.isArenaAttack())
  5103. +               {
  5104. +                   return true;
  5105. +               }
  5106. +              
  5107. +               return false;
  5108. +           }
  5109. +       }
  5110.        
  5111.         // Check if the Player has Karma
  5112.         if ((getKarma() > 0) || (getPvpFlag() > 0))
  5113. @@ -9634,6 +9869,7 @@
  5114.             // Check if a Forced ATTACK is in progress on non-attackable target
  5115.             if (!target.isAutoAttackable(this) //
  5116.                 && (!forceUse && ((skill.getId() != 3260 /* Forgiveness */) && (skill.getId() != 3261 /* Heart Shot */) && (skill.getId() != 3262 /* Double Heart Shot */))) //
  5117. +               && (!_inEventTvT || !TvT.isStarted()) //
  5118.                 && (skillTargetType != SkillTargetType.AURA) //
  5119.                 && (skillTargetType != SkillTargetType.CLAN) //
  5120.                 && (skillTargetType != SkillTargetType.ALLY) //
  5121. @@ -9868,11 +10104,15 @@
  5122.         WorldObject target = worldObject;
  5123.        
  5124.         // Check if player and target are in events and on the same team.
  5125. +       // if ((target instanceof Player) && isOnEvent() && skill.isOffensive())
  5126. +       // {
  5127. +       // return target.getActingPlayer().isOnEvent() && (isOnSoloEvent() || (getTeam() != target.getActingPlayer().getTeam()));
  5128. +       // }
  5129. +       // Check if player and target are in events and on the same team.
  5130.         if ((target instanceof Player) && isOnEvent() && skill.isOffensive())
  5131.         {
  5132. -           return target.getActingPlayer().isOnEvent() && (isOnSoloEvent() || (getTeam() != target.getActingPlayer().getTeam()));
  5133. +           return target.getActingPlayer().isOnEvent() && (isOnSoloEvent() || (getTeam() != target.getActingPlayer().getTeam())) && ((skill.isOffensive() && (_inEventTvT && target.getActingPlayer()._inEventTvT && TvT.isStarted() && !_teamNameTvT.equals(target.getActingPlayer()._teamNameTvT))));
  5134.         }
  5135. -      
  5136.         // check for PC->PC Pvp status
  5137.         if (target instanceof Summon)
  5138.         {
  5139. @@ -10868,6 +11108,22 @@
  5140.         return _exchangeRefusal;
  5141.     }
  5142.    
  5143. +   public boolean isPartyInRefuse()
  5144. +  
  5145. +   {
  5146. +      
  5147. +       return _isPartyInRefuse;
  5148. +      
  5149. +   }
  5150. +  
  5151. +   public void setIsPartyInRefuse(boolean value)
  5152. +  
  5153. +   {
  5154. +      
  5155. +       _isPartyInRefuse = value;
  5156. +      
  5157. +   }
  5158. +  
  5159.     /**
  5160.      * Gets the block list.
  5161.      * @return the block list
  5162. @@ -12207,7 +12463,13 @@
  5163.             getParty().getDimensionalRift().memberRessurected(this);
  5164.         }
  5165.        
  5166. -       if (isOnEvent())
  5167. +       // if (isOnEvent())
  5168. +       // {
  5169. +       // getStatus().setCurrentHp(getMaxHp());
  5170. +       // getStatus().setCurrentMp(getMaxMp());
  5171. +       // getStatus().setCurrentCp(getMaxCp());
  5172. +       // }
  5173. +       if ((_inEventTvT && TvT.isStarted() && Config.TVT_REVIVE_RECOVERY))
  5174.         {
  5175.             getStatus().setCurrentHp(getMaxHp());
  5176.             getStatus().setCurrentMp(getMaxMp());
  5177. @@ -15194,6 +15456,10 @@
  5178.                     _punishTask = ThreadPool.schedule(new PunishTask(this), _punishTimer);
  5179.                     sendMessage("You are in jail for " + (delayInMilliseconds / 60000) + " minutes.");
  5180.                 }
  5181. +               if (_inEventTvT)
  5182. +               {
  5183. +                   TvT.onDisconnect(this);
  5184. +               }
  5185.                
  5186.                 if (Olympiad.getInstance().isRegisteredInComp(this))
  5187.                 {
  5188. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/BroadcastingTower.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/BroadcastingTower.java
  5189. index 9066d7b..9386373 100644
  5190. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/BroadcastingTower.java
  5191. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/BroadcastingTower.java
  5192. @@ -51,7 +51,12 @@
  5193.             player.sendPacket(ActionFailed.STATIC_PACKET);
  5194.             return;
  5195.         }
  5196. -      
  5197. +       if ((player._inEventTvT))
  5198. +       {
  5199. +           player.sendMessage("You already participate in an event!");
  5200. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  5201. +           return;
  5202. +       }
  5203.         if (player.isRegisteredOnEvent())
  5204.         {
  5205.             player.sendMessage("You already participate in an event!");
  5206. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/VillageMaster.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/VillageMaster.java
  5207. index 0061cb9..5ebd896 100644
  5208. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/VillageMaster.java
  5209. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/VillageMaster.java
  5210. @@ -347,7 +347,12 @@
  5211.                         player.setLocked(false);
  5212.                         return;
  5213.                     }
  5214. -                  
  5215. +                   if (player._inEventTvT)
  5216. +                   {
  5217. +                       player.sendMessage("You can't add a subclass while in an event.");
  5218. +                       player.setLocked(false);
  5219. +                       return;
  5220. +                   }
  5221.                     // Check player level
  5222.                     if (player.getLevel() < 75)
  5223.                     {
  5224. @@ -448,6 +453,13 @@
  5225.                         player.setLocked(false);
  5226.                         return;
  5227.                     }
  5228. +                   // You can't change Subclass when you are registered in Events (TVT, CTF, DM)
  5229. +                   if (player._inEventTvT)
  5230. +                   {
  5231. +                       player.sendMessage("You can't change subclass while in an event.");
  5232. +                       player.setLocked(false);
  5233. +                       return;
  5234. +                   }
  5235.                    
  5236.                     // You can't change Subclass when you are registered in Olympiad
  5237.                     if (Olympiad.getInstance().isRegisteredInComp(player) || (player.getOlympiadGameId() > 0))
  5238. @@ -509,7 +521,13 @@
  5239.                         player.setLocked(false);
  5240.                         return;
  5241.                     }
  5242. -                  
  5243. +                   // You can't change Subclass when you are registered in Events (TVT, CTF, DM)
  5244. +                   if (player._inEventTvT)
  5245. +                   {
  5246. +                       player.sendMessage("You can't delete a subclass while in an event.");
  5247. +                       player.setLocked(false);
  5248. +                       return;
  5249. +                   }
  5250.                     // You can't delete Subclass when you are registered in Olympiad
  5251.                     if (Olympiad.getInstance().isRegisteredInComp(player) || (player.getOlympiadGameId() > 0))
  5252.                     {
  5253. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java
  5254. index c92d3cc..25aed21 100644
  5255. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java
  5256. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/GameClient.java
  5257. @@ -38,6 +38,8 @@
  5258.  import org.l2jmobius.gameserver.data.sql.CharInfoTable;
  5259.  import org.l2jmobius.gameserver.data.sql.ClanTable;
  5260.  import org.l2jmobius.gameserver.data.sql.OfflineTraderTable;
  5261. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
  5262. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  5263.  import org.l2jmobius.gameserver.model.CharSelectInfoPackage;
  5264.  import org.l2jmobius.gameserver.model.World;
  5265.  import org.l2jmobius.gameserver.model.actor.Player;
  5266. @@ -45,6 +47,7 @@
  5267.  import org.l2jmobius.gameserver.model.olympiad.Olympiad;
  5268.  import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
  5269.  import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
  5270. +import org.l2jmobius.gameserver.util.EventData;
  5271.  import org.l2jmobius.gameserver.util.FloodProtectors;
  5272.  
  5273.  /**
  5274. @@ -485,6 +488,17 @@
  5275.                 final Player player = _player;
  5276.                 if (player != null) // this should only happen on connection loss
  5277.                 {
  5278. +                   // we store all data from players who are disconnected while in an event in order to restore it in the next login
  5279. +                   if (player.atEvent)
  5280. +                   {
  5281. +                       final EventData data = new EventData(player.eventX, player.eventY, player.eventZ, player.eventKarma, player.eventPvpKills, player.eventPkKills, player.eventTitle, player.kills, player.eventSitForced);
  5282. +                       GameEvent.connectionLossData.put(player.getName(), data);
  5283. +                   }
  5284. +                   else if (player._inEventTvT)
  5285. +                   {
  5286. +                       TvT.onDisconnect(player);
  5287. +                   }
  5288. +                  
  5289.                     if (player.isFlying())
  5290.                     {
  5291.                         player.removeSkill(SkillTable.getInstance().getSkill(4289, 1));
  5292. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java
  5293. index 833f5d2..f49283c 100644
  5294. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java
  5295. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/AttackRequest.java
  5296. @@ -17,9 +17,11 @@
  5297.  package org.l2jmobius.gameserver.network.clientpackets;
  5298.  
  5299.  import org.l2jmobius.commons.network.ReadablePacket;
  5300. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  5301.  import org.l2jmobius.gameserver.model.World;
  5302.  import org.l2jmobius.gameserver.model.WorldObject;
  5303.  import org.l2jmobius.gameserver.model.actor.Player;
  5304. +import org.l2jmobius.gameserver.model.actor.Summon;
  5305.  import org.l2jmobius.gameserver.model.actor.instance.Servitor;
  5306.  import org.l2jmobius.gameserver.network.GameClient;
  5307.  import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
  5308. @@ -96,6 +98,34 @@
  5309.             return;
  5310.         }
  5311.        
  5312. +       // During teleport phase, players cant do any attack
  5313. +       if ((TvT.isTeleport() && player._inEventTvT))
  5314. +       {
  5315. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  5316. +           return;
  5317. +       }
  5318. +      
  5319. +       // No attacks to same team in Event
  5320. +       if (TvT.isStarted())
  5321. +       {
  5322. +           if (target instanceof Player)
  5323. +           {
  5324. +               if ((player._inEventTvT && ((Player) target)._inEventTvT) && player._teamNameTvT.equals(((Player) target)._teamNameTvT))
  5325. +               {
  5326. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  5327. +                   return;
  5328. +               }
  5329. +           }
  5330. +           else if (target instanceof Summon)
  5331. +           {
  5332. +               if ((player._inEventTvT && ((Summon) target).getOwner()._inEventTvT) && player._teamNameTvT.equals(((Summon) target).getOwner()._teamNameTvT))
  5333. +               {
  5334. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  5335. +                   return;
  5336. +               }
  5337. +           }
  5338. +       }
  5339. +      
  5340.         // No attacks to same team in event
  5341.         if (player.isOnEvent() && !player.isOnSoloEvent())
  5342.         {
  5343. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  5344. index fb7f499..9da0f73 100644
  5345. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  5346. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  5347. @@ -42,6 +42,7 @@
  5348.  import org.l2jmobius.gameserver.instancemanager.RebirthManager;
  5349.  import org.l2jmobius.gameserver.instancemanager.ServerRestartManager;
  5350.  import org.l2jmobius.gameserver.instancemanager.SiegeManager;
  5351. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  5352.  import org.l2jmobius.gameserver.model.Skill;
  5353.  import org.l2jmobius.gameserver.model.Wedding;
  5354.  import org.l2jmobius.gameserver.model.World;
  5355. @@ -444,6 +445,11 @@
  5356.             RebirthManager.getInstance().grantRebirthSkills(player);
  5357.         }
  5358.        
  5359. +       if (TvT._savePlayers.contains(player.getName()))
  5360. +       {
  5361. +           TvT.addDisconnectedPlayer(player);
  5362. +       }
  5363. +      
  5364.         // Means that it's not ok multiBox situation, so logout.
  5365.         if (!player.canMultiBox())
  5366.         {
  5367. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java
  5368. index dcfe0f4..a4f8244 100644
  5369. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java
  5370. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java
  5371. @@ -27,6 +27,8 @@
  5372.  import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
  5373.  import org.l2jmobius.gameserver.handler.VoicedCommandHandler;
  5374.  import org.l2jmobius.gameserver.instancemanager.RebirthManager;
  5375. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
  5376. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  5377.  import org.l2jmobius.gameserver.model.Location;
  5378.  import org.l2jmobius.gameserver.model.World;
  5379.  import org.l2jmobius.gameserver.model.WorldObject;
  5380. @@ -155,6 +157,39 @@
  5381.                
  5382.                 try
  5383.                 {
  5384. +                   if (_command.substring(endOfId + 1).startsWith("event_participate"))
  5385. +                   {
  5386. +                       GameEvent.inscribePlayer(player);
  5387. +                   }
  5388. +                   else if (_command.substring(endOfId + 1).startsWith("tvt_player_join "))
  5389. +                   {
  5390. +                       final String teamName = _command.substring(endOfId + 1).substring(16);
  5391. +                       if (TvT.isJoining())
  5392. +                       {
  5393. +                           TvT.addPlayer(player, teamName);
  5394. +                       }
  5395. +                       else
  5396. +                       {
  5397. +                           player.sendMessage("The event is already started. You can not join now!");
  5398. +                       }
  5399. +                   }
  5400. +                   else if (_command.substring(endOfId + 1).startsWith("tvt_player_leave"))
  5401. +                   {
  5402. +                       if (TvT.isJoining())
  5403. +                       {
  5404. +                           TvT.removePlayer(player);
  5405. +                       }
  5406. +                       else
  5407. +                       {
  5408. +                           player.sendMessage("The event is already started. You can not leave now!");
  5409. +                       }
  5410. +                   }
  5411. +                  
  5412. +                   if (_command.substring(endOfId + 1).startsWith("event_participate"))
  5413. +                   {
  5414. +                       GameEvent.inscribePlayer(player);
  5415. +                   }
  5416. +                  
  5417.                     final WorldObject object = World.getInstance().findObject(Integer.parseInt(id));
  5418.                     if ((Config.ALLOW_CLASS_MASTERS && Config.ALLOW_REMOTE_CLASS_MASTERS && (object instanceof ClassMaster)) //
  5419.                         || ((object instanceof Npc) && (endOfId > 0) && player.isInsideRadius2D(object, Npc.INTERACTION_DISTANCE)))
  5420. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java
  5421. index b3bb662..acc50ce 100644
  5422. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java
  5423. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestJoinParty.java
  5424. @@ -17,6 +17,7 @@
  5425.  package org.l2jmobius.gameserver.network.clientpackets;
  5426.  
  5427.  import org.l2jmobius.commons.network.ReadablePacket;
  5428. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  5429.  import org.l2jmobius.gameserver.model.BlockList;
  5430.  import org.l2jmobius.gameserver.model.Party;
  5431.  import org.l2jmobius.gameserver.model.World;
  5432. @@ -54,6 +55,21 @@
  5433.             return;
  5434.         }
  5435.        
  5436. +       if ((requestor._inEventTvT && !target._inEventTvT && (TvT.isStarted() || TvT.isTeleport())) || (!requestor._inEventTvT && target._inEventTvT && (TvT.isStarted() || TvT.isTeleport())))
  5437. +       {
  5438. +           requestor.sendMessage("You can't invite that player in party: you or your target are in Event");
  5439. +           return;
  5440. +       }
  5441. +       if (target.isPartyInRefuse())
  5442. +      
  5443. +       {
  5444. +          
  5445. +           requestor.sendMessage("[Party Refuse]: Player in refusal party.");
  5446. +          
  5447. +           return;
  5448. +          
  5449. +       }
  5450. +      
  5451.         if (target.isInParty())
  5452.         {
  5453.             final SystemMessage msg = new SystemMessage(SystemMessageId.S1_IS_A_MEMBER_OF_ANOTHER_PARTY_AND_CANNOT_BE_INVITED);
  5454. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestart.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestart.java
  5455. index 2ef23aa..a2516e3 100644
  5456. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestart.java
  5457. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestart.java
  5458. @@ -119,6 +119,14 @@
  5459.             return;
  5460.         }
  5461.        
  5462. +       // Check if player is in Event
  5463. +       if (player._inEventTvT)
  5464. +       {
  5465. +           player.sendMessage("You can't restart during Event.");
  5466. +           player.sendPacket(RestartResponse.valueOf(false));
  5467. +           return;
  5468. +       }
  5469. +      
  5470.         player.getInventory().updateDatabase();
  5471.        
  5472.         // Fix against exploit anti-target
  5473. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestartPoint.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestartPoint.java
  5474. index aa1ed7f..7ddd035 100644
  5475. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestartPoint.java
  5476. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestRestartPoint.java
  5477. @@ -26,6 +26,7 @@
  5478.  import org.l2jmobius.gameserver.instancemanager.CastleManager;
  5479.  import org.l2jmobius.gameserver.instancemanager.FortManager;
  5480.  import org.l2jmobius.gameserver.instancemanager.QuestManager;
  5481. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  5482.  import org.l2jmobius.gameserver.model.Location;
  5483.  import org.l2jmobius.gameserver.model.actor.Player;
  5484.  import org.l2jmobius.gameserver.model.quest.Quest;
  5485. @@ -117,6 +118,12 @@
  5486.                 return;
  5487.             }
  5488.            
  5489. +           else if ((_player._inEventTvT && TvT.isStarted()))
  5490. +           {
  5491. +               _player.sendMessage("You cannot do that while participating in an event!");
  5492. +               return;
  5493. +           }
  5494. +          
  5495.             try
  5496.             {
  5497.                 Location loc = null;
  5498. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/Die.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/Die.java
  5499. index ee75ca2..4c43e12 100644
  5500. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/Die.java
  5501. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/Die.java
  5502. @@ -18,6 +18,7 @@
  5503.  
  5504.  import org.l2jmobius.gameserver.instancemanager.CastleManager;
  5505.  import org.l2jmobius.gameserver.instancemanager.FortManager;
  5506. +import org.l2jmobius.gameserver.instancemanager.events.TvT;
  5507.  import org.l2jmobius.gameserver.model.actor.Attackable;
  5508.  import org.l2jmobius.gameserver.model.actor.Creature;
  5509.  import org.l2jmobius.gameserver.model.actor.Player;
  5510. @@ -45,7 +46,7 @@
  5511.             final Player player = creature.getActingPlayer();
  5512.             _allowFixedRes = player.getAccessLevel().allowFixedRes();
  5513.             _clan = player.getClan();
  5514. -           _canTeleport = !player.isPendingRevive();
  5515. +           _canTeleport = ((!TvT.isStarted() || !player._inEventTvT) && !player.isOnEvent() && !player.isPendingRevive());
  5516.         }
  5517.         _objectId = creature.getObjectId();
  5518.         _fake = !creature.isDead();
  5519.  
  5520.  
  5521.  
  5522. ======================================================================================
  5523. \L2jMobius_c6_interlude\game\config\custom\TvTEvents.ini
  5524. ======================================================================================
  5525.  
  5526. #====================================#
  5527. #            Team vs Team            #
  5528. #====================================#
  5529. # TvT(Team vs Team) Event: Blue vs Red.
  5530.  
  5531. # Setting for Team vs. Team pvp
  5532. # TvTEvenTeams = NO|BALANCE|SHUFFLE
  5533. # NO means: not even teams.
  5534. # BALANCE means: Players can only join team with lowest player count.
  5535. # SHUFFLE means: Players can only participate to tzhe event and not direct to a team. Teams will be schuffeled in teleporting teams.
  5536. TvTEvenTeams = SHUFFLE
  5537.  
  5538. # players there not participated in tvt can target tvt participants?
  5539. TvTAllowInterference = False
  5540.  
  5541. # tvt participants can use potions?
  5542. TvTAllowPotions = True
  5543.  
  5544. # tvt participants can summon by item?
  5545. TvTAllowSummon = True
  5546.  
  5547. # remove all effects of tvt participants on event start?
  5548. TvTOnStartRemoveAllEffects = False
  5549.  
  5550. # unsummon pet of tvt participants on event start?
  5551. TvTOnStartUnsummonPet = True
  5552.  
  5553. # on revive participants regain full hp/mp/cp ?
  5554. TvTReviveRecovery = True
  5555.  
  5556. # announce all team statistics
  5557. TvTAnnounceTeamStats = True
  5558.  
  5559. # announce reward
  5560. TvTAnnounceReward = True
  5561.  
  5562. # give price with 0 kills
  5563. TvTPriceNoKills = True
  5564.  
  5565. # players with cursed weapon are allowed to join ?
  5566. TvTJoinWithCursedWeapon = False
  5567.  
  5568. # Enable voice command to register on tvt event
  5569. TvTCommand = True
  5570.  
  5571. # Delay on revive when dead, NOTE: 20000 equals to 20 seconds, minimum 1000 (1 second)
  5572. TvTReviveDelay = 10000
  5573.  
  5574. # Open Western Fortress doors on tvt finish
  5575. TvTOpenFortDoors = False
  5576.  
  5577. # Close Western Fortress doors on tvt start
  5578. TvTCloseFortDoors = False
  5579.  
  5580. # Open Aden Colosseum doors on tvt finish
  5581. TvTOpenAdenColosseumDoors = True
  5582.  
  5583. # Close Aden Colosseum doors on tvt start
  5584. TvTCloseAdenColosseumDoors = True
  5585.  
  5586. # TvT Top Killer reward id
  5587. TvTTopKillerRewardId = 5575
  5588.  
  5589. # TvT Top Killer reward quantity
  5590. TvTTopKillerRewardQty = 5000000
  5591.  
  5592. # Place an aura on participants team ?
  5593. TvTAura = False
  5594.  
  5595. # Enable event stats logger
  5596. TvTStatsLogger = True
  5597.  
  5598. # Remove Buffs on player die
  5599. TvTRemoveBuffsOnPlayerDie = False
  5600.  
  5601. ======================================================================================
  5602. \L2jMobius_c6_interlude\game\config\custom\EventManager.ini
  5603. ======================================================================================
  5604.  
  5605. #============================================================#
  5606. #                       Event Manager                        #
  5607. #============================================================#
  5608. # Enable auto events and start time.
  5609.  
  5610. # TvT auto start
  5611. # Example TVTStartTime = 20:00;21:00;22:00;
  5612. TVTEventEnabled = True
  5613. TVTStartTime = 16:50;15:15;01:30;
  5614.  
  5615.  
  5616. ======================================================================================
  5617. SQL
  5618. ======================================================================================
  5619. tvt.sql
  5620.  
  5621. -- -----------------------
  5622. -- Table structure for tvt
  5623. -- -----------------------
  5624. DROP TABLE IF EXISTS `tvt`;
  5625. CREATE TABLE `tvt` (
  5626.   `eventName` varchar(255) NOT NULL DEFAULT '',
  5627.   `eventDesc` varchar(255) NOT NULL DEFAULT '',
  5628.   `joiningLocation` varchar(255) NOT NULL DEFAULT '',
  5629.   `minLevel` int(4) NOT NULL DEFAULT '0',
  5630.   `maxLevel` int(4) NOT NULL DEFAULT '0',
  5631.   `npcId` int(8) NOT NULL DEFAULT '0',
  5632.   `npcX` int(11) NOT NULL DEFAULT '0',
  5633.   `npcY` int(11) NOT NULL DEFAULT '0',
  5634.   `npcZ` int(11) NOT NULL DEFAULT '0',
  5635.   `npcHeading` int(11) NOT NULL DEFAULT '0',
  5636.   `rewardId` int(11) NOT NULL DEFAULT '0',
  5637.   `rewardAmount` int(11) NOT NULL DEFAULT '0',
  5638.   `teamsCount` int(4) NOT NULL DEFAULT '0',
  5639.   `joinTime` int(11) NOT NULL DEFAULT '0',
  5640.   `eventTime` int(11) NOT NULL DEFAULT '0',
  5641.   `minPlayers` int(4) NOT NULL DEFAULT '0',
  5642.   `maxPlayers` int(4) NOT NULL DEFAULT '0',
  5643.   `delayForNextEvent` BIGINT NOT NULL DEFAULT '0'
  5644. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  5645.  
  5646. -- ---------------------
  5647. -- Records for table tvt
  5648. -- ---------------------
  5649. INSERT INTO `tvt` values
  5650. ('TVT', 'A PvP Event', 'Giran', 1, 81, 70010, 82688, 148677, -3469, 0, 8752, 1, 2, 5, 5, 2, 50, 300000);
  5651.  
  5652. ======================================================================================
  5653. SQL
  5654. ======================================================================================
  5655. tvt_teams.sql
  5656.  
  5657. -- -----------------------------
  5658. -- Table structure for tvt_teams
  5659. -- -----------------------------
  5660. DROP TABLE IF EXISTS `tvt_teams`;
  5661. CREATE TABLE `tvt_teams` (
  5662.   `teamId` int(4) NOT NULL DEFAULT '0',
  5663.   `teamName` varchar(255) NOT NULL DEFAULT '',
  5664.   `teamX` int(11) NOT NULL DEFAULT '0',
  5665.   `teamY` int(11) NOT NULL DEFAULT '0',
  5666.   `teamZ` int(11) NOT NULL DEFAULT '0',
  5667.   `teamColor` int(11) NOT NULL DEFAULT '0',
  5668.   PRIMARY KEY (`teamId`)
  5669. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  5670.  
  5671. -- ---------------------------
  5672. -- Records for table tvt_teams
  5673. -- ---------------------------
  5674. INSERT INTO `tvt_teams` VALUES
  5675. ('0', 'Blue', '148179', '45841', '-3413', '16711680'),
  5676. ('1', 'Red', '150787', '45822', '-3413', '255'),
  5677. ('2', 'Green', '149496', '47826', '-3413', '26367');
  5678.  
  5679.  
  5680.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement