Advertisement
Sarada-L2

Boss Event Adpt Acis 398 Yo: Sarada

May 19th, 2021
1,540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.91 KB | None | 0 0
  1. diff --git a/config/CustomMods/Events/BossEvent.ini b/config/CustomMods/Events/BossEvent.ini
  2. new file mode 100644
  3. index 0000000..cc4a763
  4. --- /dev/null
  5. +++ b/config/CustomMods/Events/BossEvent.ini
  6. @@ -0,0 +1,42 @@
  7. +# ================================================
  8. +# BossEvent #
  9. +# ================================================
  10. +#General
  11. +# Event Hour
  12. +EventTime = 20:55,00:00
  13. +# List of bosses randomly selected
  14. +# e.g 29046;29029
  15. +BossList = 29046
  16. +# Id of registration NPC
  17. +RegisterNpcID = 10003
  18. +# Npc location
  19. +RegisterNpcLocation = 82727,148605,-3471
  20. +# List of locations randomly selected
  21. +# e.g 10468,-24569,-3645;174229,-88032,-5116
  22. +LocationsList = 174229,-88032,-5116
  23. +# Min players to start event
  24. +MinPlayers = 1
  25. +# Min damage to boss to receive rewards
  26. +MinDamage = 2000
  27. +# if true countdown will be shown on screen
  28. +EventTimeOnScreen = True
  29. +
  30. +# Timing
  31. +# reg time in seconds
  32. +RegistrationTime = 30
  33. +# Wait time in seconds
  34. +WaitTime = 15
  35. +# Teleport time in seconds
  36. +TeleportTime = 10
  37. +# time to despawn boss
  38. +TimeToDespawnBoss = 300
  39. +
  40. +# Rewards
  41. +# Rewards for players who hitted min damage on boss
  42. +GeneralRewards = 57,100000;3470,10
  43. +# Reward last hit player
  44. +RewardLastAttacker = True
  45. +LastAttackerRewards = 3470,5;3470,5
  46. +# Reward Player with bigger dmg
  47. +RewardMainDamageDealer = True
  48. +MainDamageDealerRewards = 3470,5;3470,5
  49. \ No newline at end of file
  50. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  51. index 9a2f099..c1b9fa7 100644
  52. --- a/java/net/sf/l2j/Config.java
  53. +++ b/java/net/sf/l2j/Config.java
  54. @@ -19,6 +19,7 @@
  55. import net.sf.l2j.gameserver.data.manager.RewardHolder;
  56. import net.sf.l2j.gameserver.enums.GeoType;
  57. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  58. +import net.sf.l2j.gameserver.model.location.Location;
  59.  
  60. /**
  61. * This class contains global server configuration.<br>
  62. @@ -49,6 +50,7 @@
  63. public static final String PCBANGEVENT = "./config/CustomMods/Events/PcBangEvent.ini";
  64. public static final String PARTYFARMEVENT = "./config/CustomMods/Events/PartyFarmEvent.ini";
  65. public static final String TVTEVENT = "./config/CustomMods/Events/TvT.ini";
  66. + public static final String BOSS_EVENT_INSTANCED = "./config/CustomMods/Events/BossEvent.ini";
  67. // --------------------------------------------------
  68. // Clans settings
  69. // --------------------------------------------------
  70. @@ -391,7 +393,26 @@
  71. public static boolean SHOW_NPC_LVL;
  72. public static boolean SHOW_NPC_CREST;
  73. public static boolean SHOW_SUMMON_CREST;
  74. -
  75. + /** Boss Event */
  76. + public static boolean BOSS_EVENT_TIME_ON_SCREEN;
  77. + public static int BOSS_EVENT_TIME_TO_DESPAWN_BOSS;
  78. + public static int BOSS_EVENT_REGISTRATION_NPC_ID;
  79. + public static Map<Integer, Integer> BOSS_EVENT_GENERAL_REWARDS = new HashMap<>();
  80. + public static Map<Integer, Integer> BOSS_EVENT_LAST_ATTACKER_REWARDS = new HashMap<>();
  81. + public static Map<Integer, Integer> BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS = new HashMap<>();
  82. + public static boolean BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER;
  83. + public static boolean BOSS_EVENT_REWARD_LAST_ATTACKER;
  84. + public static List<Location> BOSS_EVENT_LOCATION = new ArrayList<>();
  85. + public static int BOSS_EVENT_REWARD_ID;
  86. + public static int BOSS_EVENT_REWARD_COUNT;
  87. + public static int BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD;
  88. + public static List<Integer> BOSS_EVENT_ID = new ArrayList<>();
  89. + public static Location BOSS_EVENT_NPC_REGISTER_LOC;
  90. + public static int BOSS_EVENT_TIME_TO_WAIT;
  91. + public static int BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS;
  92. + public static int BOSS_EVENT_MIN_PLAYERS;
  93. + public static int BOSS_EVENT_REGISTRATION_TIME;
  94. + public static String[] BOSS_EVENT_BY_TIME_OF_DAY;
  95. /** Wyvern Manager */
  96. public static boolean WYVERN_ALLOW_UPGRADER;
  97. public static int WYVERN_REQUIRED_LEVEL;
  98. @@ -1372,6 +1393,55 @@
  99. VIP_DAYS_ID3 = Integer.parseInt(Donate.getProperty("VipCoinDays3", "3"));
  100. }
  101.  
  102. + private static final void loadBossEvent()
  103. + {
  104. + final ExProperties bossEvent = initProperties(BOSS_EVENT_INSTANCED);
  105. + BOSS_EVENT_BY_TIME_OF_DAY = bossEvent.getProperty("EventTime", "20:00").split(",");
  106. + for (String bossList : bossEvent.getProperty("BossList", "29046;29029").split(";"))
  107. + {
  108. + BOSS_EVENT_ID.add(Integer.parseInt(bossList));
  109. + }
  110. + bossEvent.getProperty("EventLocation", "174229,-88032,-5116").split(",");
  111. + for (String locationsList : bossEvent.getProperty("LocationsList", "10468,-24569,-3645;174229,-88032,-5116").split(";"))
  112. + {
  113. + String[] coords = locationsList.split(",");
  114. + int x = Integer.parseInt(coords[0]);
  115. + int y = Integer.parseInt(coords[1]);
  116. + int z = Integer.parseInt(coords[2]);
  117. + BOSS_EVENT_LOCATION.add(new Location(x, y, z));
  118. + }
  119. +
  120. + BOSS_EVENT_MIN_PLAYERS = Integer.parseInt(bossEvent.getProperty("MinPlayers", "1"));
  121. + BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD = Integer.parseInt(bossEvent.getProperty("MinDamage", "2000"));
  122. + BOSS_EVENT_REGISTRATION_TIME = Integer.parseInt(bossEvent.getProperty("RegistrationTime", "120"));
  123. + BOSS_EVENT_REWARD_ID = Integer.parseInt(bossEvent.getProperty("RewardId", "3470"));
  124. + BOSS_EVENT_REWARD_COUNT = Integer.parseInt(bossEvent.getProperty("RewardCount", "10"));
  125. + BOSS_EVENT_TIME_TO_WAIT = Integer.parseInt(bossEvent.getProperty("WaitTime", "30"));
  126. + BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS = Integer.parseInt(bossEvent.getProperty("TeleportTime", "15"));
  127. + BOSS_EVENT_REWARD_LAST_ATTACKER = Boolean.parseBoolean(bossEvent.getProperty("RewardLastAttacker", "true"));
  128. + BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER = Boolean.parseBoolean(bossEvent.getProperty("RewardMainDamageDealer", "true"));
  129. + for (String rewards : bossEvent.getProperty("GeneralRewards", "57,100000;3470,10").split(";"))
  130. + {
  131. + String[] reward = rewards.split(",");
  132. + BOSS_EVENT_GENERAL_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
  133. + }
  134. + for (String rewards : bossEvent.getProperty("MainDamageDealerRewards", "57,100000;3470,10").split(";"))
  135. + {
  136. + String[] reward = rewards.split(",");
  137. + BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
  138. + }
  139. + for (String rewards : bossEvent.getProperty("LastAttackerRewards", "57,100000;3470,10").split(";"))
  140. + {
  141. + String[] reward = rewards.split(",");
  142. + BOSS_EVENT_LAST_ATTACKER_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
  143. + }
  144. + BOSS_EVENT_REGISTRATION_NPC_ID = Integer.parseInt(bossEvent.getProperty("RegisterNpcID", "10003"));
  145. + BOSS_EVENT_TIME_TO_DESPAWN_BOSS = Integer.parseInt(bossEvent.getProperty("TimeToDespawnBoss", "300"));
  146. + String[] regLoc = bossEvent.getProperty("RegisterNpcLocation", "82727,148605,-3471").split(",");
  147. + BOSS_EVENT_NPC_REGISTER_LOC = new Location(Integer.parseInt(regLoc[0]), Integer.parseInt(regLoc[1]), Integer.parseInt(regLoc[2]));
  148. + BOSS_EVENT_TIME_ON_SCREEN = Boolean.parseBoolean(bossEvent.getProperty("EventTimeOnScreen", "true"));
  149. + }
  150. +
  151. private static final void loadFlag()
  152. {
  153. final ExProperties flagzone = initProperties(FLAGZONEMOD);
  154. @@ -2015,7 +2085,7 @@
  155. loadTvTConfig();
  156. // siege settings
  157. loadSieges();
  158. -
  159. + loadBossEvent();
  160. // OffShop settings
  161. loadOff();
  162. ProtectionMods();
  163. diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
  164. index 000e3d6..3cfc5b7 100644
  165. --- a/java/net/sf/l2j/gameserver/GameServer.java
  166. +++ b/java/net/sf/l2j/gameserver/GameServer.java
  167. @@ -21,6 +21,7 @@
  168. import net.sf.l2j.gameserver.data.cache.CrestCache;
  169. import net.sf.l2j.gameserver.data.cache.HtmCache;
  170. import net.sf.l2j.gameserver.data.manager.BoatManager;
  171. +import net.sf.l2j.gameserver.data.manager.BossEvent;
  172. import net.sf.l2j.gameserver.data.manager.BufferManager;
  173. import net.sf.l2j.gameserver.data.manager.BuyListManager;
  174. import net.sf.l2j.gameserver.data.manager.CastleManager;
  175. @@ -271,6 +272,7 @@
  176. StringUtil.printSection("Seven Signs");
  177. SevenSignsManager.getInstance().spawnSevenSignsNPC();
  178. FestivalOfDarknessManager.getInstance();
  179. + BossEvent.getInstance();
  180.  
  181. StringUtil.printSection("Manor Manager");
  182. CastleManorManager.getInstance();
  183. diff --git a/java/net/sf/l2j/gameserver/data/manager/BossEvent.java b/java/net/sf/l2j/gameserver/data/manager/BossEvent.java
  184. new file mode 100644
  185. index 0000000..949bc78
  186. --- /dev/null
  187. +++ b/java/net/sf/l2j/gameserver/data/manager/BossEvent.java
  188. @@ -0,0 +1,637 @@
  189. +package net.sf.l2j.gameserver.data.manager;
  190. +
  191. +import java.util.ArrayList;
  192. +import java.util.Collection;
  193. +import java.util.HashMap;
  194. +import java.util.List;
  195. +import java.util.Map;
  196. +import java.util.concurrent.ScheduledFuture;
  197. +import java.util.logging.Logger;
  198. +
  199. +import net.sf.l2j.commons.pool.ThreadPool;
  200. +import net.sf.l2j.commons.random.Rnd;
  201. +
  202. +import net.sf.l2j.Config;
  203. +import net.sf.l2j.gameserver.data.sql.SpawnTable;
  204. +import net.sf.l2j.gameserver.data.xml.NpcData;
  205. +import net.sf.l2j.gameserver.enums.SayType;
  206. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  207. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.BossEventCMD;
  208. +import net.sf.l2j.gameserver.model.World;
  209. +import net.sf.l2j.gameserver.model.actor.Player;
  210. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  211. +import net.sf.l2j.gameserver.model.location.Location;
  212. +import net.sf.l2j.gameserver.model.spawn.Spawn;
  213. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  214. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  215. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage.SMPOS;
  216. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  217. +
  218. +/**
  219. + * @author Zaun
  220. + */
  221. +public class BossEvent
  222. +{
  223. + public Spawn bossSpawn;
  224. + public List<Location> locList = new ArrayList<>();
  225. + public Location loc;
  226. + public List<Integer> bossList = new ArrayList<>();
  227. + public int bossId;
  228. + public int objectId;
  229. + public List<Player> eventPlayers = new ArrayList<>();
  230. + protected static final Logger _log = Logger.getLogger(BossEvent.class.getName());
  231. + private EventState state = EventState.INACTIVE;
  232. + public boolean started = false;
  233. + public boolean aborted = false;
  234. + private Player lastAttacker = null;
  235. + private Map<Integer, Integer> generalRewards = new HashMap<>();
  236. + @SuppressWarnings("unused")
  237. + private Map<Integer, Integer> lastAttackerRewards = new HashMap<>();
  238. + private Map<Integer, Integer> mainDamageDealerRewards = new HashMap<>();
  239. + public ScheduledFuture<?> despawnBoss = null;
  240. + public ScheduledFuture<?> countDownTask = null;
  241. + private String bossName = "";
  242. + public boolean bossKilled = false;
  243. + public Spawn eventNpc = null;
  244. + public long startTime;
  245. +
  246. + public enum EventState
  247. + {
  248. + REGISTRATION, TELEPORTING, WAITING, FIGHTING, FINISHING, INACTIVE
  249. + }
  250. +
  251. + public BossEvent()
  252. + {
  253. + VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new BossEventCMD());
  254. + NextBossEvent.getInstance().startCalculationOfNextEventTime();
  255. + _log.info("Boss Event loaded.");
  256. +
  257. + }
  258. +
  259. + public boolean addPlayer(Player player)
  260. + {
  261. + return eventPlayers.add(player);
  262. + }
  263. +
  264. + public boolean removePlayer(Player player)
  265. + {
  266. + return eventPlayers.remove(player);
  267. + }
  268. +
  269. + public boolean isRegistered(Player player)
  270. + {
  271. + return eventPlayers.contains(player);
  272. + }
  273. +
  274. + class Registration implements Runnable
  275. + {
  276. + @Override
  277. + public void run()
  278. + {
  279. + startRegistration();
  280. +
  281. + }
  282. +
  283. + }
  284. +
  285. + public void teleToTown()
  286. + {
  287. + for (Player p : eventPlayers)
  288. + {
  289. + p.teleToLocation(new Location(83374, 148081, -3407));
  290. + }
  291. + setState(EventState.INACTIVE);
  292. + }
  293. +
  294. + public void delay(int delay)
  295. + {
  296. + try
  297. + {
  298. + Thread.sleep(delay);
  299. + }
  300. + catch (InterruptedException e)
  301. + {
  302. + // TODO Auto-generated catch block
  303. + e.printStackTrace();
  304. + }
  305. + }
  306. +
  307. + class Teleporting implements Runnable
  308. + {
  309. + Location teleTo;
  310. + List<Player> toTeleport = new ArrayList<>();
  311. +
  312. + public Teleporting(List<Player> toTeleport, Location teleTo)
  313. + {
  314. + this.teleTo = teleTo;
  315. + this.toTeleport = toTeleport;
  316. + }
  317. +
  318. + @Override
  319. + public void run()
  320. + {
  321. + if (eventPlayers.size() >= Config.BOSS_EVENT_MIN_PLAYERS)
  322. + {
  323. + despawnNpc(eventNpc);
  324. + setState(EventState.TELEPORTING);
  325. + announce("Event Started!", false);
  326. + startCountDown(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS, true);
  327. +
  328. + for (Player p : toTeleport)
  329. + {
  330. + ThreadPool.schedule(new Runnable()
  331. + {
  332. +
  333. + @Override
  334. + public void run()
  335. + {
  336. + p.teleToLocation(teleTo);
  337. +
  338. + }
  339. + }, Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
  340. +
  341. + }
  342. + delay(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
  343. + setState(EventState.WAITING);
  344. + startCountDown(Config.BOSS_EVENT_TIME_TO_WAIT, true);
  345. + ThreadPool.schedule(new Fighting(bossId, teleTo), Config.BOSS_EVENT_TIME_TO_WAIT * 1000);
  346. +
  347. + }
  348. + else
  349. + {
  350. + announce("Event was cancelled due to lack of participation!", false);
  351. + setState(EventState.INACTIVE);
  352. + despawnNpc(eventNpc);
  353. + eventPlayers.clear();
  354. + objectId = 0;
  355. +
  356. + }
  357. +
  358. + }
  359. +
  360. + }
  361. +
  362. + public void reward(Player p, Map<Integer, Integer> rewardType)
  363. + {
  364. +
  365. + for (Map.Entry<Integer, Integer> entry : rewardType.entrySet())
  366. + {
  367. + p.addItem("BossEventReward", entry.getKey(), entry.getValue(), null, true);
  368. + }
  369. +
  370. + }
  371. +
  372. + public void rewardPlayers()
  373. + {
  374. + for (Player p : eventPlayers)
  375. + {
  376. + if (p.getBossEventDamage() > Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD)
  377. + {
  378. + reward(p, generalRewards);
  379. + }
  380. + else
  381. + {
  382. + p.sendPacket(new ExShowScreenMessage("You didn't caused min damage to receive rewards!", 5000));
  383. + p.sendMessage("You didn't caused min damage to receive rewards! Min. Damage: " + Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD + ". Your Damage: " + p.getBossEventDamage());
  384. + }
  385. + }
  386. +
  387. + if (Config.BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER)
  388. + {
  389. + if (getMainDamageDealer() != null)
  390. + {
  391. + reward(getMainDamageDealer(), mainDamageDealerRewards);
  392. + getMainDamageDealer().sendMessage("Congratulations, you was the damage dealer! So you will receive wonderful rewards.");
  393. + }
  394. +
  395. + }
  396. + }
  397. +
  398. + public void finishEvent()
  399. + {
  400. + started = false;
  401. + // if (!AdminBossEvent.manual)
  402. + // {
  403. + NextBossEvent.getInstance().startCalculationOfNextEventTime();
  404. + // }
  405. + // else
  406. + // {
  407. + // AdminBossEvent.manual = false;
  408. + // }
  409. + rewardPlayers();
  410. + if (bossKilled) announce(bossName + " has been defeated!", false);
  411. + if (Config.BOSS_EVENT_REWARD_LAST_ATTACKER)
  412. + {
  413. + if (lastAttacker != null)
  414. + {
  415. + announce("LastAttacker: " + lastAttacker.getName(), false);
  416. + }
  417. + }
  418. +
  419. + if (Config.BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER)
  420. + {
  421. + if (getMainDamageDealer() != null)
  422. + {
  423. + announce("Main Damage Dealer: " + getMainDamageDealer().getName() + ". Total Damage = " + getMainDamageDealer().getBossEventDamage(), false);
  424. + }
  425. + }
  426. + ThreadPool.schedule(new Runnable()
  427. + {
  428. +
  429. + @Override
  430. + public void run()
  431. + {
  432. + teleToTown();
  433. + eventPlayers.clear();
  434. +
  435. + }
  436. + }, Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
  437. +
  438. + setState(EventState.FINISHING);
  439. + startCountDown(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS, true);
  440. + if (despawnBoss != null)
  441. + {
  442. + despawnBoss.cancel(true);
  443. + despawnBoss = null;
  444. + }
  445. + objectId = 0;
  446. +
  447. + }
  448. +
  449. + class Fighting implements Runnable
  450. + {
  451. + int bossId;
  452. + Location spawnLoc;
  453. +
  454. + public Fighting(int bossId, Location spawnLoc)
  455. + {
  456. + this.bossId = bossId;
  457. + this.spawnLoc = spawnLoc;
  458. + }
  459. +
  460. + @Override
  461. + public void run()
  462. + {
  463. + if (spawnNpc(bossId, loc.getX(), loc.getY(), loc.getZ()))
  464. + {
  465. + setState(EventState.FIGHTING);
  466. + if (Config.BOSS_EVENT_TIME_ON_SCREEN)
  467. + {
  468. + startCountDown(Config.BOSS_EVENT_TIME_TO_DESPAWN_BOSS, true);
  469. + }
  470. + despawnBoss = ThreadPool.schedule(new DespawnBossTask(bossSpawn), Config.BOSS_EVENT_TIME_TO_DESPAWN_BOSS * 1000);
  471. + objectId = bossSpawn.getNpc().getObjectId();
  472. + for (Player p : eventPlayers)
  473. + {
  474. + p.sendPacket(new ExShowScreenMessage("Boss " + bossSpawn.getNpc().getName() + " has been spawned. Go and Defeat him!", 5000));
  475. + }
  476. +
  477. + }
  478. +
  479. + }
  480. +
  481. + }
  482. +
  483. + public void despawnNpc(Spawn spawn)
  484. + {
  485. + if (spawn != null)
  486. + {
  487. + spawn.getNpc().deleteMe();
  488. + spawn.setRespawnState(false);
  489. + SpawnTable.getInstance().deleteSpawn(spawn, true);
  490. + }
  491. +
  492. + }
  493. +
  494. + class DespawnBossTask implements Runnable
  495. + {
  496. + Spawn spawn;
  497. +
  498. + public DespawnBossTask(Spawn spawn)
  499. + {
  500. + this.spawn = spawn;
  501. + }
  502. +
  503. + @Override
  504. + public void run()
  505. + {
  506. + if (spawn != null)
  507. + {
  508. + announceScreen("Your time is over " + spawn.getNpc().getName() + " returned to his home!", true);
  509. + announce("Your time is over " + spawn.getNpc().getName() + " returned to his home!", true);
  510. + announce("You will be teleported to town.", true);
  511. + despawnNpc(spawn);
  512. + ThreadPool.schedule(new Runnable()
  513. + {
  514. +
  515. + @Override
  516. + public void run()
  517. + {
  518. + teleToTown();
  519. + eventPlayers.clear();
  520. + setState(EventState.INACTIVE);
  521. + objectId = 0;
  522. +
  523. + }
  524. + }, 10000);
  525. + }
  526. + }
  527. +
  528. + }
  529. +
  530. + public void startRegistration()
  531. + {
  532. + try
  533. + {
  534. + resetPlayersDamage();
  535. + bossKilled = false;
  536. + bossList = Config.BOSS_EVENT_ID;
  537. + bossId = bossList.get(Rnd.get(bossList.size()));
  538. + locList = Config.BOSS_EVENT_LOCATION;
  539. + loc = locList.get(Rnd.get(locList.size()));
  540. + if (NpcData.getInstance().getTemplate(bossId) != null)
  541. + {
  542. + startTime = System.currentTimeMillis() + Config.BOSS_EVENT_REGISTRATION_TIME * 1000;
  543. + eventNpc = spawnEventNpc(Config.BOSS_EVENT_NPC_REGISTER_LOC._x, Config.BOSS_EVENT_NPC_REGISTER_LOC._y, Config.BOSS_EVENT_NPC_REGISTER_LOC._z);
  544. + generalRewards = Config.BOSS_EVENT_GENERAL_REWARDS;
  545. + lastAttackerRewards = Config.BOSS_EVENT_LAST_ATTACKER_REWARDS;
  546. + mainDamageDealerRewards = Config.BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS;
  547. + started = true;
  548. + aborted = false;
  549. + bossName = NpcData.getInstance().getTemplate(bossId).getName();
  550. + setState(EventState.REGISTRATION);
  551. + announce("Registration started!", false);
  552. + announce("Joinable in giran or use command \".bossevent\" to register to event", false);
  553. + startCountDown(Config.BOSS_EVENT_REGISTRATION_TIME, false);
  554. +
  555. + ThreadPool.schedule(new Teleporting(eventPlayers, loc), Config.BOSS_EVENT_REGISTRATION_TIME * 1000);
  556. +
  557. + }
  558. + else
  559. + {
  560. + _log.warning(getClass().getName() + ": cannot be started. Invalid BossId: " + bossList);
  561. + return;
  562. + }
  563. + }
  564. + catch (Exception e)
  565. + {
  566. + _log.warning("[Boss Event]: Couldn't be started");
  567. + e.printStackTrace();
  568. + }
  569. +
  570. + }
  571. +
  572. + public int timeInMillisToStart()
  573. + {
  574. + return (int) (startTime - System.currentTimeMillis()) / 1000;
  575. + }
  576. +
  577. + public void startCountDownEnterWorld(Player player)
  578. + {
  579. + if (getState() == EventState.REGISTRATION)
  580. + {
  581. + ThreadPool.schedule(new Countdown(player, timeInMillisToStart(), getState()), 0);
  582. + }
  583. + }
  584. +
  585. + public boolean spawnNpc(int npcId, int x, int y, int z)
  586. + {
  587. + NpcTemplate tmpl = NpcData.getInstance().getTemplate(npcId);
  588. + try
  589. + {
  590. + bossSpawn = new Spawn(tmpl);
  591. +
  592. + bossSpawn.setLoc(x, y, z, Rnd.get(65535));
  593. + bossSpawn.setRespawnDelay(1);
  594. +
  595. + SpawnTable.getInstance().addSpawn(bossSpawn, false);
  596. +
  597. + bossSpawn.setRespawnState(false);
  598. + bossSpawn.doSpawn(false);
  599. + bossSpawn.getNpc().isAggressive();
  600. + bossSpawn.getNpc().decayMe();
  601. + bossSpawn.getNpc().spawnMe(bossSpawn.getNpc().getX(), bossSpawn.getNpc().getY(), bossSpawn.getNpc().getZ());
  602. + bossSpawn.getNpc().broadcastPacket(new MagicSkillUse(bossSpawn.getNpc(), bossSpawn.getNpc(), 1034, 1, 1, 1));
  603. + return true;
  604. + }
  605. + catch (Exception e)
  606. + {
  607. + e.printStackTrace();
  608. + return false;
  609. + }
  610. + }
  611. +
  612. + public void resetPlayersDamage()
  613. + {
  614. + for (Player p : World.getInstance().getPlayers())
  615. + {
  616. + p.setBossEventDamage(0);
  617. + }
  618. + }
  619. +
  620. + public Spawn spawnEventNpc(int x, int y, int z)
  621. + {
  622. + Spawn spawn = null;
  623. + NpcTemplate tmpl = NpcData.getInstance().getTemplate(Config.BOSS_EVENT_REGISTRATION_NPC_ID);
  624. + try
  625. + {
  626. + spawn = new Spawn(tmpl);
  627. +
  628. + spawn.setLoc(x, y, z, Rnd.get(65535));
  629. + spawn.setRespawnDelay(1);
  630. +
  631. + SpawnTable.getInstance().addSpawn(spawn, false);
  632. +
  633. + spawn.setRespawnState(false);
  634. + spawn.doSpawn(false);
  635. + spawn.getNpc().isAggressive();
  636. + spawn.getNpc().decayMe();
  637. + spawn.getNpc().spawnMe(spawn.getNpc().getX(), spawn.getNpc().getY(), spawn.getNpc().getZ());
  638. + spawn.getNpc().broadcastPacket(new MagicSkillUse(spawn.getNpc(), spawn.getNpc(), 1034, 1, 1, 1));
  639. + return spawn;
  640. + }
  641. + catch (Exception e)
  642. + {
  643. + e.printStackTrace();
  644. + return spawn;
  645. + }
  646. + }
  647. +
  648. + public final Player getMainDamageDealer()
  649. + {
  650. + int dmg = 0;
  651. + Player mainDamageDealer = null;
  652. + for (Player p : eventPlayers)
  653. + {
  654. + if (p.getBossEventDamage() > dmg)
  655. + {
  656. + dmg = p.getBossEventDamage();
  657. + mainDamageDealer = p;
  658. + }
  659. + }
  660. + return mainDamageDealer;
  661. + }
  662. +
  663. + public static BossEvent getInstance()
  664. + {
  665. + return SingleTonHolder._instance;
  666. + }
  667. +
  668. + private static class SingleTonHolder
  669. + {
  670. + protected static final BossEvent _instance = new BossEvent();
  671. + }
  672. +
  673. + public void startCountDown(int time, boolean eventOnly)
  674. + {
  675. + Collection<Player> players = new ArrayList<>();
  676. + players = eventOnly ? eventPlayers : World.getInstance().getPlayers();
  677. + for (Player player : players)
  678. + {
  679. + ThreadPool.schedule(new Countdown(player, time, getState()), 0L);
  680. + }
  681. +
  682. + }
  683. +
  684. + public void announce(String text, boolean eventOnly)
  685. + {
  686. + Collection<Player> players = new ArrayList<>();
  687. + players = eventOnly ? eventPlayers : World.getInstance().getPlayers();
  688. + for (Player player : players)
  689. + {
  690. + player.sendPacket(new CreatureSay(0, SayType.CRITICAL_ANNOUNCE, "[Boss Event]", text));
  691. + }
  692. + }
  693. +
  694. + public void announceScreen(String text, boolean eventOnly)
  695. + {
  696. + Collection<Player> players = new ArrayList<>();
  697. + players = eventOnly ? eventPlayers : World.getInstance().getPlayers();
  698. + for (Player player : players)
  699. + {
  700. + player.sendPacket(new ExShowScreenMessage(text, 4000));
  701. + }
  702. + }
  703. +
  704. + /**
  705. + * @return the state
  706. + */
  707. + public EventState getState()
  708. + {
  709. + return state;
  710. + }
  711. +
  712. + /**
  713. + * @param state the state to set
  714. + */
  715. + public void setState(EventState state)
  716. + {
  717. + this.state = state;
  718. + }
  719. +
  720. + /**
  721. + * @return the lastAttacker
  722. + */
  723. + public Player getLastAttacker()
  724. + {
  725. + return lastAttacker;
  726. + }
  727. +
  728. + /**
  729. + * @param lastAttacker the lastAttacker to set
  730. + */
  731. + public void setLastAttacker(Player lastAttacker)
  732. + {
  733. + this.lastAttacker = lastAttacker;
  734. + }
  735. +
  736. + protected class Countdown implements Runnable
  737. + {
  738. + private final Player _player;
  739. + private final int _time;
  740. + private String text = "";
  741. + EventState evtState;
  742. +
  743. + public Countdown(Player player, int time, EventState evtState)
  744. + {
  745. + _time = time;
  746. + _player = player;
  747. + switch (evtState)
  748. + {
  749. + case REGISTRATION:
  750. + text = "Boss Event registration ends in: ";
  751. + break;
  752. + case TELEPORTING:
  753. + text = "You will be teleported to Boss Event in: ";
  754. + break;
  755. + case WAITING:
  756. + text = "Boss will spawn in: ";
  757. + break;
  758. + case FINISHING:
  759. + text = "You will be teleported to City in: ";
  760. + break;
  761. + }
  762. + this.evtState = evtState;
  763. + }
  764. +
  765. + @Override
  766. + public void run()
  767. + {
  768. + if (getState() == EventState.INACTIVE)
  769. + {
  770. + return;
  771. + }
  772. + if (_player.isOnline())
  773. + {
  774. + switch (evtState)
  775. + {
  776. + case REGISTRATION:
  777. + case TELEPORTING:
  778. + case WAITING:
  779. + case FINISHING:
  780. + switch (_time)
  781. + {
  782. +
  783. + case 60:
  784. + case 120:
  785. + case 180:
  786. + case 240:
  787. + case 300:
  788. + _player.sendPacket(new CreatureSay(0, SayType.CRITICAL_ANNOUNCE, "[Boss Event]", text + _time / 60 + " minute(s)"));
  789. + break;
  790. + case 45:
  791. + case 30:
  792. + case 15:
  793. + case 10:
  794. + case 5:
  795. + case 4:
  796. + case 3:
  797. + case 2:
  798. + case 1:
  799. + _player.sendPacket(new CreatureSay(0, SayType.CRITICAL_ANNOUNCE, "[Boss Event]", text + _time + " second(s)"));
  800. + break;
  801. +
  802. + }
  803. + if (_time > 1)
  804. + {
  805. + ThreadPool.schedule(new Countdown(_player, _time - 1, evtState), 1000L);
  806. + }
  807. + break;
  808. + case FIGHTING:
  809. + int minutes = _time / 60;
  810. + int second = _time % 60;
  811. + String timing = ((minutes < 10) ? ("0" + minutes) : minutes) + ":" + ((second < 10) ? ("0" + second) : second);
  812. +
  813. + _player.sendPacket(new ExShowScreenMessage("Time Left: " + timing, 1100, SMPOS.BOTTOM_RIGHT, true));
  814. + if (_time > 1)
  815. + {
  816. + ThreadPool.schedule(new Countdown(_player, _time - 1, evtState), 1000L);
  817. + }
  818. + break;
  819. + }
  820. +
  821. + }
  822. + }
  823. + }
  824. +
  825. +}
  826. \ No newline at end of file
  827. diff --git a/java/net/sf/l2j/gameserver/data/manager/NextBossEvent.java b/java/net/sf/l2j/gameserver/data/manager/NextBossEvent.java
  828. new file mode 100644
  829. index 0000000..b3ef180
  830. --- /dev/null
  831. +++ b/java/net/sf/l2j/gameserver/data/manager/NextBossEvent.java
  832. @@ -0,0 +1,96 @@
  833. +package net.sf.l2j.gameserver.data.manager;
  834. +
  835. +import java.text.SimpleDateFormat;
  836. +import java.util.Calendar;
  837. +import java.util.concurrent.ScheduledFuture;
  838. +import java.util.logging.Logger;
  839. +
  840. +import net.sf.l2j.commons.pool.ThreadPool;
  841. +
  842. +import net.sf.l2j.Config;
  843. +
  844. +public class NextBossEvent
  845. +{
  846. + private static NextBossEvent _instance = null;
  847. + protected static final Logger _log = Logger.getLogger(NextBossEvent.class.getName());
  848. + private Calendar nextEvent;
  849. + private final SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  850. + public ScheduledFuture<?> task = null;
  851. +
  852. + public static NextBossEvent getInstance()
  853. + {
  854. + if (_instance == null)
  855. + {
  856. + _instance = new NextBossEvent();
  857. + }
  858. + return _instance;
  859. + }
  860. +
  861. + public String getNextTime()
  862. + {
  863. + if (nextEvent.getTime() != null)
  864. + {
  865. + return format.format(nextEvent.getTime());
  866. + }
  867. + return "Erro";
  868. + }
  869. +
  870. + public void startCalculationOfNextEventTime()
  871. + {
  872. + try
  873. + {
  874. + Calendar currentTime = Calendar.getInstance();
  875. + Calendar testStartTime = null;
  876. + long flush2 = 0L;
  877. + long timeL = 0L;
  878. + int count = 0;
  879. + for (String timeOfDay : Config.BOSS_EVENT_BY_TIME_OF_DAY)
  880. + {
  881. + testStartTime = Calendar.getInstance();
  882. + testStartTime.setLenient(true);
  883. + String[] splitTimeOfDay = timeOfDay.split(":");
  884. + testStartTime.set(11, Integer.parseInt(splitTimeOfDay[0]));
  885. + testStartTime.set(12, Integer.parseInt(splitTimeOfDay[1]));
  886. + testStartTime.set(13, 0);
  887. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  888. + {
  889. + testStartTime.add(5, 1);
  890. + }
  891. + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
  892. + if (count == 0)
  893. + {
  894. + flush2 = timeL;
  895. + nextEvent = testStartTime;
  896. + }
  897. + if (timeL < flush2)
  898. + {
  899. + flush2 = timeL;
  900. + nextEvent = testStartTime;
  901. + }
  902. + count++;
  903. + }
  904. + _log.info("[Boss Event]: Next Event Time -> " + nextEvent.getTime().toString());
  905. + ThreadPool.schedule(new StartEventTask(), flush2);
  906. + }
  907. + catch (Exception e)
  908. + {
  909. + System.out.println("[Boss Event]: " + e);
  910. + }
  911. + }
  912. +
  913. + class StartEventTask implements Runnable
  914. + {
  915. + StartEventTask()
  916. + {
  917. + }
  918. +
  919. + @Override
  920. + public void run()
  921. + {
  922. + NextBossEvent._log.info("----------------------------------------------------------------------------");
  923. + NextBossEvent._log.info("[Boss Event]: Event Started.");
  924. + NextBossEvent._log.info("----------------------------------------------------------------------------");
  925. + BossEvent.getInstance().startRegistration();
  926. + }
  927. + }
  928. +}
  929. \ No newline at end of file
  930. diff --git a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  931. index 55c8191..66cf2a3 100644
  932. --- a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  933. +++ b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  934. @@ -26,6 +26,7 @@
  935.  
  936. import net.sf.l2j.Config;
  937. import net.sf.l2j.gameserver.GameServer;
  938. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.BossEventCMD;
  939. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.GainXpSp;
  940. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Shiff_Mod;
  941. import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TvTEventCommand;
  942. @@ -60,6 +61,7 @@
  943. private VoicedCommandHandler()
  944. {
  945. _datatable = new HashMap<>();
  946. + registerVoicedCommandHandler(new BossEventCMD());
  947. registerVoicedCommandHandler(new TvTEventCommand());
  948. registerVoicedCommandHandler(new Shiff_Mod());
  949. if(Config.ENABLE_COMMAND_RAID)
  950. diff --git a/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/BossEventCMD.java b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/BossEventCMD.java
  951. new file mode 100644
  952. index 0000000..5959be2
  953. --- /dev/null
  954. +++ b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/BossEventCMD.java
  955. @@ -0,0 +1,49 @@
  956. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  957. +
  958. +import net.sf.l2j.gameserver.data.manager.BossEvent;
  959. +import net.sf.l2j.gameserver.data.manager.BossEvent.EventState;
  960. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  961. +import net.sf.l2j.gameserver.model.actor.Player;
  962. +
  963. +public class BossEventCMD implements IVoicedCommandHandler
  964. +{
  965. + @Override
  966. + public boolean useVoicedCommand(String command, Player activeChar, String params)
  967. + {
  968. + if (command.startsWith("bossevent"))
  969. + {
  970. + if (BossEvent.getInstance().getState() != EventState.REGISTRATION)
  971. + {
  972. + activeChar.sendMessage("Boss Event is not running!");
  973. + return false;
  974. + }
  975. + if (!BossEvent.getInstance().isRegistered(activeChar))
  976. + {
  977. + if (BossEvent.getInstance().addPlayer(activeChar))
  978. + {
  979. + activeChar.sendMessage("You have been successfully registered in Boss Event!");
  980. + }
  981. +
  982. + }
  983. + else
  984. + {
  985. + if (BossEvent.getInstance().removePlayer(activeChar))
  986. + {
  987. + activeChar.sendMessage("You have been successfully removed of Boss Event!");
  988. + }
  989. + }
  990. + }
  991. + return false;
  992. + }
  993. +
  994. + @Override
  995. + public String[] getVoicedCommandList()
  996. + {
  997. +
  998. + return new String[]
  999. + {
  1000. + "bossevent"
  1001. + };
  1002. + }
  1003. +
  1004. +}
  1005. \ No newline at end of file
  1006. diff --git a/java/net/sf/l2j/gameserver/model/actor/Creature.java b/java/net/sf/l2j/gameserver/model/actor/Creature.java
  1007. index c669703..bf710ee 100644
  1008. --- a/java/net/sf/l2j/gameserver/model/actor/Creature.java
  1009. +++ b/java/net/sf/l2j/gameserver/model/actor/Creature.java
  1010. @@ -10,12 +10,15 @@
  1011. import net.sf.l2j.commons.random.Rnd;
  1012.  
  1013. import net.sf.l2j.Config;
  1014. +import net.sf.l2j.gameserver.data.manager.BossEvent;
  1015. +import net.sf.l2j.gameserver.data.manager.BossEvent.EventState;
  1016. import net.sf.l2j.gameserver.data.manager.BotsPreventionManager;
  1017. import net.sf.l2j.gameserver.data.manager.ZoneManager;
  1018. import net.sf.l2j.gameserver.data.xml.MapRegionData;
  1019. import net.sf.l2j.gameserver.data.xml.MapRegionData.TeleportType;
  1020. import net.sf.l2j.gameserver.data.xml.NpcData;
  1021. import net.sf.l2j.gameserver.enums.AiEventType;
  1022. +import net.sf.l2j.gameserver.enums.SayType;
  1023. import net.sf.l2j.gameserver.enums.StatusType;
  1024. import net.sf.l2j.gameserver.enums.ZoneId;
  1025. import net.sf.l2j.gameserver.enums.actors.MoveType;
  1026. @@ -50,6 +53,7 @@
  1027. import net.sf.l2j.gameserver.network.serverpackets.AbstractNpcInfo.NpcInfo;
  1028. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1029. import net.sf.l2j.gameserver.network.serverpackets.ChangeMoveType;
  1030. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  1031. import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket;
  1032. import net.sf.l2j.gameserver.network.serverpackets.Revive;
  1033. import net.sf.l2j.gameserver.network.serverpackets.ServerObjectInfo;
  1034. @@ -484,6 +488,34 @@
  1035. stopAllEffectsExceptThoseThatLastThroughDeath();
  1036.  
  1037. calculateRewards(killer);
  1038. + if (BossEvent.getInstance().getState() == EventState.FIGHTING)
  1039. + {
  1040. + if (BossEvent.getInstance().bossSpawn.getNpc() == this)
  1041. + {
  1042. + BossEvent.getInstance().finishEvent();
  1043. + BossEvent.getInstance().bossKilled = true;
  1044. + if (killer instanceof Player)
  1045. + {
  1046. + Player lastAttacker = killer.getActingPlayer();
  1047. + BossEvent.getInstance().setLastAttacker(lastAttacker);
  1048. + LOGGER.info("Boss Event Finished. Last Attacker : " + lastAttacker.getName());
  1049. + LOGGER.info("Players rewarded: " + BossEvent.getInstance().eventPlayers.size());
  1050. + if (Config.BOSS_EVENT_REWARD_LAST_ATTACKER)
  1051. + {
  1052. +
  1053. + if (lastAttacker.getBossEventDamage() > Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD)
  1054. + {
  1055. + BossEvent.getInstance().reward(lastAttacker, Config.BOSS_EVENT_LAST_ATTACKER_REWARDS);
  1056. + lastAttacker.sendPacket(new CreatureSay(0, SayType.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the last attacker! So you will receive wonderful rewards."));
  1057. + //lastAttacker.sendChatMessage(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the last attacker! So you will receive wonderful rewards.");
  1058. +
  1059. + }
  1060. +
  1061. + }
  1062. + }
  1063. +
  1064. + }
  1065. + }
  1066. if (Config.BOTS_PREVENTION)
  1067. {
  1068. BotsPreventionManager.getInstance().updatecounter(killer,this);
  1069. diff --git a/java/net/sf/l2j/gameserver/model/actor/Player.java b/java/net/sf/l2j/gameserver/model/actor/Player.java
  1070. index 290b545..ca38b35 100644
  1071. --- a/java/net/sf/l2j/gameserver/model/actor/Player.java
  1072. +++ b/java/net/sf/l2j/gameserver/model/actor/Player.java
  1073. @@ -33,6 +33,8 @@
  1074. import net.sf.l2j.gameserver.communitybbs.model.Forum;
  1075. import net.sf.l2j.gameserver.data.SkillTable;
  1076. import net.sf.l2j.gameserver.data.SkillTable.FrequentSkill;
  1077. +import net.sf.l2j.gameserver.data.manager.BossEvent;
  1078. +import net.sf.l2j.gameserver.data.manager.BossEvent.EventState;
  1079. import net.sf.l2j.gameserver.data.manager.CastleManager;
  1080. import net.sf.l2j.gameserver.data.manager.CoupleManager;
  1081. import net.sf.l2j.gameserver.data.manager.CursedWeaponManager;
  1082. @@ -6968,7 +6970,13 @@
  1083. sendPacket(SystemMessageId.MISSED_TARGET);
  1084. return;
  1085. }
  1086. -
  1087. + if (BossEvent.getInstance().getState() == EventState.FIGHTING && BossEvent.getInstance().eventPlayers.contains(this))
  1088. + {
  1089. + if (target.getObjectId() == BossEvent.getInstance().objectId)
  1090. + {
  1091. + bossEventDamage += damage;
  1092. + }
  1093. + }
  1094. // Check if hit is critical
  1095. if (pcrit)
  1096. sendPacket(SystemMessageId.CRITICAL_HIT);
  1097. @@ -6988,7 +6996,22 @@
  1098. if (isInOlympiadMode() && target instanceof Player && ((Player) target).isInOlympiadMode() && ((Player) target).getOlympiadGameId() == getOlympiadGameId())
  1099. OlympiadGameManager.getInstance().notifyCompetitorDamage(this, damage);
  1100. }
  1101. + private int bossEventDamage = 0;
  1102. + /**
  1103. + * @return the bossEventDamage
  1104. + */
  1105. + public int getBossEventDamage()
  1106. + {
  1107. + return bossEventDamage;
  1108. + }
  1109.  
  1110. + /**
  1111. + * @param bossEventDamage the bossEventDamage to set
  1112. + */
  1113. + public void setBossEventDamage(int bossEventDamage)
  1114. + {
  1115. + this.bossEventDamage = bossEventDamage;
  1116. + }
  1117. public void checkItemRestriction()
  1118. {
  1119. for (final ItemInstance item : getInventory().getPaperdollItems())
  1120. diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/BossEventNpc.java b/java/net/sf/l2j/gameserver/model/actor/instance/BossEventNpc.java
  1121. new file mode 100644
  1122. index 0000000..3e7f1b8
  1123. --- /dev/null
  1124. +++ b/java/net/sf/l2j/gameserver/model/actor/instance/BossEventNpc.java
  1125. @@ -0,0 +1,61 @@
  1126. +package net.sf.l2j.gameserver.model.actor.instance;
  1127. +
  1128. +import net.sf.l2j.gameserver.data.manager.BossEvent;
  1129. +import net.sf.l2j.gameserver.data.manager.BossEvent.EventState;
  1130. +import net.sf.l2j.gameserver.model.actor.Player;
  1131. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  1132. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1133. +
  1134. +public class BossEventNpc extends Folk
  1135. +{
  1136. + /**
  1137. + * @param objectId
  1138. + * @param template
  1139. + */
  1140. + public BossEventNpc(int objectId, NpcTemplate template)
  1141. + {
  1142. + super(objectId, template);
  1143. + }
  1144. +
  1145. + @Override
  1146. + public void showChatWindow(Player player, int val)
  1147. + {
  1148. + NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  1149. + html.setFile("data/html/mods/BossEvent.htm");
  1150. + html.replace("%objectId%", String.valueOf(getObjectId()));
  1151. + html.replace("%npcname%", getName());
  1152. + html.replace("%regCount%", String.valueOf(BossEvent.getInstance().eventPlayers.size()));
  1153. + player.sendPacket(html);
  1154. + }
  1155. +
  1156. + @Override
  1157. + public void onBypassFeedback(Player activeChar, String command)
  1158. + {
  1159. +
  1160. + super.onBypassFeedback(activeChar, command);
  1161. + if (command.startsWith("register"))
  1162. + {
  1163. + if (BossEvent.getInstance().getState() != EventState.REGISTRATION)
  1164. + {
  1165. + activeChar.sendMessage("Boss Event is not running!");
  1166. + return;
  1167. + }
  1168. + if (!BossEvent.getInstance().isRegistered(activeChar))
  1169. + {
  1170. + if (BossEvent.getInstance().addPlayer(activeChar))
  1171. + {
  1172. + activeChar.sendMessage("You have been successfully registered in Boss Event!");
  1173. + }
  1174. +
  1175. + }
  1176. + else
  1177. + {
  1178. + if (BossEvent.getInstance().removePlayer(activeChar))
  1179. + {
  1180. + activeChar.sendMessage("You have been successfully removed of Boss Event!");
  1181. + }
  1182. + }
  1183. + }
  1184. + }
  1185. +
  1186. +}
  1187. \ No newline at end of file
  1188. diff --git a/java/net/sf/l2j/gameserver/model/location/Location.java b/java/net/sf/l2j/gameserver/model/location/Location.java
  1189. index 1ebbe9c..754c007 100644
  1190. --- a/java/net/sf/l2j/gameserver/model/location/Location.java
  1191. +++ b/java/net/sf/l2j/gameserver/model/location/Location.java
  1192. @@ -12,7 +12,7 @@
  1193. {
  1194. public static final Location DUMMY_LOC = new Location(0, 0, 0);
  1195.  
  1196. - protected volatile int _z;
  1197. + public volatile int _z;
  1198.  
  1199. public Location(int x, int y, int z)
  1200. {
  1201. diff --git a/java/net/sf/l2j/gameserver/model/location/Point2D.java b/java/net/sf/l2j/gameserver/model/location/Point2D.java
  1202. index 9e6e470..bc1e3a5 100644
  1203. --- a/java/net/sf/l2j/gameserver/model/location/Point2D.java
  1204. +++ b/java/net/sf/l2j/gameserver/model/location/Point2D.java
  1205. @@ -7,8 +7,8 @@
  1206. */
  1207. public class Point2D
  1208. {
  1209. - protected volatile int _x;
  1210. - protected volatile int _y;
  1211. + public volatile int _x;
  1212. + public volatile int _y;
  1213.  
  1214. public Point2D(int x, int y)
  1215. {
  1216.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement