Advertisement
Sarada-L2

TvT Acis 398 Yo: Sarada

May 12th, 2021 (edited)
1,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 90.45 KB | None | 0 0
  1. diff --git a/config/CustomMods/Events/TvT.ini b/config/CustomMods/Events/TvT.ini
  2. new file mode 100644
  3. index 0000000..a217932
  4. --- /dev/null
  5. +++ b/config/CustomMods/Events/TvT.ini
  6. @@ -0,0 +1,63 @@
  7. +#---------------------------------------------------------------
  8. +# Team vs. Team Event Engine -
  9. +#---------------------------------------------------------------
  10. +# enable TvTEvent
  11. +TvTEventEnabled = true
  12. +# Time Between TvT events (in minutes, 300 = 5 hours)
  13. +TvTEventInterval = 1
  14. +# Registration timer (in minutes) from start of event.
  15. +TvTEventParticipationTime = 1
  16. +
  17. +# Event running time, in minutes
  18. +TvTEventRunningTime = 2
  19. +
  20. +# TvT Event NPC Details (create a custom npc of type TvTEventNpc)
  21. +TvTEventParticipationNpcId = 70010
  22. +TvTEventParticipationNpcCoordinates = 83358,148879,-3405
  23. +
  24. +# Minimum amount of players allowed in each team
  25. +TvTEventMinPlayersInTeams = 1
  26. +TvTEventMaxPlayersInTeams = 20
  27. +
  28. +# Level rules
  29. +TvTEventMinPlayerLevel = 70
  30. +TvTEventMaxPlayerLevel = 80
  31. +
  32. +# Remove buffs effect
  33. +TvTEventRemoveBuffs = false
  34. +
  35. +# If Enable Players cant be healed
  36. +TvTHealPlayersEnable = true
  37. +
  38. +# If true, gives reward for kills stage without die
  39. +# Example: Get 3/7/10 kills without die, and you will be rewarded
  40. +# No more than 1 item!
  41. +TvTKillsRewardEnable = true
  42. +TvTKillsReward = 57,500000000
  43. +
  44. +# Teleport delay Timers (in seconds)
  45. +TvTEventRespawnTeleportDelay = 5
  46. +TvTEventStartLeaveTeleportDelay = 10
  47. +
  48. +# Back to Town
  49. +TvTEventBack = 83013,148595,-3469
  50. +# First Team Details (name, start and death x,y,z tp point)
  51. +TvTEventTeam1Name = Good
  52. +TvTEventTeam1Coordinates = 148695,46725,-3414
  53. +# Second Team Details (name, start and death x,y,z tp point)
  54. +TvTEventTeam2Name = Evil
  55. +TvTEventTeam2Coordinates = 149999,46728,-3414
  56. +
  57. +# Reward for winning team
  58. +# itemId,amount;itemId,amount;itemId,amount;...
  59. +# no ";" at the start or end
  60. +TvTEventReward = 57,100000;5575,1000
  61. +
  62. +# TvTEvent Rules
  63. +TvTEventTargetTeamMembersAllowed = true
  64. +TvTEventPotionsAllowed = false
  65. +TvTEventSummonByItemAllowed = false
  66. +# Door id's to close/open on start/end
  67. +# ex.: 1;2;3;4;5;6
  68. +# no ";" at the start or end
  69. +TvTEventDoorsCloseOpenOnStartEnd =
  70. \ No newline at end of file
  71. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  72. index 2d1316a..9a2f099 100644
  73. --- a/java/net/sf/l2j/Config.java
  74. +++ b/java/net/sf/l2j/Config.java
  75. @@ -48,6 +48,7 @@
  76. public static final String DONATEMODS = "./config/CustomMods/Donate.ini";
  77. public static final String PCBANGEVENT = "./config/CustomMods/Events/PcBangEvent.ini";
  78. public static final String PARTYFARMEVENT = "./config/CustomMods/Events/PartyFarmEvent.ini";
  79. + public static final String TVTEVENT = "./config/CustomMods/Events/TvT.ini";
  80. // --------------------------------------------------
  81. // Clans settings
  82. // --------------------------------------------------
  83. @@ -206,6 +207,31 @@
  84. public static boolean RESTART_BY_TIME_OF_DAY;
  85. public static int RESTART_SECONDS;
  86. public static String[] RESTART_INTERVAL_BY_TIME_OF_DAY;
  87. + public static boolean TVT_EVENT_ENABLED;
  88. + public static int TVT_EVENT_INTERVAL;
  89. + public static int TVT_EVENT_PARTICIPATION_TIME;
  90. + public static int TVT_EVENT_RUNNING_TIME;
  91. + public static int TVT_EVENT_PARTICIPATION_NPC_ID;
  92. + public static int TVT_EVENT_MIN_PLAYERS_IN_TEAMS;
  93. + public static int TVT_EVENT_MAX_PLAYERS_IN_TEAMS;
  94. + public static int TVT_EVENT_RESPAWN_TELEPORT_DELAY;
  95. + public static int TVT_EVENT_START_LEAVE_TELEPORT_DELAY;
  96. + public static String TVT_EVENT_TEAM_1_NAME;
  97. + public static int[] TVT_EVENT_BACK_COORDINATES = new int[3];
  98. + public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
  99. + public static String TVT_EVENT_TEAM_2_NAME;
  100. + public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
  101. + public static List<int[]> TVT_EVENT_REWARDS = new ArrayList<>();
  102. + public static boolean TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
  103. + public static boolean TVT_EVENT_POTIONS_ALLOWED;
  104. + public static boolean TVT_EVENT_SUMMON_BY_ITEM_ALLOWED;
  105. + public static List<Integer> TVT_EVENT_DOOR_IDS = new ArrayList<>();
  106. + public static byte TVT_EVENT_MIN_LVL;
  107. + public static byte TVT_EVENT_MAX_LVL;
  108. + public static boolean TVT_EVENT_REMOVE_BUFFS;
  109. + public static boolean TVT_EVENT_HEAL_PLAYERS;
  110. + public static boolean TVT_KILLS_REWARD_ENABLED;
  111. + public static List<int[]> TVT_KILLS_REWARD = new ArrayList<>();
  112. // --------------------------------------------------
  113. // Events settings
  114. // --------------------------------------------------
  115. @@ -1628,7 +1654,146 @@
  116. MAX_BUFFS_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
  117. STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
  118. }
  119. -
  120. + private static final void loadTvTConfig()
  121. + {
  122. + final ExProperties events = initProperties(TVTEVENT);
  123. + TVT_EVENT_ENABLED = events.getProperty("TvTEventEnabled", false);
  124. + TVT_EVENT_INTERVAL = events.getProperty("TvTEventInterval", 18000);
  125. + TVT_EVENT_PARTICIPATION_TIME = events.getProperty("TvTEventParticipationTime", 3600);
  126. + TVT_EVENT_RUNNING_TIME = events.getProperty("TvTEventRunningTime", 1800);
  127. + TVT_EVENT_PARTICIPATION_NPC_ID = events.getProperty("TvTEventParticipationNpcId", 0);
  128. + TVT_EVENT_REMOVE_BUFFS = events.getProperty("TvTEventRemoveBuffs", false);
  129. + TVT_KILLS_REWARD_ENABLED = events.getProperty("TvTKillsRewardEnable", false);
  130. + TVT_EVENT_HEAL_PLAYERS = events.getProperty("TvTHealPlayersEnable", false);
  131. +
  132. + if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
  133. + {
  134. + TVT_EVENT_ENABLED = false;
  135. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcId");
  136. + }
  137. + else
  138. + {
  139. + String[] propertySplit = events.getProperty("TvTEventParticipationNpcCoordinates", "0,0,0").split(",");
  140. +
  141. + if (propertySplit.length < 3)
  142. + {
  143. + TVT_EVENT_ENABLED = false;
  144. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcCoordinates");
  145. + }
  146. + else
  147. + {
  148. + TVT_EVENT_BACK_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  149. + TVT_EVENT_BACK_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  150. + TVT_EVENT_BACK_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  151. +
  152. + TVT_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(events.getProperty("TvTEventMinPlayersInTeams", "1"));
  153. + TVT_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(events.getProperty("TvTEventMaxPlayersInTeams", "20"));
  154. + TVT_EVENT_MIN_LVL = (byte) Integer.parseInt(events.getProperty("TvTEventMinPlayerLevel", "1"));
  155. + TVT_EVENT_MAX_LVL = (byte) Integer.parseInt(events.getProperty("TvTEventMaxPlayerLevel", "80"));
  156. + TVT_EVENT_RESPAWN_TELEPORT_DELAY = Integer.parseInt(events.getProperty("TvTEventRespawnTeleportDelay", "20"));
  157. + TVT_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(events.getProperty("TvTEventStartLeaveTeleportDelay", "20"));
  158. +
  159. + TVT_EVENT_TEAM_1_NAME = events.getProperty("TvTEventTeam1Name", "Team1");
  160. + propertySplit = events.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
  161. +
  162. + if (propertySplit.length < 3)
  163. + {
  164. + TVT_EVENT_ENABLED = false;
  165. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam1Coordinates");
  166. + }
  167. + else
  168. + {
  169. + TVT_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  170. + TVT_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  171. + TVT_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  172. +
  173. + TVT_EVENT_TEAM_2_NAME = events.getProperty("TvTEventTeam2Name", "Team2");
  174. + propertySplit = events.getProperty("TvTEventTeam2Coordinates", "0,0,0").split(",");
  175. +
  176. + if (propertySplit.length < 3)
  177. + {
  178. + TVT_EVENT_ENABLED = false;
  179. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam2Coordinates");
  180. + }
  181. + else
  182. + {
  183. + TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  184. + TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  185. + TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  186. + propertySplit = events.getProperty("TvTEventReward", "57,100000").split(";");
  187. +
  188. + for (String reward : propertySplit)
  189. + {
  190. + String[] rewardSplit = reward.split(",");
  191. +
  192. + if (rewardSplit.length != 2)
  193. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
  194. + else
  195. + {
  196. + try
  197. + {
  198. + TVT_EVENT_REWARDS.add(new int[]
  199. + {
  200. + Integer.valueOf(rewardSplit[0]),
  201. + Integer.valueOf(rewardSplit[1])
  202. + });
  203. + }
  204. + catch (NumberFormatException nfe)
  205. + {
  206. + if (!reward.equals(""))
  207. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
  208. + }
  209. + }
  210. + }
  211. +
  212. + propertySplit = events.getProperty("TvTKillsReward", "57,100000").split(";");
  213. +
  214. + for (String rewardKills : propertySplit)
  215. + {
  216. + String[] rewardSplit = rewardKills.split(",");
  217. +
  218. + if (rewardSplit.length != 2)
  219. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + rewardKills + "\"");
  220. + else
  221. + {
  222. + try
  223. + {
  224. + TVT_KILLS_REWARD.add(new int[]
  225. + {
  226. + Integer.valueOf(rewardSplit[0]),
  227. + Integer.valueOf(rewardSplit[1])
  228. + });
  229. + }
  230. + catch (NumberFormatException nfe)
  231. + {
  232. + if (!rewardKills.equals(""))
  233. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + rewardKills + "\"");
  234. + }
  235. + }
  236. + }
  237. +
  238. + TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(events.getProperty("TvTEventTargetTeamMembersAllowed", "true"));
  239. + TVT_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(events.getProperty("TvTEventPotionsAllowed", "false"));
  240. + TVT_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(events.getProperty("TvTEventSummonByItemAllowed", "false"));
  241. + propertySplit = events.getProperty("TvTEventDoorsCloseOpenOnStartEnd", "").split(";");
  242. +
  243. + for (String door : propertySplit)
  244. + {
  245. + try
  246. + {
  247. + TVT_EVENT_DOOR_IDS.add(Integer.valueOf(door));
  248. + }
  249. + catch (NumberFormatException nfe)
  250. + {
  251. + if (!door.equals(""))
  252. + System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventDoorsCloseOpenOnStartEnd \"" + door + "\"");
  253. + }
  254. + }
  255. + }
  256. + }
  257. + }
  258. + }
  259. + }
  260. /**
  261. * Loads siege settings.
  262. */
  263. @@ -1847,7 +2012,7 @@
  264. loadNewChar();
  265. // players settings
  266. loadPlayers();
  267. -
  268. + loadTvTConfig();
  269. // siege settings
  270. loadSieges();
  271.  
  272. diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
  273. index da7c459..000e3d6 100644
  274. --- a/java/net/sf/l2j/gameserver/GameServer.java
  275. +++ b/java/net/sf/l2j/gameserver/GameServer.java
  276. @@ -79,6 +79,7 @@
  277. import net.sf.l2j.gameserver.data.xml.TeleportLocationData;
  278. import net.sf.l2j.gameserver.data.xml.WalkerRouteData;
  279. import net.sf.l2j.gameserver.enums.actors.OfflineStoresData;
  280. +import net.sf.l2j.gameserver.events.TvTEventManager;
  281. import net.sf.l2j.gameserver.geoengine.GeoEngine;
  282. import net.sf.l2j.gameserver.handler.AdminCommandHandler;
  283. import net.sf.l2j.gameserver.handler.ChatHandler;
  284. @@ -265,7 +266,8 @@
  285.  
  286. StringUtil.printSection("Auto Spawns");
  287. AutoSpawnTable.getInstance();
  288. -
  289. + StringUtil.printSection("TvT Event");
  290. + TvTEventManager.getInstance();
  291. StringUtil.printSection("Seven Signs");
  292. SevenSignsManager.getInstance().spawnSevenSignsNPC();
  293. FestivalOfDarknessManager.getInstance();
  294. diff --git a/java/net/sf/l2j/gameserver/enums/TeamType.java b/java/net/sf/l2j/gameserver/enums/TeamType.java
  295. deleted file mode 100644
  296. index d41cc86..0000000
  297. --- a/java/net/sf/l2j/gameserver/enums/TeamType.java
  298. +++ /dev/null
  299. @@ -1,20 +0,0 @@
  300. -package net.sf.l2j.gameserver.enums;
  301. -
  302. -public enum TeamType
  303. -{
  304. - NONE(0),
  305. - BLUE(1),
  306. - RED(2);
  307. -
  308. - private int _id;
  309. -
  310. - private TeamType(int id)
  311. - {
  312. - _id = id;
  313. - }
  314. -
  315. - public int getId()
  316. - {
  317. - return _id;
  318. - }
  319. -}
  320. \ No newline at end of file
  321. diff --git a/java/net/sf/l2j/gameserver/events/TvTEvent.java b/java/net/sf/l2j/gameserver/events/TvTEvent.java
  322. new file mode 100644
  323. index 0000000..8ac6a0e
  324. --- /dev/null
  325. +++ b/java/net/sf/l2j/gameserver/events/TvTEvent.java
  326. @@ -0,0 +1,792 @@
  327. +/*
  328. + This program is free software: you can redistribute it and/or modify it under
  329. + * the terms of the GNU General Public License as published by the Free Software
  330. + * Foundation, either version 3 of the License, or (at your option) any later
  331. + * version.
  332. + *
  333. + * This program is distributed in the hope that it will be useful, but WITHOUT
  334. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  335. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  336. + * details.
  337. + *
  338. + * You should have received a copy of the GNU General Public License along with
  339. + * this program. If not, see <http://www.gnu.org/licenses/>.
  340. + */
  341. +package net.sf.l2j.gameserver.events;
  342. +
  343. +import net.sf.l2j.commons.random.Rnd;
  344. +
  345. +import net.sf.l2j.Config;
  346. +import net.sf.l2j.gameserver.data.SkillTable;
  347. +import net.sf.l2j.gameserver.data.sql.SpawnTable;
  348. +import net.sf.l2j.gameserver.data.xml.DoorData;
  349. +import net.sf.l2j.gameserver.data.xml.ItemData;
  350. +import net.sf.l2j.gameserver.data.xml.NpcData;
  351. +import net.sf.l2j.gameserver.enums.SayType;
  352. +import net.sf.l2j.gameserver.model.World;
  353. +import net.sf.l2j.gameserver.model.actor.Creature;
  354. +import net.sf.l2j.gameserver.model.actor.Player;
  355. +import net.sf.l2j.gameserver.model.actor.Summon;
  356. +import net.sf.l2j.gameserver.model.actor.instance.Door;
  357. +import net.sf.l2j.gameserver.model.actor.instance.Pet;
  358. +import net.sf.l2j.gameserver.model.actor.instance.Servitor;
  359. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  360. +import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
  361. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  362. +import net.sf.l2j.gameserver.model.spawn.Spawn;
  363. +import net.sf.l2j.gameserver.network.SystemMessageId;
  364. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  365. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  366. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  367. +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  368. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  369. +import net.sf.l2j.gameserver.skills.L2Skill;
  370. +
  371. +/**
  372. + * @author Baggos
  373. + */
  374. +public class TvTEvent
  375. +{
  376. + enum EventState
  377. + {
  378. + INACTIVE,
  379. + INACTIVATING,
  380. + PARTICIPATING,
  381. + STARTING,
  382. + STARTED,
  383. + REWARDING
  384. + }
  385. +
  386. + /** Gives Noblesse to players */
  387. + static L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
  388. + /**
  389. + * The teams of the TvTEvent<br>
  390. + */
  391. + public static TvTEventTeams[] _teams = new TvTEventTeams[2]; // event only allow max 2 teams
  392. + private static Spawn _npcSpawn = null;
  393. + /**
  394. + * The state of the TvTEvent<br>
  395. + */
  396. + public static EventState _state = EventState.INACTIVE;
  397. +
  398. + /**
  399. + * No instance of this class!<br>
  400. + */
  401. + private TvTEvent()
  402. + {
  403. + }
  404. +
  405. + /**
  406. + * Teams initializing<br>
  407. + */
  408. + public static void init()
  409. + {
  410. + _teams[0] = new TvTEventTeams(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
  411. + _teams[1] = new TvTEventTeams(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
  412. + }
  413. +
  414. + /**
  415. + * Starts the participation of the TvTEvent<br>
  416. + * 1. Get NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
  417. + * 2. Try to spawn a new npc of it<br>
  418. + * <br>
  419. + * @return boolean<br>
  420. + */
  421. + public static boolean startParticipation()
  422. + {
  423. + NpcTemplate tmpl = NpcData.getInstance().getTemplate(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
  424. +
  425. + if (tmpl == null)
  426. + {
  427. + System.out.println("TvTEventEngine[TvTEvent.startParticipation()]: L2NpcTemplate is a NullPointer -> Invalid npc id in configs?");
  428. + return false;
  429. + }
  430. +
  431. + try
  432. + {
  433. + _npcSpawn = new Spawn(tmpl);
  434. + _npcSpawn.setLoc(Config.TVT_EVENT_BACK_COORDINATES[0],Config.TVT_EVENT_BACK_COORDINATES[1],Config.TVT_EVENT_BACK_COORDINATES[2], 0);
  435. + //_npcSpawn.setLocy(Config.TVT_EVENT_BACK_COORDINATES[1]);
  436. + //_npcSpawn.setLocz(Config.TVT_EVENT_BACK_COORDINATES[2]);
  437. + //_npcSpawn.getAmount();
  438. + _npcSpawn.getHeading();
  439. + _npcSpawn.setRespawnDelay(1);
  440. +
  441. + SpawnTable.getInstance().addSpawn(_npcSpawn, false);
  442. +
  443. + _npcSpawn.setRespawnState(true);
  444. + _npcSpawn.doSpawn(false);
  445. + _npcSpawn.getNpc().isAggressive();
  446. + _npcSpawn.getNpc().decayMe();
  447. + _npcSpawn.getNpc().spawnMe(_npcSpawn.getNpc().getX(), _npcSpawn.getNpc().getY(), _npcSpawn.getNpc().getZ());
  448. +
  449. + _npcSpawn.getNpc().broadcastPacket(new MagicSkillUse(_npcSpawn.getNpc(), _npcSpawn.getNpc(), 1034, 1, 1, 1));
  450. + }
  451. + catch (Exception e)
  452. + {
  453. + System.out.println("TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e);
  454. + return false;
  455. + }
  456. +
  457. + setState(EventState.PARTICIPATING);
  458. + return true;
  459. + }
  460. +
  461. + /**
  462. + * Unspawn event npc.
  463. + */
  464. + public static void unspawnEventNpc()
  465. + {
  466. + if (_npcSpawn == null || _npcSpawn.getNpc() == null)
  467. + return;
  468. +
  469. + _npcSpawn.getNpc().deleteMe();
  470. + _npcSpawn.setRespawnState(false);
  471. + SpawnTable.getInstance().deleteSpawn(_npcSpawn, true);
  472. + }
  473. +
  474. + /**
  475. + * Starts the TvTEvent fight<br>
  476. + * 1. Set state EventState.STARTING<br>
  477. + * 2. Close doors specified in configs<br>
  478. + * 3. Abort if not enought participants(return false)<br>
  479. + * 4. Set state EventState.STARTED<br>
  480. + * 5. Teleport all participants to team spot<br>
  481. + * <br>
  482. + * @return boolean<br>
  483. + */
  484. + public static boolean startFight()
  485. + {
  486. + setState(EventState.STARTING);
  487. +
  488. + // not enought participants
  489. + if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
  490. + {
  491. + setState(EventState.INACTIVE);
  492. + unspawnEventNpc();
  493. + _teams[0].cleanMe();
  494. + _teams[1].cleanMe();
  495. + return false;
  496. + }
  497. +
  498. + closeDoors();
  499. + setState(EventState.STARTED); // set state to STARTED here, so TvTEventTeleporter know to teleport to team spot
  500. +
  501. + // teleport all participants to there team spot
  502. + for (TvTEventTeams team : _teams)
  503. + {
  504. + for (String playerName : team.getParticipatedPlayerNames())
  505. + {
  506. + Player playerInstance = team.getParticipatedPlayers().get(playerName);
  507. +
  508. + if (playerInstance == null)
  509. + continue;
  510. +
  511. + // leave party
  512. + // playerInstance.leaveParty();
  513. + playerInstance.removeMeFromPartyMatch();
  514. + // Get Noblesse effect
  515. + noblesse.getEffects(playerInstance, playerInstance);
  516. +
  517. + // implements Runnable and starts itself in constructor
  518. + new TvTEventTeleport(playerInstance, team.getCoordinates(), false, false);
  519. + }
  520. + }
  521. +
  522. + return true;
  523. + }
  524. +
  525. + /**
  526. + * Calculates the TvTEvent reward<br>
  527. + * 1. If both teams are at a tie(points equals), send it as system message to all participants, if one of the teams have 0 participants left online abort rewarding<br>
  528. + * 2. Wait till teams are not at a tie anymore<br>
  529. + * 3. Set state EvcentState.REWARDING<br>
  530. + * 4. Reward team with more points<br>
  531. + * 5. Show win html to wining team participants<br>
  532. + * <br>
  533. + * @return String<br>
  534. + */
  535. + public static String calculateRewards()
  536. + {
  537. + if (_teams[0].getPoints() == _teams[1].getPoints())
  538. + {
  539. + if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
  540. + {
  541. + // the fight cannot be completed
  542. + setState(EventState.REWARDING);
  543. + return "TvT Event: Event finish. No team won, cause of inactivity!";
  544. + }
  545. +
  546. + sysMsgToAllParticipants("TvT Event: Both teams are at a tie, next team to get a kill wins!");
  547. + }
  548. +
  549. + while (_teams[0].getPoints() == _teams[1].getPoints())
  550. + {
  551. + waiter(1);
  552. + }
  553. +
  554. + setState(EventState.REWARDING); // after state REWARDING is set, nobody can point anymore
  555. +
  556. + byte teamId = (byte) (_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
  557. + TvTEventTeams team = _teams[teamId];
  558. +
  559. + for (String playerName : team.getParticipatedPlayerNames())
  560. + {
  561. + for (int[] reward : Config.TVT_EVENT_REWARDS)
  562. + {
  563. + if (team.getParticipatedPlayers().get(playerName) == null)
  564. + continue;
  565. +
  566. + PcInventory inv = team.getParticipatedPlayers().get(playerName).getInventory();
  567. +
  568. + if (ItemData.getInstance().createDummyItem(reward[0]).isStackable())
  569. + inv.addItem("TvT Event", reward[0], reward[1], team.getParticipatedPlayers().get(playerName), team.getParticipatedPlayers().get(playerName));
  570. + else
  571. + {
  572. + for (int i = 0; i < reward[1]; i++)
  573. + inv.addItem("TvT Event", reward[0], 1, team.getParticipatedPlayers().get(playerName), team.getParticipatedPlayers().get(playerName));
  574. + }
  575. +
  576. + SystemMessage systemMessage = null;
  577. +
  578. + if (reward[1] > 1)
  579. + {
  580. + systemMessage = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
  581. + systemMessage.addItemName(reward[0]);
  582. + systemMessage.addNumber(reward[1]);
  583. + }
  584. + else
  585. + {
  586. + systemMessage = new SystemMessage(SystemMessageId.EARNED_ITEM_S1);
  587. + systemMessage.addItemName(reward[0]);
  588. + }
  589. +
  590. + team.getParticipatedPlayers().get(playerName).sendPacket(systemMessage);
  591. + }
  592. +
  593. + StatusUpdate statusUpdate = new StatusUpdate(team.getParticipatedPlayers().get(playerName));
  594. +
  595. + // statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, team.getParticipatedPlayers().get(playerName).getCurrentLoad());
  596. + team.getParticipatedPlayers().get(playerName).sendPacket(statusUpdate);
  597. +
  598. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  599. +
  600. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>");
  601. + team.getParticipatedPlayers().get(playerName).sendPacket(npcHtmlMessage);
  602. + }
  603. +
  604. + return "TvT Event: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
  605. + }
  606. +
  607. + /**
  608. + * Stops the TvTEvent fight<br>
  609. + * 1. Set state EventState.INACTIVATING<br>
  610. + * 2. Remove tvt npc from world<br>
  611. + * 3. Open doors specified in configs<br>
  612. + * 4. Teleport all participants back to participation npc location<br>
  613. + * 5. Teams cleaning<br>
  614. + * 6. Set state EventState.INACTIVE<br>
  615. + */
  616. + public static void stopFight()
  617. + {
  618. + setState(EventState.INACTIVATING);
  619. + openDoors();
  620. + unspawnEventNpc();
  621. +
  622. + for (TvTEventTeams team : _teams)
  623. + {
  624. + for (String playerName : team.getParticipatedPlayerNames())
  625. + {
  626. + Player playerInstance = team.getParticipatedPlayers().get(playerName);
  627. +
  628. + if (playerInstance == null)
  629. + continue;
  630. +
  631. + new TvTEventTeleport(playerInstance, Config.TVT_EVENT_BACK_COORDINATES, false, false);
  632. + }
  633. + }
  634. +
  635. + _teams[0].cleanMe();
  636. + _teams[1].cleanMe();
  637. +
  638. + setState(EventState.INACTIVE);
  639. +
  640. + }
  641. +
  642. + /**
  643. + * Adds a player to a TvTEvent team<br>
  644. + * 1. Calculate the id of the team in which the player should be added<br>
  645. + * 2. Add the player to the calculated team
  646. + * @param playerInstance
  647. + * @return boolean
  648. + */
  649. + public static synchronized boolean addParticipant(Player playerInstance)
  650. + {
  651. + if (playerInstance == null)
  652. + return false;
  653. +
  654. + byte teamId = 0;
  655. +
  656. + if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
  657. + teamId = (byte) (Rnd.get(2));
  658. + else
  659. + teamId = (byte) (_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
  660. +
  661. + return _teams[teamId].addPlayer(playerInstance);
  662. + }
  663. +
  664. + /**
  665. + * Removes a TvTEvent player from it's team<br>
  666. + * 1. Get team id of the player<br>
  667. + * 2. Remove player from it's team
  668. + * @param playerName
  669. + * @return boolean
  670. + */
  671. + public static boolean removeParticipant(String playerName)
  672. + {
  673. + byte teamId = getParticipantTeamId(playerName);
  674. +
  675. + if (teamId == -1)
  676. + return false;
  677. +
  678. + _teams[teamId].removePlayer(playerName);
  679. + return true;
  680. + }
  681. +
  682. + /**
  683. + * Send a SystemMessage to all participated players<br>
  684. + * 1. Send the message to all players of team number one<br>
  685. + * 2. Send the message to all players of team number two
  686. + * @param message
  687. + */
  688. + public static void sysMsgToAllParticipants(String message)
  689. + {
  690. + for (Player playerInstance : _teams[0].getParticipatedPlayers().values())
  691. + {
  692. + if (playerInstance != null)
  693. + playerInstance.sendMessage(message);
  694. + }
  695. +
  696. + for (Player playerInstance : _teams[1].getParticipatedPlayers().values())
  697. + {
  698. + if (playerInstance != null)
  699. + playerInstance.sendMessage(message);
  700. + }
  701. + }
  702. +
  703. + /**
  704. + * Close doors specified in configs
  705. + */
  706. + public static void closeDoors()
  707. + {
  708. + for (int doorId : Config.TVT_EVENT_DOOR_IDS)
  709. + {
  710. + Door doorInstance = DoorData.getInstance().getDoor(doorId);
  711. +
  712. + if (doorInstance != null)
  713. + doorInstance.closeMe();
  714. + }
  715. + }
  716. +
  717. + /**
  718. + * Open doors specified in configs
  719. + */
  720. + public static void openDoors()
  721. + {
  722. + for (int doorId : Config.TVT_EVENT_DOOR_IDS)
  723. + {
  724. + Door doorInstance = DoorData.getInstance().getDoor(doorId);
  725. +
  726. + if (doorInstance != null)
  727. + doorInstance.openMe();
  728. + }
  729. + }
  730. +
  731. + public static void waiter(int seconds)
  732. + {
  733. + try
  734. + {
  735. + Thread.sleep(seconds * 1000);
  736. + }
  737. + catch (InterruptedException e)
  738. + {
  739. + e.printStackTrace();
  740. + }
  741. + }
  742. +
  743. + /**
  744. + * Called when a player logs in
  745. + * @param playerInstance
  746. + * @param player
  747. + */
  748. + public static void onLogin(Player playerInstance, Player player)
  749. + {
  750. + if (playerInstance == null || (!isStarting() && !isStarted()))
  751. + return;
  752. +
  753. + byte teamId = getParticipantTeamId(playerInstance.getName());
  754. +
  755. + if (teamId == -1)
  756. + return;
  757. +
  758. + _teams[teamId].addPlayer(playerInstance);
  759. + new TvTEventTeleport(playerInstance, _teams[teamId].getCoordinates(), true, false);
  760. + }
  761. +
  762. + /**
  763. + * Called when a player logs out
  764. + * @param playerInstance
  765. + * @param player
  766. + */
  767. + public static void onLogout(Player playerInstance, Player player)
  768. + {
  769. + if (playerInstance == null || (!isStarting() && !isStarted()))
  770. + return;
  771. +
  772. + removeParticipant(playerInstance.getName());
  773. + }
  774. +
  775. + /**
  776. + * Called on every bypass by npc of type L2TvTEventNpc<br>
  777. + * Needs synchronization cause of the max player check
  778. + * @param command
  779. + * @param playerInstance
  780. + */
  781. + public static synchronized void onBypass(String command, Player playerInstance)
  782. + {
  783. + if (playerInstance == null || !isParticipating())
  784. + return;
  785. +
  786. + if (command.equals("tvt_event_participation"))
  787. + {
  788. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  789. + int playerLevel = playerInstance.getStatus().getLevel();
  790. +
  791. + if (playerInstance.isCursedWeaponEquipped())
  792. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Cursed weapon owners are not allowed to participate.</body></html>");
  793. + else if (OlympiadManager.getInstance().isRegisteredInComp(playerInstance))
  794. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Olympiad participants can't register.</body></html>");
  795. + else if (playerInstance.getKarma() > 0)
  796. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Chaotic players are not allowed to participate.</body></html>");
  797. + else if (_teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
  798. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Sorry the event is full!</body></html>");
  799. + else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
  800. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Only players from level " + Config.TVT_EVENT_MIN_LVL + " to level " + Config.TVT_EVENT_MAX_LVL + " are allowed tro participate.</body></html>");
  801. + else if (_teams[0].getParticipatedPlayerCount() > 19 && _teams[1].getParticipatedPlayerCount() > 19)
  802. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + " player are allowed in one team.</body></html>");
  803. + else if (addParticipant(playerInstance))
  804. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
  805. + else // addParticipant returned false cause playerInstance == null
  806. + return;
  807. +
  808. + playerInstance.sendPacket(npcHtmlMessage);
  809. + }
  810. + else if (command.equals("tvt_event_remove_participation"))
  811. + {
  812. + removeParticipant(playerInstance.getName());
  813. +
  814. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  815. +
  816. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
  817. + playerInstance.sendPacket(npcHtmlMessage);
  818. + }
  819. + }
  820. +
  821. + /**
  822. + * Called on every onAction in L2PcIstance
  823. + * @param playerName
  824. + * @param targetPlayerName
  825. + * @return boolean
  826. + */
  827. + public static boolean onAction(String playerName, String targetPlayerName)
  828. + {
  829. + if (!isStarted())
  830. + return true;
  831. +
  832. + Player playerInstance = World.getInstance().getPlayer(playerName);
  833. +
  834. + if (playerInstance == null)
  835. + return false;
  836. +
  837. + if (playerInstance.isGM())
  838. + return true;
  839. +
  840. + byte playerTeamId = getParticipantTeamId(playerName);
  841. + byte targetPlayerTeamId = getParticipantTeamId(targetPlayerName);
  842. +
  843. + if ((playerTeamId != -1 && targetPlayerTeamId == -1) || (playerTeamId == -1 && targetPlayerTeamId != -1))
  844. + return false;
  845. +
  846. + if (playerTeamId != -1 && targetPlayerTeamId != -1 && playerTeamId == targetPlayerTeamId && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
  847. + return false;
  848. +
  849. + return true;
  850. + }
  851. +
  852. + /**
  853. + * Called on every summon item use
  854. + * @param playerName
  855. + * @return boolean
  856. + */
  857. + public static boolean onItemSummon(String playerName)
  858. + {
  859. + if (!isStarted())
  860. + return true;
  861. +
  862. + if (isPlayerParticipant(playerName) && !Config.TVT_EVENT_SUMMON_BY_ITEM_ALLOWED)
  863. + return false;
  864. +
  865. + return true;
  866. + }
  867. +
  868. + /**
  869. + * Is called when a player is killed
  870. + * @param killerCharacter
  871. + * @param killedPlayerInstance
  872. + */
  873. + public static void onKill(Creature killerCharacter, Player killedPlayerInstance)
  874. + {
  875. + if (killerCharacter == null || killedPlayerInstance == null || (!(killerCharacter instanceof Player) && !(killerCharacter instanceof Pet) && !(killerCharacter instanceof Servitor )) || !isStarted())
  876. + return;
  877. +
  878. + Player killerPlayerInstance = null;
  879. +
  880. + if (killerCharacter instanceof Pet || killerCharacter instanceof Servitor )
  881. + {
  882. + killerPlayerInstance = ((Summon) killerCharacter).getOwner();
  883. +
  884. + if (killerPlayerInstance == null)
  885. + return;
  886. + }
  887. + else
  888. + killerPlayerInstance = (Player) killerCharacter;
  889. +
  890. + if (Config.TVT_KILLS_REWARD_ENABLED)
  891. + for (int[] rewardKills : Config.TVT_KILLS_REWARD)
  892. + {
  893. + SystemMessage systemMessage = null;
  894. + // Count the kill
  895. + killerPlayerInstance._tvtkills++;
  896. + switch (killerPlayerInstance._tvtkills)
  897. + {
  898. + case 5: // Reward after 5 kills without die
  899. + case 8: // Reward after 8 kills without die
  900. + case 12: // Reward after 12 kills without die
  901. + case 15: // Reward after 15 kills without die
  902. + case 20: // Reward after 20 kills without die
  903. +
  904. + systemMessage = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
  905. + systemMessage.addItemName(rewardKills[0]);
  906. + systemMessage.addNumber(rewardKills[1]);
  907. +
  908. + World.announceToOnlinePlayers("TvT Event: Player " + killerPlayerInstance.getName() + " has " + killerPlayerInstance._tvtkills + " kills without die.", true);
  909. + killerPlayerInstance.getInventory().addItem("TvT Event", rewardKills[0], rewardKills[1], killerPlayerInstance, killerPlayerInstance);
  910. + killerPlayerInstance.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Amazing", +killerPlayerInstance._tvtkills + " kills without die. You has been rewarded!"));
  911. + killerPlayerInstance.sendPacket(systemMessage);
  912. + break;
  913. + }
  914. + }
  915. +
  916. + String playerName = killerPlayerInstance.getName();
  917. + byte killerTeamId = getParticipantTeamId(playerName);
  918. +
  919. + playerName = killedPlayerInstance.getName();
  920. +
  921. + byte killedTeamId = getParticipantTeamId(playerName);
  922. +
  923. + if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
  924. + _teams[killerTeamId].increasePoints();
  925. +
  926. + if (killedTeamId != -1)
  927. + new TvTEventTeleport(killedPlayerInstance, _teams[killedTeamId].getCoordinates(), false, false);
  928. + }
  929. +
  930. + /**
  931. + * Sets the TvTEvent state
  932. + * @param state
  933. + */
  934. + private static void setState(EventState state)
  935. + {
  936. + synchronized (_state)
  937. + {
  938. + _state = state;
  939. + }
  940. + }
  941. +
  942. + /**
  943. + * Is TvTEvent inactive?
  944. + * @return boolean
  945. + */
  946. + public static boolean isInactive()
  947. + {
  948. + boolean isInactive;
  949. +
  950. + synchronized (_state)
  951. + {
  952. + isInactive = _state == EventState.INACTIVE;
  953. + }
  954. +
  955. + return isInactive;
  956. + }
  957. +
  958. + /**
  959. + * Is TvTEvent in inactivating?
  960. + * @return boolean
  961. + */
  962. + public static boolean isInactivating()
  963. + {
  964. + boolean isInactivating;
  965. +
  966. + synchronized (_state)
  967. + {
  968. + isInactivating = _state == EventState.INACTIVATING;
  969. + }
  970. +
  971. + return isInactivating;
  972. + }
  973. +
  974. + /**
  975. + * Is TvTEvent in participation?
  976. + * @return boolean
  977. + */
  978. + public static boolean isParticipating()
  979. + {
  980. + boolean isParticipating;
  981. +
  982. + synchronized (_state)
  983. + {
  984. + isParticipating = _state == EventState.PARTICIPATING;
  985. + }
  986. +
  987. + return isParticipating;
  988. + }
  989. +
  990. + /**
  991. + * Is TvTEvent starting?
  992. + * @return boolean
  993. + */
  994. + public static boolean isStarting()
  995. + {
  996. + boolean isStarting;
  997. +
  998. + synchronized (_state)
  999. + {
  1000. + isStarting = _state == EventState.STARTING;
  1001. + }
  1002. +
  1003. + return isStarting;
  1004. + }
  1005. +
  1006. + /**
  1007. + * Is TvTEvent started?
  1008. + * @return boolean
  1009. + */
  1010. + public static boolean isStarted()
  1011. + {
  1012. + boolean isStarted;
  1013. +
  1014. + synchronized (_state)
  1015. + {
  1016. + isStarted = _state == EventState.STARTED;
  1017. + }
  1018. +
  1019. + return isStarted;
  1020. + }
  1021. +
  1022. + /**
  1023. + * Is TvTEvent rewarding?
  1024. + * @return boolean
  1025. + */
  1026. + public static boolean isRewarding()
  1027. + {
  1028. + boolean isRewarding;
  1029. +
  1030. + synchronized (_state)
  1031. + {
  1032. + isRewarding = _state == EventState.REWARDING;
  1033. + }
  1034. +
  1035. + return isRewarding;
  1036. + }
  1037. +
  1038. + /**
  1039. + * Returns the team id of a player, if player is not participant it returns -1
  1040. + * @param playerName
  1041. + * @return byte
  1042. + */
  1043. + public static byte getParticipantTeamId(String playerName)
  1044. + {
  1045. + return (byte) (_teams[0].containsPlayer(playerName) ? 0 : (_teams[1].containsPlayer(playerName) ? 1 : -1));
  1046. + }
  1047. +
  1048. + /**
  1049. + * Returns the team coordinates in which the player is in, if player is not in a team return null
  1050. + * @param playerName
  1051. + * @return int[]
  1052. + */
  1053. + public static int[] getParticipantTeamCoordinates(String playerName)
  1054. + {
  1055. + return _teams[0].containsPlayer(playerName) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerName) ? _teams[1].getCoordinates() : null);
  1056. + }
  1057. +
  1058. + /**
  1059. + * Is given player participant of the event?
  1060. + * @param playerName
  1061. + * @return boolean
  1062. + */
  1063. + public static boolean isPlayerParticipant(String playerName)
  1064. + {
  1065. + return _teams[0].containsPlayer(playerName) || _teams[1].containsPlayer(playerName);
  1066. + }
  1067. +
  1068. + /**
  1069. + * Returns participated player count<br>
  1070. + * <br>
  1071. + * @return int<br>
  1072. + */
  1073. + public static int getParticipatedPlayersCount()
  1074. + {
  1075. + return _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
  1076. + }
  1077. +
  1078. + /**
  1079. + * Returns teams names<br>
  1080. + * <br>
  1081. + * @return String[]<br>
  1082. + */
  1083. + public static String[] getTeamNames()
  1084. + {
  1085. + return new String[]
  1086. + {
  1087. + _teams[0].getName(),
  1088. + _teams[1].getName()
  1089. + };
  1090. + }
  1091. +
  1092. + /**
  1093. + * Returns player count of both teams<br>
  1094. + * <br>
  1095. + * @return int[]<br>
  1096. + */
  1097. + public static int[] getTeamsPlayerCounts()
  1098. + {
  1099. + return new int[]
  1100. + {
  1101. + _teams[0].getParticipatedPlayerCount(),
  1102. + _teams[1].getParticipatedPlayerCount()
  1103. + };
  1104. + }
  1105. +
  1106. + /**
  1107. + * Returns points count of both teams
  1108. + * @return int[]
  1109. + */
  1110. + public static int[] getTeamsPoints()
  1111. + {
  1112. + return new int[]
  1113. + {
  1114. + _teams[0].getPoints(),
  1115. + _teams[1].getPoints()
  1116. + };
  1117. + }
  1118. +}
  1119. \ No newline at end of file
  1120. diff --git a/java/net/sf/l2j/gameserver/events/TvTEventManager.java b/java/net/sf/l2j/gameserver/events/TvTEventManager.java
  1121. new file mode 100644
  1122. index 0000000..fcb79c4
  1123. --- /dev/null
  1124. +++ b/java/net/sf/l2j/gameserver/events/TvTEventManager.java
  1125. @@ -0,0 +1,153 @@
  1126. +/*
  1127. + * This program is free software: you can redistribute it and/or modify it under
  1128. + * the terms of the GNU General Public License as published by the Free Software
  1129. + * Foundation, either version 3 of the License, or (at your option) any later
  1130. + * version.
  1131. + *
  1132. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1133. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1134. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1135. + * details.
  1136. + *
  1137. + * You should have received a copy of the GNU General Public License along with
  1138. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1139. + */
  1140. +package net.sf.l2j.gameserver.events;
  1141. +
  1142. +import net.sf.l2j.commons.pool.ThreadPool;
  1143. +
  1144. +import net.sf.l2j.Config;
  1145. +import net.sf.l2j.gameserver.model.World;
  1146. +
  1147. +/**
  1148. + * @author FBIagent
  1149. + */
  1150. +public class TvTEventManager implements Runnable
  1151. +{
  1152. + /**
  1153. + * The one and only instance of this class<br>
  1154. + */
  1155. + private static TvTEventManager _instance = null;
  1156. +
  1157. + /**
  1158. + * New instance only by getInstance()<br>
  1159. + */
  1160. + private TvTEventManager()
  1161. + {
  1162. + if (Config.TVT_EVENT_ENABLED)
  1163. + {
  1164. + ThreadPool.schedule(this, 0);
  1165. + System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Started.");
  1166. + }
  1167. + else
  1168. + System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Engine is disabled.");
  1169. + }
  1170. +
  1171. + /**
  1172. + * Initialize new/Returns the one and only instance<br>
  1173. + * <br>
  1174. + * @return TvTManager<br>
  1175. + */
  1176. + public static TvTEventManager getInstance()
  1177. + {
  1178. + if (_instance == null)
  1179. + _instance = new TvTEventManager();
  1180. +
  1181. + return _instance;
  1182. + }
  1183. +
  1184. + /**
  1185. + * The task method to handle cycles of the event
  1186. + * @see java.lang.Runnable#run()
  1187. + */
  1188. + @Override
  1189. + public void run()
  1190. + {
  1191. + TvTEvent.init();
  1192. +
  1193. + for (;;)
  1194. + {
  1195. + waiter(Config.TVT_EVENT_INTERVAL * 60); // in config given as minutes
  1196. +
  1197. + if (!TvTEvent.startParticipation())
  1198. + {
  1199. + World.announceToOnlinePlayers("TvT Event: Event was canceled.", true);
  1200. + System.out.println("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
  1201. + continue;
  1202. + }
  1203. + World.announceToOnlinePlayers("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s). Type .tvtjoin or .tvtleave", true);
  1204. +
  1205. + waiter(Config.TVT_EVENT_PARTICIPATION_TIME * 60); // in config given as minutes
  1206. +
  1207. + if (!TvTEvent.startFight())
  1208. + {
  1209. + World.announceToOnlinePlayers("TvT Event: Event canceled due to lack of Participation.", true);
  1210. + System.out.println("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
  1211. + continue;
  1212. + }
  1213. + World.announceToOnlinePlayers("TvT Event: Registration closed!", true);
  1214. + TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  1215. +
  1216. + waiter(Config.TVT_EVENT_RUNNING_TIME * 60); // in config given as minutes
  1217. + World.announceToOnlinePlayers(TvTEvent.calculateRewards(), true);
  1218. + TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  1219. + TvTEvent.stopFight();
  1220. + }
  1221. + }
  1222. +
  1223. + /**
  1224. + * This method waits for a period time delay
  1225. + * @param seconds
  1226. + */
  1227. + void waiter(int seconds)
  1228. + {
  1229. + while (seconds > 1)
  1230. + {
  1231. + seconds--; // here because we don't want to see two time announce at the same time
  1232. +
  1233. + if (TvTEvent.isParticipating() || TvTEvent.isStarted())
  1234. + {
  1235. + switch (seconds)
  1236. + {
  1237. + case 3600: // 1 hour left
  1238. + if (TvTEvent.isParticipating())
  1239. + World.announceToOnlinePlayers("TvT Event: " + seconds / 60 / 60 + " hour(s) umtil registration is closed!", true);
  1240. + else if (TvTEvent.isStarted())
  1241. + TvTEvent.sysMsgToAllParticipants("TvT Event: " + seconds / 60 / 60 + " hour(s) until event is finished!");
  1242. +
  1243. + break;
  1244. + case 1800: // 30 minutes left
  1245. + case 900: // 15 minutes left
  1246. + case 600: // 10 minutes left
  1247. + case 300: // 5 minutes left
  1248. + case 240: // 4 minutes left
  1249. + case 180: // 3 minutes left
  1250. + case 120: // 2 minutes left
  1251. + case 60: // 1 minute left
  1252. + if (TvTEvent.isParticipating())
  1253. + World.announceToOnlinePlayers("TvT Event: " + seconds / 60 + " minute(s) until registration is closed!", true);
  1254. + else if (TvTEvent.isStarted())
  1255. + TvTEvent.sysMsgToAllParticipants("TvT Event: " + seconds / 60 + " minute(s) until the event is finished!");
  1256. +
  1257. + break;
  1258. + case 30: // 30 seconds left
  1259. + /**
  1260. + * case 15: // 15 seconds left case 10: // 10 seconds left
  1261. + */
  1262. + case 5: // 5 seconds left
  1263. +
  1264. + /**
  1265. + * case 4: // 4 seconds left case 3: // 3 seconds left case 2: // 2 seconds left case 1: // 1 seconds left
  1266. + */
  1267. + if (TvTEvent.isParticipating())
  1268. + World.announceToOnlinePlayers("TvT Event: " + seconds + " second(s) until registration is closed!", true);
  1269. + else if (TvTEvent.isStarted())
  1270. + TvTEvent.sysMsgToAllParticipants("TvT Event: " + seconds + " second(s) until the event is finished!");
  1271. +
  1272. + break;
  1273. + }
  1274. + }
  1275. + TvTEvent.waiter(1);
  1276. + }
  1277. + }
  1278. +}
  1279. \ No newline at end of file
  1280. diff --git a/java/net/sf/l2j/gameserver/events/TvTEventTeams.java b/java/net/sf/l2j/gameserver/events/TvTEventTeams.java
  1281. new file mode 100644
  1282. index 0000000..4f19ea6
  1283. --- /dev/null
  1284. +++ b/java/net/sf/l2j/gameserver/events/TvTEventTeams.java
  1285. @@ -0,0 +1,209 @@
  1286. +/*
  1287. + * This program is free software: you can redistribute it and/or modify it under
  1288. + * the terms of the GNU General Public License as published by the Free Software
  1289. + * Foundation, either version 3 of the License, or (at your option) any later
  1290. + * version.
  1291. + *
  1292. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1293. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1294. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1295. + * details.
  1296. + *
  1297. + * You should have received a copy of the GNU General Public License along with
  1298. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1299. + */
  1300. +package net.sf.l2j.gameserver.events;
  1301. +
  1302. +
  1303. +import java.util.HashMap;
  1304. +import java.util.Map;
  1305. +import java.util.Vector;
  1306. +
  1307. +import net.sf.l2j.gameserver.model.actor.Player;
  1308. +
  1309. +/**
  1310. + * @author FBIagent
  1311. + */
  1312. +public class TvTEventTeams
  1313. +{
  1314. + /**
  1315. + * The name of the team<br>
  1316. + */
  1317. + private String _name;
  1318. + /**
  1319. + * The team spot coordinated<br>
  1320. + */
  1321. + private int[] _coordinates = new int[3];
  1322. + /**
  1323. + * The points of the team<br>
  1324. + */
  1325. + private short _points;
  1326. + /**
  1327. + * Name and instance of all participated players in FastMap<br>
  1328. + */
  1329. + private Map<String, Player> _participatedPlayers = new HashMap<>();
  1330. + /**
  1331. + * Name of all participated players in Vector<br>
  1332. + */
  1333. + private Vector<String> _participatedPlayerNames = new Vector<>();
  1334. +
  1335. + /**
  1336. + * C'tor initialize the team
  1337. + * @param name
  1338. + * @param coordinates
  1339. + */
  1340. + public TvTEventTeams(String name, int[] coordinates)
  1341. + {
  1342. + _name = name;
  1343. + _coordinates = coordinates;
  1344. + _points = 0;
  1345. + }
  1346. +
  1347. + /**
  1348. + * Adds a player to the team
  1349. + * @param playerInstance
  1350. + * @return boolean
  1351. + */
  1352. + public boolean addPlayer(Player playerInstance)
  1353. + {
  1354. + if (playerInstance == null)
  1355. + return false;
  1356. +
  1357. + synchronized (_participatedPlayers)
  1358. + {
  1359. + String playerName = playerInstance.getName();
  1360. +
  1361. + _participatedPlayers.put(playerName, playerInstance);
  1362. +
  1363. + if (!_participatedPlayerNames.contains(playerName))
  1364. + _participatedPlayerNames.add(playerName);
  1365. + }
  1366. +
  1367. + return true;
  1368. + }
  1369. +
  1370. + /**
  1371. + * Removes a player from the team
  1372. + * @param playerName
  1373. + */
  1374. + public void removePlayer(String playerName)
  1375. + {
  1376. + synchronized (_participatedPlayers)
  1377. + {
  1378. + _participatedPlayers.remove(playerName);
  1379. + _participatedPlayerNames.remove(playerName);
  1380. + }
  1381. + }
  1382. +
  1383. + /**
  1384. + * Increases the points of the team<br>
  1385. + */
  1386. + public void increasePoints()
  1387. + {
  1388. + _points++;
  1389. + }
  1390. +
  1391. + /**
  1392. + * Cleanup the team and make it ready for adding players again<br>
  1393. + */
  1394. + public void cleanMe()
  1395. + {
  1396. + _participatedPlayers.clear();
  1397. + _participatedPlayerNames.clear();
  1398. + _participatedPlayers = new HashMap<>();
  1399. + _participatedPlayerNames = new Vector<>();
  1400. + _points = 0;
  1401. + }
  1402. +
  1403. + /**
  1404. + * Is given player in this team?
  1405. + * @param playerName
  1406. + * @return boolean
  1407. + */
  1408. + public boolean containsPlayer(String playerName)
  1409. + {
  1410. + boolean containsPlayer;
  1411. +
  1412. + synchronized (_participatedPlayers)
  1413. + {
  1414. + containsPlayer = _participatedPlayerNames.contains(playerName);
  1415. + }
  1416. +
  1417. + return containsPlayer;
  1418. + }
  1419. +
  1420. + /**
  1421. + * Returns the name of the team
  1422. + * @return String
  1423. + */
  1424. + public String getName()
  1425. + {
  1426. + return _name;
  1427. + }
  1428. +
  1429. + /**
  1430. + * Returns the coordinates of the team spot
  1431. + * @return int[]
  1432. + */
  1433. + public int[] getCoordinates()
  1434. + {
  1435. + return _coordinates;
  1436. + }
  1437. +
  1438. + /**
  1439. + * Returns the points of the team
  1440. + * @return short
  1441. + */
  1442. + public short getPoints()
  1443. + {
  1444. + return _points;
  1445. + }
  1446. +
  1447. + /**
  1448. + * Returns name and instance of all participated players in FastMap
  1449. + * @return Map<String, Player>
  1450. + */
  1451. + public Map<String, Player> getParticipatedPlayers()
  1452. + {
  1453. + Map<String, Player> participatedPlayers = null;
  1454. +
  1455. + synchronized (_participatedPlayers)
  1456. + {
  1457. + participatedPlayers = _participatedPlayers;
  1458. + }
  1459. +
  1460. + return participatedPlayers;
  1461. + }
  1462. +
  1463. + /**
  1464. + * Returns name of all participated players in Vector
  1465. + * @return Vector<String>
  1466. + */
  1467. + public Vector<String> getParticipatedPlayerNames()
  1468. + {
  1469. + Vector<String> participatedPlayerNames = null;
  1470. +
  1471. + synchronized (_participatedPlayers)
  1472. + {
  1473. + participatedPlayerNames = _participatedPlayerNames;
  1474. + }
  1475. +
  1476. + return participatedPlayerNames;
  1477. + }
  1478. +
  1479. + /**
  1480. + * Returns player count of this team
  1481. + * @return int
  1482. + */
  1483. + public int getParticipatedPlayerCount()
  1484. + {
  1485. + int participatedPlayerCount;
  1486. +
  1487. + synchronized (_participatedPlayers)
  1488. + {
  1489. + participatedPlayerCount = _participatedPlayers.size();
  1490. + }
  1491. +
  1492. + return participatedPlayerCount;
  1493. + }
  1494. +}
  1495. \ No newline at end of file
  1496. diff --git a/java/net/sf/l2j/gameserver/events/TvTEventTeleport.java b/java/net/sf/l2j/gameserver/events/TvTEventTeleport.java
  1497. new file mode 100644
  1498. index 0000000..2745b70
  1499. --- /dev/null
  1500. +++ b/java/net/sf/l2j/gameserver/events/TvTEventTeleport.java
  1501. @@ -0,0 +1,101 @@
  1502. +/*
  1503. + * This program is free software: you can redistribute it and/or modify it under
  1504. + * the terms of the GNU General Public License as published by the Free Software
  1505. + * Foundation, either version 3 of the License, or (at your option) any later
  1506. + * version.
  1507. + *
  1508. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1509. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1510. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1511. + * details.
  1512. + *
  1513. + * You should have received a copy of the GNU General Public License along with
  1514. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1515. + */
  1516. +package net.sf.l2j.gameserver.events;
  1517. +
  1518. +import net.sf.l2j.commons.pool.ThreadPool;
  1519. +
  1520. +import net.sf.l2j.Config;
  1521. +import net.sf.l2j.gameserver.data.SkillTable;
  1522. +import net.sf.l2j.gameserver.model.actor.Player;
  1523. +import net.sf.l2j.gameserver.model.actor.Summon;
  1524. +import net.sf.l2j.gameserver.skills.AbstractEffect;
  1525. +import net.sf.l2j.gameserver.skills.L2Skill;
  1526. +
  1527. +public class TvTEventTeleport implements Runnable
  1528. +{
  1529. + /** Gives Noblesse to players */
  1530. + static L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
  1531. + /** The instance of the player to teleport */
  1532. + public Player _playerInstance;
  1533. + /** Coordinates of the spot to teleport to */
  1534. + public int[] _coordinates = new int[3];
  1535. + /** Admin removed this player from event */
  1536. + private boolean _adminRemove;
  1537. +
  1538. + /**
  1539. + * Initialize the teleporter and start the delayed task
  1540. + * @param playerInstance
  1541. + * @param coordinates
  1542. + * @param fastSchedule
  1543. + * @param adminRemove
  1544. + */
  1545. + public TvTEventTeleport(Player playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
  1546. + {
  1547. + _playerInstance = playerInstance;
  1548. + _coordinates = coordinates;
  1549. + _adminRemove = adminRemove;
  1550. +
  1551. + // in config as seconds
  1552. + long delay = (TvTEvent.isStarted() ? Config.TVT_EVENT_RESPAWN_TELEPORT_DELAY : Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
  1553. +
  1554. + if (fastSchedule)
  1555. + delay = 0;
  1556. +
  1557. + ThreadPool.schedule(this, delay);
  1558. + }
  1559. +
  1560. + /**
  1561. + * The task method to teleport the player<br>
  1562. + * 1. Unsummon pet if there is one 2. Remove all effects 3. Revive and full heal the player 4. Teleport the player 5. Broadcast status and user info
  1563. + * @see java.lang.Runnable#run()
  1564. + */
  1565. + @Override
  1566. + public void run()
  1567. + {
  1568. + if (_playerInstance == null)
  1569. + return;
  1570. +
  1571. + Summon summon = _playerInstance.getSummon();
  1572. +
  1573. + if (summon != null)
  1574. + summon.unSummon(_playerInstance);
  1575. +
  1576. + for (AbstractEffect effect : _playerInstance.getAllEffects())
  1577. + {
  1578. + if (Config.TVT_EVENT_REMOVE_BUFFS && effect != null)
  1579. + effect.exit();
  1580. + }
  1581. +
  1582. + ThreadPool.schedule(new Runnable()
  1583. + {
  1584. + @Override
  1585. + public void run()
  1586. + {
  1587. + _playerInstance.doRevive();
  1588. + _playerInstance.getStatus().setMaxCpHpMp();
  1589. + noblesse.getEffects(_playerInstance, _playerInstance);
  1590. + _playerInstance.teleportTo(_coordinates[0], _coordinates[1], _coordinates[2], 0);
  1591. + }
  1592. + }, 4000);
  1593. +
  1594. + if (TvTEvent.isStarted() && !_adminRemove)
  1595. + _playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getName()) + 1);
  1596. + else
  1597. + _playerInstance.setTeam(0);
  1598. +
  1599. + //_playerInstance.broadcastStatusUpdate();
  1600. + _playerInstance.broadcastUserInfo();
  1601. + }
  1602. +}
  1603. \ No newline at end of file
  1604. diff --git a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  1605. index 2abbe8b..22f66da 100644
  1606. --- a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  1607. +++ b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  1608. @@ -36,6 +36,7 @@
  1609. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTarget;
  1610. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTeleport;
  1611. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTest;
  1612. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTvTEvent;
  1613. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminVip;
  1614. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
  1615.  
  1616. @@ -45,6 +46,7 @@
  1617.  
  1618. protected AdminCommandHandler()
  1619. {
  1620. + registerHandler(new AdminTvTEvent());
  1621. registerHandler(new AdminLevel());
  1622. registerHandler(new AdminCustom());
  1623. registerHandler(new AdminVip());
  1624. diff --git a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  1625. index 1c2a717..55c8191 100644
  1626. --- a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  1627. +++ b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  1628. @@ -28,6 +28,7 @@
  1629. import net.sf.l2j.gameserver.GameServer;
  1630. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.GainXpSp;
  1631. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Shiff_Mod;
  1632. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TvTEventCommand;
  1633. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoicedBanking;
  1634. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoicedBossSpawn;
  1635. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.VoicedCastles;
  1636. @@ -59,6 +60,7 @@
  1637. private VoicedCommandHandler()
  1638. {
  1639. _datatable = new HashMap<>();
  1640. + registerVoicedCommandHandler(new TvTEventCommand());
  1641. registerVoicedCommandHandler(new Shiff_Mod());
  1642. if(Config.ENABLE_COMMAND_RAID)
  1643. {
  1644. diff --git a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java
  1645. new file mode 100644
  1646. index 0000000..a836558
  1647. --- /dev/null
  1648. +++ b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java
  1649. @@ -0,0 +1,90 @@
  1650. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  1651. +
  1652. +import net.sf.l2j.Config;
  1653. +import net.sf.l2j.gameserver.events.TvTEvent;
  1654. +import net.sf.l2j.gameserver.events.TvTEventTeleport;
  1655. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  1656. +import net.sf.l2j.gameserver.model.WorldObject;
  1657. +import net.sf.l2j.gameserver.model.actor.Player;
  1658. +
  1659. +/**
  1660. + * @author FBIagent The class handles administrator commands for the TvT Engine which was first implemented by FBIagent
  1661. + */
  1662. +public class AdminTvTEvent implements IAdminCommandHandler
  1663. +{
  1664. + private static final String[] ADMIN_COMMANDS =
  1665. + {
  1666. + "admin_tvt_add",
  1667. + "admin_tvt_remove"
  1668. + };
  1669. +
  1670. + @Override
  1671. + public void useAdminCommand(String command, Player adminInstance)
  1672. + {
  1673. +
  1674. + //AdminData.auditGMAction(adminInstance.getName(), command, (adminInstance.getTarget() != null ? adminInstance.getTarget().getName() : "no-target"), "");
  1675. +
  1676. + if (command.equals("admin_tvt_add"))
  1677. + {
  1678. + WorldObject target = adminInstance.getTarget();
  1679. +
  1680. + if (target == null || !(target instanceof Player))
  1681. + {
  1682. + adminInstance.sendMessage("You should select a player!");
  1683. + return;
  1684. + }
  1685. +
  1686. + add(adminInstance, (Player) target);
  1687. + }
  1688. + else if (command.equals("admin_tvt_remove"))
  1689. + {
  1690. + WorldObject target = adminInstance.getTarget();
  1691. +
  1692. + if (target == null || !(target instanceof Player))
  1693. + {
  1694. + adminInstance.sendMessage("You should select a player!");
  1695. + return;
  1696. + }
  1697. +
  1698. + remove(adminInstance, (Player) target);
  1699. + }
  1700. +
  1701. + return;
  1702. + }
  1703. +
  1704. + @Override
  1705. + public String[] getAdminCommandList()
  1706. + {
  1707. + return ADMIN_COMMANDS;
  1708. + }
  1709. +
  1710. + private static void add(Player adminInstance, Player playerInstance)
  1711. + {
  1712. + if (TvTEvent.isPlayerParticipant(playerInstance.getName()))
  1713. + {
  1714. + adminInstance.sendMessage("Player already participated in the event!");
  1715. + return;
  1716. + }
  1717. +
  1718. + if (!TvTEvent.addParticipant(playerInstance))
  1719. + {
  1720. + adminInstance.sendMessage("Player instance could not be added, it seems to be null!");
  1721. + return;
  1722. + }
  1723. +
  1724. + if (TvTEvent.isStarted())
  1725. + // we don't need to check return value of TvTEvent.getParticipantTeamCoordinates() for null, TvTEvent.addParticipant() returned true so target is in event
  1726. + new TvTEventTeleport(playerInstance, TvTEvent.getParticipantTeamCoordinates(playerInstance.getName()), true, false);
  1727. + }
  1728. +
  1729. + private static void remove(Player adminInstance, Player playerInstance)
  1730. + {
  1731. + if (!TvTEvent.removeParticipant(playerInstance.getName()))
  1732. + {
  1733. + adminInstance.sendMessage("Player is not part of the event!");
  1734. + return;
  1735. + }
  1736. +
  1737. + new TvTEventTeleport(playerInstance, Config.TVT_EVENT_BACK_COORDINATES, true, true);
  1738. + }
  1739. +}
  1740. \ No newline at end of file
  1741. diff --git a/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java b/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  1742. index 1792260..aec88a2 100644
  1743. --- a/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  1744. +++ b/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  1745. @@ -5,6 +5,7 @@
  1746. import net.sf.l2j.gameserver.data.SkillTable;
  1747. import net.sf.l2j.gameserver.data.xml.NpcData;
  1748. import net.sf.l2j.gameserver.data.xml.SummonItemData;
  1749. +import net.sf.l2j.gameserver.events.TvTEvent;
  1750. import net.sf.l2j.gameserver.handler.IItemHandler;
  1751. import net.sf.l2j.gameserver.model.actor.Npc;
  1752. import net.sf.l2j.gameserver.model.actor.Playable;
  1753. @@ -32,7 +33,8 @@
  1754. player.sendPacket(SystemMessageId.CANT_MOVE_SITTING);
  1755. return;
  1756. }
  1757. -
  1758. + if (!TvTEvent.onItemSummon(playable.getName()))
  1759. + return;
  1760. if (player.isInObserverMode())
  1761. return;
  1762.  
  1763. diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java
  1764. index 43f7687..bc3ca1a 100644
  1765. --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java
  1766. +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java
  1767. @@ -100,6 +100,9 @@
  1768.  
  1769. if (activeChar instanceof Player && ((Player) activeChar).isCursedWeaponEquipped())
  1770. continue;
  1771. +
  1772. + else if (((Player) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
  1773. + continue;
  1774. }
  1775.  
  1776. final double amount = target.getStatus().addHp(power * target.getStatus().calcStat(Stats.HEAL_EFFECTIVNESS, 100, null, null) / 100.);
  1777. diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
  1778. index 1763eac..27998ed 100644
  1779. --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
  1780. +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
  1781. @@ -47,7 +47,19 @@
  1782. // Doors and flags can't be healed in any way
  1783. if (target instanceof Door || target instanceof SiegeFlag)
  1784. continue;
  1785. + // Mana potions can't be used on event
  1786. + if (((Player) activeChar).isInFunEvent() && !Config.TVT_EVENT_POTIONS_ALLOWED)
  1787. + {
  1788. + if (skill.getSkillType() == SkillType.MANAHEAL_PERCENT)
  1789. + continue;
  1790. + }
  1791.  
  1792. + // Players can't be healed on event
  1793. + if (((Player) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
  1794. + {
  1795. + if (skill.getSkillType() == SkillType.HEAL_PERCENT)
  1796. + continue;
  1797. + }
  1798. final boolean isTargetPlayer = target instanceof Player;
  1799.  
  1800. // Cursed weapon owner can't heal or be healed
  1801. diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
  1802. index 128db81..d0da398 100644
  1803. --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
  1804. +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
  1805. @@ -2,6 +2,7 @@
  1806.  
  1807. import net.sf.l2j.gameserver.enums.items.ShotType;
  1808. import net.sf.l2j.gameserver.enums.skills.SkillType;
  1809. +import net.sf.l2j.gameserver.events.TvTEvent;
  1810. import net.sf.l2j.gameserver.handler.ISkillHandler;
  1811. import net.sf.l2j.gameserver.model.WorldObject;
  1812. import net.sf.l2j.gameserver.model.actor.Creature;
  1813. @@ -21,6 +22,11 @@
  1814. @Override
  1815. public void useSkill(Creature activeChar, L2Skill skill, WorldObject[] targets)
  1816. {
  1817. + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(activeChar.getName()))
  1818. + {
  1819. + activeChar.sendMessage("You can not use this action when it is participating in this event.");
  1820. + return;
  1821. + }
  1822. for (WorldObject cha : targets)
  1823. {
  1824. final Creature target = (Creature) cha;
  1825. diff --git a/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java b/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
  1826. index 8bac2b9..a63f474 100644
  1827. --- a/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
  1828. +++ b/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
  1829. @@ -2,6 +2,7 @@
  1830.  
  1831. import net.sf.l2j.gameserver.enums.ZoneId;
  1832. import net.sf.l2j.gameserver.enums.skills.SkillType;
  1833. +import net.sf.l2j.gameserver.events.TvTEvent;
  1834. import net.sf.l2j.gameserver.handler.ISkillHandler;
  1835. import net.sf.l2j.gameserver.model.WorldObject;
  1836. import net.sf.l2j.gameserver.model.actor.Creature;
  1837. @@ -27,7 +28,12 @@
  1838. return;
  1839.  
  1840. final Player player = (Player) activeChar;
  1841. -
  1842. + // Players can't summon anyone on event
  1843. + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  1844. + {
  1845. + player.sendMessage("You can not use this action when it is participating in this event.");
  1846. + return;
  1847. + }
  1848. // Check player status.
  1849. if (!checkSummoner(player))
  1850. return;
  1851. diff --git a/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java b/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  1852. index 7d6acb3..843411b 100644
  1853. --- a/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  1854. +++ b/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  1855. @@ -16,7 +16,7 @@
  1856. @Override
  1857. public void useUserCommand(int id, Player player)
  1858. {
  1859. - if (player.isInOlympiadMode() || player.isInObserverMode() || player.isFestivalParticipant() || player.isInJail() || player.isInsideZone(ZoneId.BOSS))
  1860. + if (player.isInOlympiadMode() || player.isInObserverMode() || player.isFestivalParticipant() || player.isInJail() || player.isInsideZone(ZoneId.BOSS) || player.isInFunEvent())
  1861. {
  1862. player.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
  1863. return;
  1864. diff --git a/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
  1865. new file mode 100644
  1866. index 0000000..f8441ab
  1867. --- /dev/null
  1868. +++ b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
  1869. @@ -0,0 +1,137 @@
  1870. +/*
  1871. + * This program is free software: you can redistribute it and/or modify it under
  1872. + * the terms of the GNU General Public License as published by the Free Software
  1873. + * Foundation, either version 3 of the License, or (at your option) any later
  1874. + * version.
  1875. + *
  1876. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1877. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1878. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1879. + * details.
  1880. + *
  1881. + * You should have received a copy of the GNU General Public License along with
  1882. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1883. + */
  1884. +
  1885. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  1886. +
  1887. +import net.sf.l2j.Config;
  1888. +import net.sf.l2j.gameserver.data.cache.HtmCache;
  1889. +import net.sf.l2j.gameserver.enums.SayType;
  1890. +import net.sf.l2j.gameserver.events.TvTEvent;
  1891. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  1892. +import net.sf.l2j.gameserver.model.actor.Player;
  1893. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  1894. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  1895. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1896. +
  1897. +/**
  1898. + * @author Baggos
  1899. + */
  1900. +
  1901. +public class TvTEventCommand implements IVoicedCommandHandler
  1902. +{
  1903. + private static final String[] VOICED_COMMANDS =
  1904. + {
  1905. + "tvtjoin",
  1906. + "tvtleave",
  1907. + "tvtstatus"
  1908. + };
  1909. +
  1910. + @Override
  1911. + public boolean useVoicedCommand(final String command, final Player activeChar, final String target)
  1912. + {
  1913. + if (command.startsWith("tvtjoin"))
  1914. + JoinTvT(target, activeChar);
  1915. +
  1916. + else if (command.startsWith("tvtleave"))
  1917. + LeaveTvT(activeChar);
  1918. +
  1919. + else if (command.startsWith("tvtstatus"))
  1920. + TvTStatus(activeChar);
  1921. +
  1922. + return true;
  1923. + }
  1924. +
  1925. + public static boolean JoinTvT(final String command, Player activeChar)
  1926. + {
  1927. + int playerLevel = activeChar.getStatus().getLevel();
  1928. + if (!TvTEvent.isParticipating())
  1929. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  1930. + else if (TvTEvent.isPlayerParticipant(activeChar.getName()))
  1931. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "You are already on the list."));
  1932. + else if (activeChar.isCursedWeaponEquipped())
  1933. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Cursed weapon owners are not allowed to participate."));
  1934. + else if (activeChar.isInJail())
  1935. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Nothing for you!."));
  1936. + else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
  1937. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Olympiad participants can't register."));
  1938. + else if (activeChar.getKarma() > 0)
  1939. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Chaotic players are not allowed to participate."));
  1940. + else if (TvTEvent._teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && TvTEvent._teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
  1941. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Sorry the event is full!"));
  1942. + else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
  1943. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "Only players from level " + Config.TVT_EVENT_MIN_LVL + " until level " + Config.TVT_EVENT_MAX_LVL + " are allowed to participate."));
  1944. + else if (TvTEvent._teams[0].getParticipatedPlayerCount() > 19 && TvTEvent._teams[1].getParticipatedPlayerCount() > 19)
  1945. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + " player are allowed in one team."));
  1946. + else
  1947. + {
  1948. + TvTEvent.addParticipant(activeChar);
  1949. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  1950. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
  1951. + activeChar.sendPacket(npcHtmlMessage);
  1952. + }
  1953. + return false;
  1954. + }
  1955. +
  1956. + public boolean LeaveTvT(final Player activeChar)
  1957. + {
  1958. + if (!TvTEvent.isParticipating())
  1959. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  1960. + else if (!TvTEvent.isInactive() && !TvTEvent.isPlayerParticipant(activeChar.getName()))
  1961. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "You aren't registered in the TvT Event."));
  1962. + else
  1963. + {
  1964. + TvTEvent.removeParticipant(activeChar.getName());
  1965. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  1966. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
  1967. + activeChar.sendPacket(npcHtmlMessage);
  1968. + }
  1969. + return false;
  1970. + }
  1971. +
  1972. + public boolean TvTStatus(final Player activeChar)
  1973. + {
  1974. + if (!TvTEvent.isStarted())
  1975. + activeChar.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "TvT Event", "TvT Event is not in progress yet."));
  1976. + else
  1977. + {
  1978. + String htmFile = "data/html/mods/TvTEventStatus.htm";
  1979. + String htmContent = HtmCache.getInstance().getHtm(htmFile);
  1980. +
  1981. + if (htmContent != null)
  1982. + {
  1983. + int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  1984. + int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
  1985. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(5);
  1986. +
  1987. + npcHtmlMessage.setHtml(htmContent);
  1988. + // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  1989. + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  1990. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  1991. + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  1992. + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  1993. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  1994. + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  1995. + activeChar.sendPacket(npcHtmlMessage);
  1996. + }
  1997. + }
  1998. + return false;
  1999. + }
  2000. +
  2001. + @Override
  2002. + public String[] getVoicedCommandList()
  2003. + {
  2004. + return VOICED_COMMANDS;
  2005. + }
  2006. +}
  2007. \ No newline at end of file
  2008. diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver/model/actor/Player.java
  2009. index 70a2fda..290b545 100644
  2010. --- a/java/net/sf/l2j/gameserver/model/actor/Player.java
  2011. +++ b/java/net/sf/l2j/gameserver/model/actor/Player.java
  2012. @@ -61,7 +61,6 @@
  2013. import net.sf.l2j.gameserver.enums.ShortcutType;
  2014. import net.sf.l2j.gameserver.enums.SpawnType;
  2015. import net.sf.l2j.gameserver.enums.StatusType;
  2016. -import net.sf.l2j.gameserver.enums.TeamType;
  2017. import net.sf.l2j.gameserver.enums.TeleportMode;
  2018. import net.sf.l2j.gameserver.enums.ZoneId;
  2019. import net.sf.l2j.gameserver.enums.actors.ClassId;
  2020. @@ -81,6 +80,7 @@
  2021. import net.sf.l2j.gameserver.enums.skills.EffectFlag;
  2022. import net.sf.l2j.gameserver.enums.skills.EffectType;
  2023. import net.sf.l2j.gameserver.enums.skills.Stats;
  2024. +import net.sf.l2j.gameserver.events.TvTEvent;
  2025. import net.sf.l2j.gameserver.geoengine.GeoEngine;
  2026. import net.sf.l2j.gameserver.handler.IItemHandler;
  2027. import net.sf.l2j.gameserver.handler.ItemHandler;
  2028. @@ -274,7 +274,8 @@
  2029. private long _onlineBeginTime;
  2030. private long _lastAccess;
  2031. private long _uptime;
  2032. -
  2033. + public int _tvtkills;
  2034. + public boolean atEvent = false;
  2035. protected int _baseClass;
  2036. protected int _activeClass;
  2037. protected int _classIndex;
  2038. @@ -428,7 +429,7 @@
  2039. private final int[] _loto = new int[5];
  2040. private final int[] _race = new int[2];
  2041.  
  2042. - private TeamType _team = TeamType.NONE;
  2043. + private int _team = 0;
  2044.  
  2045. private int _alliedVarkaKetra; // lvl of alliance with ketra orcs or varka silenos, used in quests and aggro checks [-5,-1] varka, 0 neutral, [1,5] ketra
  2046.  
  2047. @@ -2295,6 +2296,11 @@
  2048. @Override
  2049. public void onAction(Player player, boolean isCtrlPressed, boolean isShiftPressed)
  2050. {
  2051. + if (!TvTEvent.onAction(player.getName(), getName()))
  2052. + {
  2053. + player.sendPacket(ActionFailed.STATIC_PACKET);
  2054. + return;
  2055. + }
  2056. if (player.getTarget() != this)
  2057. player.setTarget(this);
  2058. else
  2059. @@ -2704,6 +2710,8 @@
  2060. if (isMounted())
  2061. stopFeed();
  2062.  
  2063. + _tvtkills = 0;
  2064. +
  2065. // Clean player charges on death.
  2066. clearCharges();
  2067.  
  2068. @@ -2712,7 +2720,7 @@
  2069. if (isFakeDeath())
  2070. stopFakeDeath(true);
  2071. }
  2072. -
  2073. + TvTEvent.onKill(killer, this);
  2074. if (killer != null)
  2075. {
  2076. final Player pk = killer.getActingPlayer();
  2077. @@ -2778,6 +2786,11 @@
  2078. return true;
  2079. }
  2080.  
  2081. + public boolean isInFunEvent()
  2082. + {
  2083. + return (atEvent || (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getName())) && !isGM());
  2084. + }
  2085. +
  2086. private void onDieDropItem(Creature killer)
  2087. {
  2088. if (killer == null)
  2089. @@ -5815,12 +5828,12 @@
  2090. return _lvlJoinedAcademy > 0;
  2091. }
  2092.  
  2093. - public void setTeam(TeamType team)
  2094. + public void setTeam(int team)
  2095. {
  2096. _team = team;
  2097. }
  2098.  
  2099. - public TeamType getTeam()
  2100. + public int getTeam()
  2101. {
  2102. return _team;
  2103. }
  2104. diff --git a/java/net/sf/l2j/gameserver/model/actor/Summon.java b/java/net/sf/l2j/gameserver/model/actor/Summon.java
  2105. index f0b8c83..a2cba5b 100644
  2106. --- a/java/net/sf/l2j/gameserver/model/actor/Summon.java
  2107. +++ b/java/net/sf/l2j/gameserver/model/actor/Summon.java
  2108. @@ -4,7 +4,6 @@
  2109.  
  2110. import net.sf.l2j.Config;
  2111. import net.sf.l2j.gameserver.data.xml.ItemData;
  2112. -import net.sf.l2j.gameserver.enums.TeamType;
  2113. import net.sf.l2j.gameserver.enums.actors.NpcSkillType;
  2114. import net.sf.l2j.gameserver.enums.items.ActionType;
  2115. import net.sf.l2j.gameserver.enums.items.ShotType;
  2116. @@ -171,9 +170,9 @@
  2117. return (getOwner() != null) ? getOwner().getPvpFlag() : 0;
  2118. }
  2119.  
  2120. - public final TeamType getTeam()
  2121. + public final int getTeam()
  2122. {
  2123. - return (getOwner() != null) ? getOwner().getTeam() : TeamType.NONE;
  2124. + return getOwner() != null ? getOwner().getTeam() : 0;
  2125. }
  2126.  
  2127. public final Player getOwner()
  2128. diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java b/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java
  2129. index d768cea..b9ba44e 100644
  2130. --- a/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java
  2131. +++ b/java/net/sf/l2j/gameserver/model/actor/instance/OlympiadManagerNpc.java
  2132. @@ -8,6 +8,7 @@
  2133. import net.sf.l2j.gameserver.data.manager.HeroManager;
  2134. import net.sf.l2j.gameserver.data.xml.MultisellData;
  2135. import net.sf.l2j.gameserver.enums.OlympiadType;
  2136. +import net.sf.l2j.gameserver.events.TvTEvent;
  2137. import net.sf.l2j.gameserver.model.actor.Player;
  2138. import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  2139. import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  2140. @@ -173,6 +174,11 @@
  2141. }
  2142. else if (command.startsWith("Olympiad"))
  2143. {
  2144. + if (TvTEvent.isParticipating())
  2145. + {
  2146. + player.sendMessage("You can't do that while in a event");
  2147. + return;
  2148. + }
  2149. int val = Integer.parseInt(command.substring(9, 10));
  2150.  
  2151. final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  2152. @@ -208,6 +214,11 @@
  2153. break;
  2154.  
  2155. case 3: // Spectator overview
  2156. + if (TvTEvent.isParticipating() || TvTEvent.isStarting() || TvTEvent.isStarted())
  2157. + {
  2158. + player.sendMessage("You can't do that while in a event");
  2159. + return;
  2160. + }
  2161. html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "olympiad_observe_list.htm");
  2162.  
  2163. int i = 0;
  2164. diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/TvTEventNpc.java b/java/net/sf/l2j/gameserver/model/actor/instance/TvTEventNpc.java
  2165. new file mode 100644
  2166. index 0000000..400c8b8
  2167. --- /dev/null
  2168. +++ b/java/net/sf/l2j/gameserver/model/actor/instance/TvTEventNpc.java
  2169. @@ -0,0 +1,82 @@
  2170. +package net.sf.l2j.gameserver.model.actor.instance;
  2171. +
  2172. +import net.sf.l2j.Config;
  2173. +import net.sf.l2j.gameserver.data.cache.HtmCache;
  2174. +import net.sf.l2j.gameserver.events.TvTEvent;
  2175. +import net.sf.l2j.gameserver.model.actor.Player;
  2176. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  2177. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  2178. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  2179. +
  2180. +public class TvTEventNpc extends Folk
  2181. +{
  2182. + public TvTEventNpc(int objectId, NpcTemplate template)
  2183. + {
  2184. + super(objectId, template);
  2185. + }
  2186. +
  2187. + @Override
  2188. + public void onBypassFeedback(Player playerInstance, String command)
  2189. + {
  2190. + TvTEvent.onBypass(command, playerInstance);
  2191. + }
  2192. +
  2193. + @Override
  2194. + public void showChatWindow(Player playerInstance, int val)
  2195. + {
  2196. + if (playerInstance == null)
  2197. + return;
  2198. +
  2199. + if (TvTEvent.isParticipating())
  2200. + {
  2201. + String htmFile = "data/html/mods/";
  2202. +
  2203. + if (!TvTEvent.isPlayerParticipant(playerInstance.getName()))
  2204. + htmFile += "TvTEventParticipation";
  2205. + else
  2206. + htmFile += "TvTEventRemoveParticipation";
  2207. +
  2208. + htmFile += ".htm";
  2209. +
  2210. + String htmContent = HtmCache.getInstance().getHtm(htmFile);
  2211. +
  2212. + if (htmContent != null)
  2213. + {
  2214. + int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  2215. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  2216. +
  2217. + npcHtmlMessage.setHtml(htmContent);
  2218. + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  2219. + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  2220. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  2221. + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  2222. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  2223. + playerInstance.sendPacket(npcHtmlMessage);
  2224. + }
  2225. + }
  2226. + else if (TvTEvent.isStarting() || TvTEvent.isStarted())
  2227. + {
  2228. + String htmFile = "data/html/mods/TvTEventStatus.htm";
  2229. + String htmContent = HtmCache.getInstance().getHtm(htmFile);
  2230. +
  2231. + if (htmContent != null)
  2232. + {
  2233. + int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  2234. + int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
  2235. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  2236. +
  2237. + npcHtmlMessage.setHtml(htmContent);
  2238. + // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  2239. + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  2240. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  2241. + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  2242. + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  2243. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  2244. + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  2245. + playerInstance.sendPacket(npcHtmlMessage);
  2246. + }
  2247. + }
  2248. +
  2249. + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
  2250. + }
  2251. +}
  2252. \ No newline at end of file
  2253. diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java b/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
  2254. index 25385b7..220f78a 100644
  2255. --- a/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
  2256. +++ b/java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
  2257. @@ -93,7 +93,7 @@
  2258. }
  2259.  
  2260. // Simple checks to avoid exploits
  2261. - if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  2262. + if (partner.isInFunEvent() || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  2263. {
  2264. player.sendMessage("Due to the current partner's status, the teleportation failed.");
  2265. return;
  2266. diff --git a/java/net/sf/l2j/gameserver/model/entity/Duel.java b/java/net/sf/l2j/gameserver/model/entity/Duel.java
  2267. index 8ca5ae8..c2902a1 100644
  2268. --- a/java/net/sf/l2j/gameserver/model/entity/Duel.java
  2269. +++ b/java/net/sf/l2j/gameserver/model/entity/Duel.java
  2270. @@ -8,7 +8,6 @@
  2271. import net.sf.l2j.commons.pool.ThreadPool;
  2272.  
  2273. import net.sf.l2j.gameserver.data.manager.DuelManager;
  2274. -import net.sf.l2j.gameserver.enums.TeamType;
  2275. import net.sf.l2j.gameserver.enums.ZoneId;
  2276. import net.sf.l2j.gameserver.model.actor.Player;
  2277. import net.sf.l2j.gameserver.model.actor.Summon;
  2278. @@ -312,7 +311,7 @@
  2279. {
  2280. partyPlayer.cancelActiveTrade();
  2281. partyPlayer.setDuelState(DuelState.DUELLING);
  2282. - partyPlayer.setTeam(TeamType.BLUE);
  2283. + partyPlayer.setTeam(1);
  2284. partyPlayer.broadcastUserInfo();
  2285.  
  2286. final Summon summon = partyPlayer.getSummon();
  2287. @@ -326,7 +325,7 @@
  2288. {
  2289. partyPlayer.cancelActiveTrade();
  2290. partyPlayer.setDuelState(DuelState.DUELLING);
  2291. - partyPlayer.setTeam(TeamType.RED);
  2292. + partyPlayer.setTeam(2);
  2293. partyPlayer.broadcastUserInfo();
  2294.  
  2295. final Summon summon = partyPlayer.getSummon();
  2296. @@ -349,9 +348,9 @@
  2297. {
  2298. // Set states.
  2299. _playerA.setDuelState(DuelState.DUELLING);
  2300. - _playerA.setTeam(TeamType.BLUE);
  2301. + _playerA.setTeam(1);
  2302. _playerB.setDuelState(DuelState.DUELLING);
  2303. - _playerB.setTeam(TeamType.RED);
  2304. + _playerB.setTeam(2);
  2305.  
  2306. // Send duel Start packets.
  2307. ExDuelReady ready = new ExDuelReady(false);
  2308. @@ -414,7 +413,7 @@
  2309. for (Player partyPlayer : _playerA.getParty().getMembers())
  2310. {
  2311. partyPlayer.setInDuel(0);
  2312. - partyPlayer.setTeam(TeamType.NONE);
  2313. + partyPlayer.setTeam(0);
  2314. partyPlayer.broadcastUserInfo();
  2315.  
  2316. final Summon summon = partyPlayer.getSummon();
  2317. @@ -425,7 +424,7 @@
  2318. for (Player partyPlayer : _playerB.getParty().getMembers())
  2319. {
  2320. partyPlayer.setInDuel(0);
  2321. - partyPlayer.setTeam(TeamType.NONE);
  2322. + partyPlayer.setTeam(0);
  2323. partyPlayer.broadcastUserInfo();
  2324.  
  2325. final Summon summon = partyPlayer.getSummon();
  2326. @@ -436,7 +435,7 @@
  2327. else
  2328. {
  2329. _playerA.setInDuel(0);
  2330. - _playerA.setTeam(TeamType.NONE);
  2331. + _playerA.setTeam(0);
  2332. _playerA.broadcastUserInfo();
  2333.  
  2334. Summon summon = _playerA.getSummon();
  2335. @@ -444,7 +443,7 @@
  2336. summon.updateAbnormalEffect();
  2337.  
  2338. _playerB.setInDuel(0);
  2339. - _playerB.setTeam(TeamType.NONE);
  2340. + _playerB.setTeam(0);
  2341. _playerB.broadcastUserInfo();
  2342.  
  2343. summon = _playerB.getSummon();
  2344. diff --git a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  2345. index 1c35a8b..bcaa4fa 100644
  2346. --- a/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  2347. +++ b/java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  2348. @@ -10,6 +10,7 @@
  2349.  
  2350. import net.sf.l2j.Config;
  2351. import net.sf.l2j.gameserver.enums.OlympiadType;
  2352. +import net.sf.l2j.gameserver.events.TvTEvent;
  2353. import net.sf.l2j.gameserver.model.World;
  2354. import net.sf.l2j.gameserver.model.actor.Npc;
  2355. import net.sf.l2j.gameserver.model.actor.Player;
  2356. @@ -253,7 +254,11 @@
  2357. player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
  2358. return false;
  2359. }
  2360. -
  2361. + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  2362. + {
  2363. + player.sendMessage("You can not register in olympiad while registered at TvT.");
  2364. + return false;
  2365. + }
  2366. if (player.isSubClassActive())
  2367. {
  2368. player.sendPacket(SystemMessageId.YOU_CANT_JOIN_THE_OLYMPIAD_WITH_A_SUB_JOB_CHARACTER);
  2369. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  2370. index 496642d..4010615 100644
  2371. --- a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  2372. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  2373. @@ -24,6 +24,7 @@
  2374. import net.sf.l2j.gameserver.enums.SiegeSide;
  2375. import net.sf.l2j.gameserver.enums.ZoneId;
  2376. import net.sf.l2j.gameserver.enums.actors.ClassRace;
  2377. +import net.sf.l2j.gameserver.events.TvTEvent;
  2378. import net.sf.l2j.gameserver.model.World;
  2379. import net.sf.l2j.gameserver.model.actor.Player;
  2380. import net.sf.l2j.gameserver.model.clanhall.ClanHall;
  2381. @@ -233,7 +234,7 @@
  2382. player.sendPacket(SystemMessageId.WELCOME_TO_LINEAGE);
  2383. player.sendPacket(SevenSignsManager.getInstance().getCurrentPeriod().getMessageId());
  2384. AnnouncementData.getInstance().showAnnouncements(player, false);
  2385. -
  2386. + TvTEvent.onLogin(player, player);
  2387. if(Config.PCB_ENABLE)
  2388. {
  2389. player.showPcBangWindow();
  2390. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java b/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  2391. index 7a65c66..7394077 100644
  2392. --- a/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  2393. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  2394. @@ -2,6 +2,7 @@
  2395.  
  2396. import net.sf.l2j.gameserver.data.manager.FestivalOfDarknessManager;
  2397. import net.sf.l2j.gameserver.enums.ZoneId;
  2398. +import net.sf.l2j.gameserver.events.TvTEvent;
  2399. import net.sf.l2j.gameserver.model.actor.Player;
  2400. import net.sf.l2j.gameserver.network.SystemMessageId;
  2401. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  2402. @@ -33,7 +34,11 @@
  2403. player.sendPacket(ActionFailed.STATIC_PACKET);
  2404. return;
  2405. }
  2406. -
  2407. + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  2408. + {
  2409. + player.sendMessage("You can not leave the game while attending an event.");
  2410. + return;
  2411. + }
  2412. if (AttackStanceTaskManager.getInstance().isInAttackStance(player))
  2413. {
  2414. player.sendPacket(SystemMessageId.CANT_LOGOUT_WHILE_FIGHTING);
  2415. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  2416. index 0a071c9..a8a7b2b 100644
  2417. --- a/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  2418. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  2419. @@ -2,6 +2,7 @@
  2420.  
  2421. import net.sf.l2j.gameserver.data.manager.FestivalOfDarknessManager;
  2422. import net.sf.l2j.gameserver.enums.ZoneId;
  2423. +import net.sf.l2j.gameserver.events.TvTEvent;
  2424. import net.sf.l2j.gameserver.model.actor.Player;
  2425. import net.sf.l2j.gameserver.network.GameClient;
  2426. import net.sf.l2j.gameserver.network.GameClient.GameClientState;
  2427. @@ -29,7 +30,12 @@
  2428. sendPacket(RestartResponse.valueOf(false));
  2429. return;
  2430. }
  2431. -
  2432. + if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  2433. + {
  2434. + player.sendMessage("You can not restart when you registering in TvTEvent.");
  2435. + sendPacket(RestartResponse.valueOf(false));
  2436. + return;
  2437. + }
  2438. if (player.isInsideZone(ZoneId.NO_RESTART))
  2439. {
  2440. player.sendPacket(SystemMessageId.NO_RESTART_HERE);
  2441. diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
  2442. index 80dba69..53e9f6a 100644
  2443. --- a/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
  2444. +++ b/java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
  2445. @@ -259,7 +259,7 @@
  2446. writeD(_allyCrest);
  2447.  
  2448. writeC(_summon.getMove().getMoveType().getId());
  2449. - writeC(_summon.getTeam().getId());
  2450. + writeC(_summon.getTeam());
  2451.  
  2452. writeF(_collisionRadius);
  2453. writeF(_collisionHeight);
  2454. diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
  2455. index f83da89..c56bb3d 100644
  2456. --- a/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
  2457. +++ b/java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
  2458. @@ -3,7 +3,6 @@
  2459. import net.sf.l2j.Config;
  2460. import net.sf.l2j.gameserver.data.manager.CursedWeaponManager;
  2461. import net.sf.l2j.gameserver.enums.Paperdoll;
  2462. -import net.sf.l2j.gameserver.enums.TeamType;
  2463. import net.sf.l2j.gameserver.enums.skills.AbnormalEffect;
  2464. import net.sf.l2j.gameserver.model.actor.Player;
  2465. import net.sf.l2j.gameserver.model.actor.Summon;
  2466. @@ -146,7 +145,12 @@
  2467. writeD(_player.getStatus().getMaxCp());
  2468. writeD((int) _player.getStatus().getCp());
  2469. writeC((_player.isMounted()) ? 0 : _player.getEnchantEffect());
  2470. - writeC((Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()) ? TeamType.BLUE.getId() : _player.getTeam().getId());
  2471. + if (_player.getTeam() == 1 || (Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()))
  2472. + writeC(0x01); // team circle around feet 1= Blue, 2 = red
  2473. + else if (_player.getTeam() == 2)
  2474. + writeC(0x02); // team circle around feet 1= Blue, 2 = red
  2475. + else
  2476. + writeC(0x00); // team circle around feet 1= Blue, 2 = red
  2477. writeD(_player.getClanCrestLargeId());
  2478. writeC((_player.isNoble()) ? 1 : 0);
  2479. writeC((_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA)) ? 1 : 0);
  2480. diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java b/java/net/sf/l2j/gameserver/network/serverpackets/Die.java
  2481. index 50e57f0..4fe2f40 100644
  2482. --- a/java/net/sf/l2j/gameserver/network/serverpackets/Die.java
  2483. +++ b/java/net/sf/l2j/gameserver/network/serverpackets/Die.java
  2484. @@ -17,6 +17,7 @@
  2485. private boolean _sweepable;
  2486. private boolean _allowFixedRes;
  2487. private Clan _clan;
  2488. + private boolean _funEvent;
  2489.  
  2490. public Die(Creature creature)
  2491. {
  2492. @@ -29,6 +30,7 @@
  2493. Player player = (Player) creature;
  2494. _allowFixedRes = player.getAccessLevel().allowFixedRes();
  2495. _clan = player.getClan();
  2496. + _funEvent = !player.isInFunEvent();
  2497.  
  2498. }
  2499. else if (creature instanceof Monster)
  2500. @@ -43,9 +45,9 @@
  2501.  
  2502. writeC(0x06);
  2503. writeD(_objectId);
  2504. - writeD(0x01); // to nearest village
  2505. + writeD(_funEvent ? 0x01 : 0); // to nearest village
  2506.  
  2507. - if (_clan != null)
  2508. + if (_funEvent && _clan != null)
  2509. {
  2510. SiegeSide side = null;
  2511.  
  2512. diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java
  2513. index 2b80637..4e5f4d9 100644
  2514. --- a/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java
  2515. +++ b/java/net/sf/l2j/gameserver/network/serverpackets/PetInfo.java
  2516. @@ -109,7 +109,7 @@
  2517. writeC(_summon.getMove().getMoveType().getId());
  2518.  
  2519. writeH(0); // ??
  2520. - writeC(_summon.getTeam().getId());
  2521. + writeC(_summon.getOwner() != null ? _summon.getOwner().getTeam() : 0); // team aura (1 = blue, 2 = red)
  2522. writeD(_summon.getSoulShotsPerHit());
  2523. writeD(_summon.getSpiritShotsPerHit());
  2524. }
  2525. diff --git a/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java b/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
  2526. index bb1ce74..492f8b5 100644
  2527. --- a/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
  2528. +++ b/java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
  2529. @@ -3,7 +3,6 @@
  2530. import net.sf.l2j.Config;
  2531. import net.sf.l2j.gameserver.data.manager.CursedWeaponManager;
  2532. import net.sf.l2j.gameserver.enums.Paperdoll;
  2533. -import net.sf.l2j.gameserver.enums.TeamType;
  2534. import net.sf.l2j.gameserver.enums.skills.AbnormalEffect;
  2535. import net.sf.l2j.gameserver.model.actor.Player;
  2536. import net.sf.l2j.gameserver.model.actor.Summon;
  2537. @@ -201,7 +200,12 @@
  2538. writeD(_player.getStatus().getMaxCp());
  2539. writeD((int) _player.getStatus().getCp());
  2540. writeC((_player.isMounted()) ? 0 : _player.getEnchantEffect());
  2541. - writeC((Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()) ? TeamType.BLUE.getId() : _player.getTeam().getId());
  2542. + if (_player.getTeam() == 1 || (Config.PLAYER_SPAWN_PROTECTION > 0 && _player.isSpawnProtected()))
  2543. + writeC(0x01); // team circle around feet 1= Blue, 2 = red
  2544. + else if (_player.getTeam() == 2)
  2545. + writeC(0x02); // team circle around feet 1= Blue, 2 = red
  2546. + else
  2547. + writeC(0x00); // team circle around feet 1= Blue, 2 = red
  2548. writeD(_player.getClanCrestLargeId());
  2549. writeC((_player.isNoble()) ? 1 : 0);
  2550. writeC((_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA)) ? 1 : 0);
  2551. diff --git a/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java b/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
  2552. index 6c0657e..8d6e073 100644
  2553. --- a/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
  2554. +++ b/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
  2555. @@ -39,7 +39,7 @@
  2556. if (activeChar instanceof Player)
  2557. {
  2558. // Check invalid states.
  2559. - if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
  2560. + if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS) || ((Player) activeChar).isInFunEvent())
  2561. return;
  2562. }
  2563.  
  2564. net.sf.l2j.gameserver.data.xml/ItemData.java
  2565.  
  2566. + /**
  2567. + * Dummy item is created by setting the ID of the object in the world at null value
  2568. + * @param itemId : int designating the item
  2569. + * @return ItemInstance designating the dummy item created
  2570. + */
  2571. + public ItemInstance createDummyItem(int itemId)
  2572. + {
  2573. + final Item item = getTemplate(itemId);
  2574. + if (item == null)
  2575. + return null;
  2576. +
  2577. + return new ItemInstance(0, item);
  2578. + }
  2579. /**
  2580. * @param id : the item id to check.
  2581. * @return the {@link Item} corresponding to the item id.
  2582. */
  2583. public Item getTemplate(int id)
  2584. {
  2585. return (id >= _templates.length) ? null : _templates[id];
  2586. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement