FourSepulchersManager.java 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.instancemanager;
  16. import java.sql.Connection;
  17. import java.sql.PreparedStatement;
  18. import java.sql.ResultSet;
  19. import java.util.Calendar;
  20. import java.util.List;
  21. import java.util.Set;
  22. import java.util.concurrent.ScheduledFuture;
  23. import java.util.logging.Level;
  24. import java.util.logging.Logger;
  25. import javolution.util.FastList;
  26. import javolution.util.FastMap;
  27. import com.l2jserver.Config;
  28. import com.l2jserver.L2DatabaseFactory;
  29. import com.l2jserver.gameserver.ThreadPoolManager;
  30. import com.l2jserver.gameserver.datatables.DoorTable;
  31. import com.l2jserver.gameserver.datatables.NpcTable;
  32. import com.l2jserver.gameserver.datatables.SpawnTable;
  33. import com.l2jserver.gameserver.model.L2Spawn;
  34. import com.l2jserver.gameserver.model.actor.L2Npc;
  35. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  37. import com.l2jserver.gameserver.model.actor.instance.L2SepulcherMonsterInstance;
  38. import com.l2jserver.gameserver.model.actor.instance.L2SepulcherNpcInstance;
  39. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  40. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  41. import com.l2jserver.gameserver.model.quest.Quest;
  42. import com.l2jserver.gameserver.model.quest.QuestState;
  43. import com.l2jserver.gameserver.network.NpcStringId;
  44. import com.l2jserver.gameserver.network.SystemMessageId;
  45. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  46. import com.l2jserver.gameserver.util.Util;
  47. import com.l2jserver.util.Rnd;
  48. import gnu.trove.map.hash.TIntIntHashMap;
  49. import gnu.trove.map.hash.TIntObjectHashMap;
  50. /**
  51. * Zoey76: TODO: Use Location DTO instead of array of int.
  52. * @author sandman
  53. */
  54. public class FourSepulchersManager
  55. {
  56. protected static final Logger _log = Logger.getLogger(FourSepulchersManager.class.getName());
  57. private static final int QUEST_ID = 620;
  58. private static final int ENTRANCE_PASS = 7075;
  59. private static final int USED_PASS = 7261;
  60. private static final int CHAPEL_KEY = 7260;
  61. private static final int ANTIQUE_BROOCH = 7262;
  62. protected boolean _firstTimeRun;
  63. protected boolean _inEntryTime = false;
  64. protected boolean _inWarmUpTime = false;
  65. protected boolean _inAttackTime = false;
  66. protected boolean _inCoolDownTime = false;
  67. protected ScheduledFuture<?> _changeCoolDownTimeTask = null;
  68. protected ScheduledFuture<?> _changeEntryTimeTask = null;
  69. protected ScheduledFuture<?> _changeWarmUpTimeTask = null;
  70. protected ScheduledFuture<?> _changeAttackTimeTask = null;
  71. protected ScheduledFuture<?> _onPartyAnnihilatedTask = null;
  72. // @formatter:off
  73. private final int[][] _startHallSpawn =
  74. {
  75. { 181632, -85587, -7218 },
  76. { 179963, -88978, -7218 },
  77. { 173217, -86132, -7218 },
  78. { 175608, -82296, -7218 }
  79. };
  80. private final int[][][] _shadowSpawnLoc =
  81. {
  82. {
  83. { 25339, 191231, -85574, -7216, 33380 },
  84. { 25349, 189534, -88969, -7216, 32768 },
  85. { 25346, 173195, -76560, -7215, 49277 },
  86. { 25342, 175591, -72744, -7215, 49317 }
  87. },
  88. {
  89. { 25342, 191231, -85574, -7216, 33380 },
  90. { 25339, 189534, -88969, -7216, 32768 },
  91. { 25349, 173195, -76560, -7215, 49277 },
  92. { 25346, 175591, -72744, -7215, 49317 }
  93. },
  94. {
  95. { 25346, 191231, -85574, -7216, 33380 },
  96. { 25342, 189534, -88969, -7216, 32768 },
  97. { 25339, 173195, -76560, -7215, 49277 },
  98. { 25349, 175591, -72744, -7215, 49317 }
  99. },
  100. {
  101. { 25349, 191231, -85574, -7216, 33380 },
  102. { 25346, 189534, -88969, -7216, 32768 },
  103. { 25342, 173195, -76560, -7215, 49277 },
  104. { 25339, 175591, -72744, -7215, 49317 }
  105. },
  106. };
  107. // @formatter:on
  108. protected FastMap<Integer, Boolean> _archonSpawned = new FastMap<>();
  109. protected FastMap<Integer, Boolean> _hallInUse = new FastMap<>();
  110. protected FastMap<Integer, L2PcInstance> _challengers = new FastMap<>();
  111. protected TIntObjectHashMap<int[]> _startHallSpawns = new TIntObjectHashMap<>();
  112. protected TIntIntHashMap _hallGateKeepers = new TIntIntHashMap();
  113. protected TIntIntHashMap _keyBoxNpc = new TIntIntHashMap();
  114. protected TIntIntHashMap _victim = new TIntIntHashMap();
  115. protected TIntObjectHashMap<L2Spawn> _executionerSpawns = new TIntObjectHashMap<>();
  116. protected TIntObjectHashMap<L2Spawn> _keyBoxSpawns = new TIntObjectHashMap<>();
  117. protected TIntObjectHashMap<L2Spawn> _mysteriousBoxSpawns = new TIntObjectHashMap<>();
  118. protected TIntObjectHashMap<L2Spawn> _shadowSpawns = new TIntObjectHashMap<>();
  119. protected TIntObjectHashMap<FastList<L2Spawn>> _dukeFinalMobs = new TIntObjectHashMap<>();
  120. protected TIntObjectHashMap<FastList<L2SepulcherMonsterInstance>> _dukeMobs = new TIntObjectHashMap<>();
  121. protected TIntObjectHashMap<FastList<L2Spawn>> _emperorsGraveNpcs = new TIntObjectHashMap<>();
  122. protected TIntObjectHashMap<FastList<L2Spawn>> _magicalMonsters = new TIntObjectHashMap<>();
  123. protected TIntObjectHashMap<FastList<L2Spawn>> _physicalMonsters = new TIntObjectHashMap<>();
  124. protected TIntObjectHashMap<FastList<L2SepulcherMonsterInstance>> _viscountMobs = new TIntObjectHashMap<>();
  125. protected FastList<L2Spawn> _physicalSpawns;
  126. protected FastList<L2Spawn> _magicalSpawns;
  127. protected FastList<L2Spawn> _managers;
  128. protected FastList<L2Spawn> _dukeFinalSpawns;
  129. protected FastList<L2Spawn> _emperorsGraveSpawns;
  130. protected FastList<L2Npc> _allMobs = new FastList<>();
  131. protected long _attackTimeEnd = 0;
  132. protected long _coolDownTimeEnd = 0;
  133. protected long _entryTimeEnd = 0;
  134. protected long _warmUpTimeEnd = 0;
  135. protected byte _newCycleMin = 55;
  136. public void init()
  137. {
  138. if (_changeCoolDownTimeTask != null)
  139. {
  140. _changeCoolDownTimeTask.cancel(true);
  141. }
  142. if (_changeEntryTimeTask != null)
  143. {
  144. _changeEntryTimeTask.cancel(true);
  145. }
  146. if (_changeWarmUpTimeTask != null)
  147. {
  148. _changeWarmUpTimeTask.cancel(true);
  149. }
  150. if (_changeAttackTimeTask != null)
  151. {
  152. _changeAttackTimeTask.cancel(true);
  153. }
  154. _changeCoolDownTimeTask = null;
  155. _changeEntryTimeTask = null;
  156. _changeWarmUpTimeTask = null;
  157. _changeAttackTimeTask = null;
  158. _inEntryTime = false;
  159. _inWarmUpTime = false;
  160. _inAttackTime = false;
  161. _inCoolDownTime = false;
  162. _firstTimeRun = true;
  163. initFixedInfo();
  164. loadMysteriousBox();
  165. initKeyBoxSpawns();
  166. loadPhysicalMonsters();
  167. loadMagicalMonsters();
  168. initLocationShadowSpawns();
  169. initExecutionerSpawns();
  170. loadDukeMonsters();
  171. loadEmperorsGraveMonsters();
  172. spawnManagers();
  173. timeSelector();
  174. }
  175. // phase select on server launch
  176. protected void timeSelector()
  177. {
  178. timeCalculator();
  179. long currentTime = Calendar.getInstance().getTimeInMillis();
  180. // if current time >= time of entry beginning and if current time < time
  181. // of entry beginning + time of entry end
  182. if ((currentTime >= _coolDownTimeEnd) && (currentTime < _entryTimeEnd)) // entry
  183. // time
  184. // check
  185. {
  186. clean();
  187. _changeEntryTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeEntryTime(), 0);
  188. _log.info(getClass().getSimpleName() + ": Beginning in Entry time");
  189. }
  190. else if ((currentTime >= _entryTimeEnd) && (currentTime < _warmUpTimeEnd)) // warmup
  191. // time
  192. // check
  193. {
  194. clean();
  195. _changeWarmUpTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeWarmUpTime(), 0);
  196. _log.info(getClass().getSimpleName() + ": Beginning in WarmUp time");
  197. }
  198. else if ((currentTime >= _warmUpTimeEnd) && (currentTime < _attackTimeEnd)) // attack
  199. // time
  200. // check
  201. {
  202. clean();
  203. _changeAttackTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeAttackTime(), 0);
  204. _log.info(getClass().getSimpleName() + ": Beginning in Attack time");
  205. }
  206. else
  207. // else cooldown time and without cleanup because it's already
  208. // implemented
  209. {
  210. _changeCoolDownTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeCoolDownTime(), 0);
  211. _log.info(getClass().getSimpleName() + ": Beginning in Cooldown time");
  212. }
  213. }
  214. // phase end times calculator
  215. protected void timeCalculator()
  216. {
  217. Calendar tmp = Calendar.getInstance();
  218. if (tmp.get(Calendar.MINUTE) < _newCycleMin)
  219. {
  220. tmp.set(Calendar.HOUR, Calendar.getInstance().get(Calendar.HOUR) - 1);
  221. }
  222. tmp.set(Calendar.MINUTE, _newCycleMin);
  223. _coolDownTimeEnd = tmp.getTimeInMillis();
  224. _entryTimeEnd = _coolDownTimeEnd + (Config.FS_TIME_ENTRY * 60000L);
  225. _warmUpTimeEnd = _entryTimeEnd + (Config.FS_TIME_WARMUP * 60000L);
  226. _attackTimeEnd = _warmUpTimeEnd + (Config.FS_TIME_ATTACK * 60000L);
  227. }
  228. public void clean()
  229. {
  230. for (int i = 31921; i < 31925; i++)
  231. {
  232. int[] Location = _startHallSpawns.get(i);
  233. GrandBossManager.getInstance().getZone(Location[0], Location[1], Location[2]).oustAllPlayers();
  234. }
  235. deleteAllMobs();
  236. closeAllDoors();
  237. _hallInUse.clear();
  238. _hallInUse.put(31921, false);
  239. _hallInUse.put(31922, false);
  240. _hallInUse.put(31923, false);
  241. _hallInUse.put(31924, false);
  242. if (_archonSpawned.size() != 0)
  243. {
  244. Set<Integer> npcIdSet = _archonSpawned.keySet();
  245. for (int npcId : npcIdSet)
  246. {
  247. _archonSpawned.put(npcId, false);
  248. }
  249. }
  250. }
  251. protected void spawnManagers()
  252. {
  253. _managers = new FastList<>();
  254. // L2Spawn spawnDat;
  255. int i = 31921;
  256. for (L2Spawn spawnDat; i <= 31924; i++)
  257. {
  258. if ((i < 31921) || (i > 31924))
  259. {
  260. continue;
  261. }
  262. L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(i);
  263. if (template1 == null)
  264. {
  265. continue;
  266. }
  267. try
  268. {
  269. spawnDat = new L2Spawn(template1);
  270. spawnDat.setAmount(1);
  271. spawnDat.setRespawnDelay(60);
  272. switch (i)
  273. {
  274. case 31921: // conquerors
  275. spawnDat.setLocx(181061);
  276. spawnDat.setLocy(-85595);
  277. spawnDat.setLocz(-7200);
  278. spawnDat.setHeading(-32584);
  279. break;
  280. case 31922: // emperors
  281. spawnDat.setLocx(179292);
  282. spawnDat.setLocy(-88981);
  283. spawnDat.setLocz(-7200);
  284. spawnDat.setHeading(-33272);
  285. break;
  286. case 31923: // sages
  287. spawnDat.setLocx(173202);
  288. spawnDat.setLocy(-87004);
  289. spawnDat.setLocz(-7200);
  290. spawnDat.setHeading(-16248);
  291. break;
  292. case 31924: // judges
  293. spawnDat.setLocx(175606);
  294. spawnDat.setLocy(-82853);
  295. spawnDat.setLocz(-7200);
  296. spawnDat.setHeading(-16248);
  297. break;
  298. }
  299. _managers.add(spawnDat);
  300. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  301. spawnDat.doSpawn();
  302. spawnDat.startRespawn();
  303. _log.info(getClass().getSimpleName() + ": spawned " + spawnDat.getTemplate().getName());
  304. }
  305. catch (Exception e)
  306. {
  307. _log.log(Level.WARNING, "Error while spawning managers: " + e.getMessage(), e);
  308. }
  309. }
  310. }
  311. protected void initFixedInfo()
  312. {
  313. _startHallSpawns.put(31921, _startHallSpawn[0]);
  314. _startHallSpawns.put(31922, _startHallSpawn[1]);
  315. _startHallSpawns.put(31923, _startHallSpawn[2]);
  316. _startHallSpawns.put(31924, _startHallSpawn[3]);
  317. _hallInUse.put(31921, false);
  318. _hallInUse.put(31922, false);
  319. _hallInUse.put(31923, false);
  320. _hallInUse.put(31924, false);
  321. _hallGateKeepers.put(31925, 25150012);
  322. _hallGateKeepers.put(31926, 25150013);
  323. _hallGateKeepers.put(31927, 25150014);
  324. _hallGateKeepers.put(31928, 25150015);
  325. _hallGateKeepers.put(31929, 25150016);
  326. _hallGateKeepers.put(31930, 25150002);
  327. _hallGateKeepers.put(31931, 25150003);
  328. _hallGateKeepers.put(31932, 25150004);
  329. _hallGateKeepers.put(31933, 25150005);
  330. _hallGateKeepers.put(31934, 25150006);
  331. _hallGateKeepers.put(31935, 25150032);
  332. _hallGateKeepers.put(31936, 25150033);
  333. _hallGateKeepers.put(31937, 25150034);
  334. _hallGateKeepers.put(31938, 25150035);
  335. _hallGateKeepers.put(31939, 25150036);
  336. _hallGateKeepers.put(31940, 25150022);
  337. _hallGateKeepers.put(31941, 25150023);
  338. _hallGateKeepers.put(31942, 25150024);
  339. _hallGateKeepers.put(31943, 25150025);
  340. _hallGateKeepers.put(31944, 25150026);
  341. _keyBoxNpc.put(18120, 31455);
  342. _keyBoxNpc.put(18121, 31455);
  343. _keyBoxNpc.put(18122, 31455);
  344. _keyBoxNpc.put(18123, 31455);
  345. _keyBoxNpc.put(18124, 31456);
  346. _keyBoxNpc.put(18125, 31456);
  347. _keyBoxNpc.put(18126, 31456);
  348. _keyBoxNpc.put(18127, 31456);
  349. _keyBoxNpc.put(18128, 31457);
  350. _keyBoxNpc.put(18129, 31457);
  351. _keyBoxNpc.put(18130, 31457);
  352. _keyBoxNpc.put(18131, 31457);
  353. _keyBoxNpc.put(18149, 31458);
  354. _keyBoxNpc.put(18150, 31459);
  355. _keyBoxNpc.put(18151, 31459);
  356. _keyBoxNpc.put(18152, 31459);
  357. _keyBoxNpc.put(18153, 31459);
  358. _keyBoxNpc.put(18154, 31460);
  359. _keyBoxNpc.put(18155, 31460);
  360. _keyBoxNpc.put(18156, 31460);
  361. _keyBoxNpc.put(18157, 31460);
  362. _keyBoxNpc.put(18158, 31461);
  363. _keyBoxNpc.put(18159, 31461);
  364. _keyBoxNpc.put(18160, 31461);
  365. _keyBoxNpc.put(18161, 31461);
  366. _keyBoxNpc.put(18162, 31462);
  367. _keyBoxNpc.put(18163, 31462);
  368. _keyBoxNpc.put(18164, 31462);
  369. _keyBoxNpc.put(18165, 31462);
  370. _keyBoxNpc.put(18183, 31463);
  371. _keyBoxNpc.put(18184, 31464);
  372. _keyBoxNpc.put(18212, 31465);
  373. _keyBoxNpc.put(18213, 31465);
  374. _keyBoxNpc.put(18214, 31465);
  375. _keyBoxNpc.put(18215, 31465);
  376. _keyBoxNpc.put(18216, 31466);
  377. _keyBoxNpc.put(18217, 31466);
  378. _keyBoxNpc.put(18218, 31466);
  379. _keyBoxNpc.put(18219, 31466);
  380. _victim.put(18150, 18158);
  381. _victim.put(18151, 18159);
  382. _victim.put(18152, 18160);
  383. _victim.put(18153, 18161);
  384. _victim.put(18154, 18162);
  385. _victim.put(18155, 18163);
  386. _victim.put(18156, 18164);
  387. _victim.put(18157, 18165);
  388. }
  389. private void loadMysteriousBox()
  390. {
  391. _mysteriousBoxSpawns.clear();
  392. try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  393. PreparedStatement ps = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY id"))
  394. {
  395. ps.setInt(1, 0);
  396. try (ResultSet rs = ps.executeQuery())
  397. {
  398. L2Spawn spawnDat;
  399. L2NpcTemplate template1;
  400. while (rs.next())
  401. {
  402. template1 = NpcTable.getInstance().getTemplate(rs.getInt("npc_templateid"));
  403. if (template1 != null)
  404. {
  405. spawnDat = new L2Spawn(template1);
  406. spawnDat.setAmount(rs.getInt("count"));
  407. spawnDat.setLocx(rs.getInt("locx"));
  408. spawnDat.setLocy(rs.getInt("locy"));
  409. spawnDat.setLocz(rs.getInt("locz"));
  410. spawnDat.setHeading(rs.getInt("heading"));
  411. spawnDat.setRespawnDelay(rs.getInt("respawn_delay"));
  412. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  413. int keyNpcId = rs.getInt("key_npc_id");
  414. _mysteriousBoxSpawns.put(keyNpcId, spawnDat);
  415. }
  416. else
  417. {
  418. _log.warning("FourSepulchersManager.LoadMysteriousBox: Data missing in NPC table for ID: " + rs.getInt("npc_templateid") + ".");
  419. }
  420. }
  421. }
  422. _log.info(getClass().getSimpleName() + ": loaded " + _mysteriousBoxSpawns.size() + " Mysterious-Box spawns.");
  423. }
  424. catch (Exception e)
  425. {
  426. // problem with initializing spawn, go to next one
  427. _log.log(Level.WARNING, "FourSepulchersManager.LoadMysteriousBox: Spawn could not be initialized: " + e.getMessage(), e);
  428. }
  429. }
  430. private void initKeyBoxSpawns()
  431. {
  432. L2Spawn spawnDat;
  433. L2NpcTemplate template;
  434. // Zoey76: TODO: Replace iteration over keys with iteration over entries to avoid calling get method inside the loop.
  435. for (int keyNpcId : _keyBoxNpc.keys())
  436. {
  437. try
  438. {
  439. template = NpcTable.getInstance().getTemplate(_keyBoxNpc.get(keyNpcId));
  440. if (template != null)
  441. {
  442. spawnDat = new L2Spawn(template);
  443. spawnDat.setAmount(1);
  444. spawnDat.setLocx(0);
  445. spawnDat.setLocy(0);
  446. spawnDat.setLocz(0);
  447. spawnDat.setHeading(0);
  448. spawnDat.setRespawnDelay(3600);
  449. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  450. _keyBoxSpawns.put(keyNpcId, spawnDat);
  451. }
  452. else
  453. {
  454. _log.warning("FourSepulchersManager.InitKeyBoxSpawns: Data missing in NPC table for ID: " + _keyBoxNpc.get(keyNpcId) + ".");
  455. }
  456. }
  457. catch (Exception e)
  458. {
  459. _log.log(Level.WARNING, "FourSepulchersManager.InitKeyBoxSpawns: Spawn could not be initialized: " + e.getMessage(), e);
  460. }
  461. }
  462. }
  463. private void loadPhysicalMonsters()
  464. {
  465. _physicalMonsters.clear();
  466. int loaded = 0;
  467. try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  468. PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
  469. {
  470. ps1.setInt(1, 1);
  471. try (ResultSet rs1 = ps1.executeQuery();
  472. PreparedStatement ps2 = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist Where key_npc_id = ? and spawntype = ? ORDER BY id"))
  473. {
  474. L2Spawn spawnDat;
  475. L2NpcTemplate template1;
  476. while (rs1.next())
  477. {
  478. int keyNpcId = rs1.getInt("key_npc_id");
  479. ps2.setInt(1, keyNpcId);
  480. ps2.setInt(2, 1);
  481. try (ResultSet rs2 = ps2.executeQuery())
  482. {
  483. _physicalSpawns = new FastList<>();
  484. while (rs2.next())
  485. {
  486. template1 = NpcTable.getInstance().getTemplate(rs2.getInt("npc_templateid"));
  487. if (template1 != null)
  488. {
  489. spawnDat = new L2Spawn(template1);
  490. spawnDat.setAmount(rs2.getInt("count"));
  491. spawnDat.setLocx(rs2.getInt("locx"));
  492. spawnDat.setLocy(rs2.getInt("locy"));
  493. spawnDat.setLocz(rs2.getInt("locz"));
  494. spawnDat.setHeading(rs2.getInt("heading"));
  495. spawnDat.setRespawnDelay(rs2.getInt("respawn_delay"));
  496. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  497. _physicalSpawns.add(spawnDat);
  498. loaded++;
  499. }
  500. else
  501. {
  502. _log.warning("FourSepulchersManager.LoadPhysicalMonsters: Data missing in NPC table for ID: " + rs2.getInt("npc_templateid") + ".");
  503. }
  504. }
  505. }
  506. ps2.clearParameters();
  507. _physicalMonsters.put(keyNpcId, _physicalSpawns);
  508. }
  509. }
  510. _log.info(getClass().getSimpleName() + ": loaded " + loaded + " Physical type monsters spawns.");
  511. }
  512. catch (Exception e)
  513. {
  514. _log.log(Level.WARNING, "FourSepulchersManager.LoadPhysicalMonsters: Spawn could not be initialized: " + e.getMessage(), e);
  515. }
  516. }
  517. private void loadMagicalMonsters()
  518. {
  519. _magicalMonsters.clear();
  520. int loaded = 0;
  521. try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  522. PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
  523. {
  524. ps1.setInt(1, 2);
  525. try (ResultSet rs1 = ps1.executeQuery();
  526. PreparedStatement ps2 = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist WHERE key_npc_id = ? AND spawntype = ? ORDER BY id"))
  527. {
  528. L2Spawn spawnDat;
  529. L2NpcTemplate template1;
  530. while (rs1.next())
  531. {
  532. int keyNpcId = rs1.getInt("key_npc_id");
  533. ps2.setInt(1, keyNpcId);
  534. ps2.setInt(2, 2);
  535. try (ResultSet rset2 = ps2.executeQuery())
  536. {
  537. _magicalSpawns = new FastList<>();
  538. while (rset2.next())
  539. {
  540. template1 = NpcTable.getInstance().getTemplate(rset2.getInt("npc_templateid"));
  541. if (template1 != null)
  542. {
  543. spawnDat = new L2Spawn(template1);
  544. spawnDat.setAmount(rset2.getInt("count"));
  545. spawnDat.setLocx(rset2.getInt("locx"));
  546. spawnDat.setLocy(rset2.getInt("locy"));
  547. spawnDat.setLocz(rset2.getInt("locz"));
  548. spawnDat.setHeading(rset2.getInt("heading"));
  549. spawnDat.setRespawnDelay(rset2.getInt("respawn_delay"));
  550. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  551. _magicalSpawns.add(spawnDat);
  552. loaded++;
  553. }
  554. else
  555. {
  556. _log.warning("FourSepulchersManager.LoadMagicalMonsters: Data missing in NPC table for ID: " + rset2.getInt("npc_templateid") + ".");
  557. }
  558. }
  559. }
  560. ps2.clearParameters();
  561. _magicalMonsters.put(keyNpcId, _magicalSpawns);
  562. }
  563. }
  564. _log.info(getClass().getSimpleName() + ": loaded " + loaded + " Magical type monsters spawns.");
  565. }
  566. catch (Exception e)
  567. {
  568. _log.log(Level.WARNING, "FourSepulchersManager.LoadMagicalMonsters: Spawn could not be initialized: " + e.getMessage(), e);
  569. }
  570. }
  571. private void loadDukeMonsters()
  572. {
  573. _dukeFinalMobs.clear();
  574. _archonSpawned.clear();
  575. int loaded = 0;
  576. try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  577. PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
  578. {
  579. ps1.setInt(1, 5);
  580. try (ResultSet rs1 = ps1.executeQuery();
  581. PreparedStatement ps2 = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist WHERE key_npc_id = ? AND spawntype = ? ORDER BY id"))
  582. {
  583. L2Spawn spawnDat;
  584. L2NpcTemplate template1;
  585. while (rs1.next())
  586. {
  587. int keyNpcId = rs1.getInt("key_npc_id");
  588. ps2.setInt(1, keyNpcId);
  589. ps2.setInt(2, 5);
  590. try (ResultSet rset2 = ps2.executeQuery())
  591. {
  592. ps2.clearParameters();
  593. _dukeFinalSpawns = new FastList<>();
  594. while (rset2.next())
  595. {
  596. template1 = NpcTable.getInstance().getTemplate(rset2.getInt("npc_templateid"));
  597. if (template1 != null)
  598. {
  599. spawnDat = new L2Spawn(template1);
  600. spawnDat.setAmount(rset2.getInt("count"));
  601. spawnDat.setLocx(rset2.getInt("locx"));
  602. spawnDat.setLocy(rset2.getInt("locy"));
  603. spawnDat.setLocz(rset2.getInt("locz"));
  604. spawnDat.setHeading(rset2.getInt("heading"));
  605. spawnDat.setRespawnDelay(rset2.getInt("respawn_delay"));
  606. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  607. _dukeFinalSpawns.add(spawnDat);
  608. loaded++;
  609. }
  610. else
  611. {
  612. _log.warning("FourSepulchersManager.LoadDukeMonsters: Data missing in NPC table for ID: " + rset2.getInt("npc_templateid") + ".");
  613. }
  614. }
  615. }
  616. ps2.clearParameters();
  617. _dukeFinalMobs.put(keyNpcId, _dukeFinalSpawns);
  618. _archonSpawned.put(keyNpcId, false);
  619. }
  620. }
  621. _log.info(getClass().getSimpleName() + ": loaded " + loaded + " Church of duke monsters spawns.");
  622. }
  623. catch (Exception e)
  624. {
  625. _log.log(Level.WARNING, "FourSepulchersManager.LoadDukeMonsters: Spawn could not be initialized: " + e.getMessage(), e);
  626. }
  627. }
  628. private void loadEmperorsGraveMonsters()
  629. {
  630. _emperorsGraveNpcs.clear();
  631. int loaded = 0;
  632. try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  633. PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
  634. {
  635. ps1.setInt(1, 6);
  636. try (ResultSet rs1 = ps1.executeQuery();
  637. PreparedStatement ps2 = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist WHERE key_npc_id = ? and spawntype = ? ORDER BY id"))
  638. {
  639. L2Spawn spawnDat;
  640. L2NpcTemplate template1;
  641. while (rs1.next())
  642. {
  643. int keyNpcId = rs1.getInt("key_npc_id");
  644. ps2.setInt(1, keyNpcId);
  645. ps2.setInt(2, 6);
  646. try (ResultSet rs2 = ps2.executeQuery())
  647. {
  648. _emperorsGraveSpawns = new FastList<>();
  649. while (rs2.next())
  650. {
  651. template1 = NpcTable.getInstance().getTemplate(rs2.getInt("npc_templateid"));
  652. if (template1 != null)
  653. {
  654. spawnDat = new L2Spawn(template1);
  655. spawnDat.setAmount(rs2.getInt("count"));
  656. spawnDat.setLocx(rs2.getInt("locx"));
  657. spawnDat.setLocy(rs2.getInt("locy"));
  658. spawnDat.setLocz(rs2.getInt("locz"));
  659. spawnDat.setHeading(rs2.getInt("heading"));
  660. spawnDat.setRespawnDelay(rs2.getInt("respawn_delay"));
  661. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  662. _emperorsGraveSpawns.add(spawnDat);
  663. loaded++;
  664. }
  665. else
  666. {
  667. _log.warning("FourSepulchersManager.LoadEmperorsGraveMonsters: Data missing in NPC table for ID: " + rs2.getInt("npc_templateid") + ".");
  668. }
  669. }
  670. }
  671. ps2.clearParameters();
  672. _emperorsGraveNpcs.put(keyNpcId, _emperorsGraveSpawns);
  673. }
  674. }
  675. _log.info(getClass().getSimpleName() + ": loaded " + loaded + " Emperor's grave NPC spawns.");
  676. }
  677. catch (Exception e)
  678. {
  679. _log.log(Level.WARNING, "FourSepulchersManager.LoadEmperorsGraveMonsters: Spawn could not be initialized: " + e.getMessage(), e);
  680. }
  681. }
  682. protected void initLocationShadowSpawns()
  683. {
  684. int locNo = Rnd.get(4);
  685. final int[] gateKeeper =
  686. {
  687. 31929,
  688. 31934,
  689. 31939,
  690. 31944
  691. };
  692. L2Spawn spawnDat;
  693. L2NpcTemplate template;
  694. _shadowSpawns.clear();
  695. for (int i = 0; i <= 3; i++)
  696. {
  697. template = NpcTable.getInstance().getTemplate(_shadowSpawnLoc[locNo][i][0]);
  698. if (template != null)
  699. {
  700. try
  701. {
  702. spawnDat = new L2Spawn(template);
  703. spawnDat.setAmount(1);
  704. spawnDat.setLocx(_shadowSpawnLoc[locNo][i][1]);
  705. spawnDat.setLocy(_shadowSpawnLoc[locNo][i][2]);
  706. spawnDat.setLocz(_shadowSpawnLoc[locNo][i][3]);
  707. spawnDat.setHeading(_shadowSpawnLoc[locNo][i][4]);
  708. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  709. int keyNpcId = gateKeeper[i];
  710. _shadowSpawns.put(keyNpcId, spawnDat);
  711. }
  712. catch (Exception e)
  713. {
  714. _log.log(Level.SEVERE, "Error on InitLocationShadowSpawns", e);
  715. }
  716. }
  717. else
  718. {
  719. _log.warning("FourSepulchersManager.InitLocationShadowSpawns: Data missing in NPC table for ID: " + _shadowSpawnLoc[locNo][i][0] + ".");
  720. }
  721. }
  722. }
  723. protected void initExecutionerSpawns()
  724. {
  725. L2Spawn spawnDat;
  726. L2NpcTemplate template;
  727. for (int keyNpcId : _victim.keys())
  728. {
  729. try
  730. {
  731. template = NpcTable.getInstance().getTemplate(_victim.get(keyNpcId));
  732. if (template != null)
  733. {
  734. spawnDat = new L2Spawn(template);
  735. spawnDat.setAmount(1);
  736. spawnDat.setLocx(0);
  737. spawnDat.setLocy(0);
  738. spawnDat.setLocz(0);
  739. spawnDat.setHeading(0);
  740. spawnDat.setRespawnDelay(3600);
  741. SpawnTable.getInstance().addNewSpawn(spawnDat, false);
  742. _executionerSpawns.put(keyNpcId, spawnDat);
  743. }
  744. else
  745. {
  746. _log.warning("FourSepulchersManager.InitExecutionerSpawns: Data missing in NPC table for ID: " + _victim.get(keyNpcId) + ".");
  747. }
  748. }
  749. catch (Exception e)
  750. {
  751. _log.log(Level.WARNING, "FourSepulchersManager.InitExecutionerSpawns: Spawn could not be initialized: " + e.getMessage(), e);
  752. }
  753. }
  754. }
  755. public boolean isEntryTime()
  756. {
  757. return _inEntryTime;
  758. }
  759. public boolean isAttackTime()
  760. {
  761. return _inAttackTime;
  762. }
  763. public synchronized void tryEntry(L2Npc npc, L2PcInstance player)
  764. {
  765. Quest hostQuest = QuestManager.getInstance().getQuest(QUEST_ID);
  766. if (hostQuest == null)
  767. {
  768. _log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't find quest: " + QUEST_ID);
  769. return;
  770. }
  771. int npcId = npc.getNpcId();
  772. switch (npcId)
  773. {
  774. // ID ok
  775. case 31921:
  776. case 31922:
  777. case 31923:
  778. case 31924:
  779. break;
  780. // ID not ok
  781. default:
  782. if (!player.isGM())
  783. {
  784. _log.warning("Player " + player.getName() + "(" + player.getObjectId() + ") tried to cheat in four sepulchers.");
  785. Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " tried to enter four sepulchers with invalid npc id.", Config.DEFAULT_PUNISH);
  786. }
  787. return;
  788. }
  789. if (_hallInUse.get(npcId).booleanValue())
  790. {
  791. showHtmlFile(player, npcId + "-FULL.htm", npc, null);
  792. return;
  793. }
  794. if (Config.FS_PARTY_MEMBER_COUNT > 1)
  795. {
  796. if (!player.isInParty() || (player.getParty().getMemberCount() < Config.FS_PARTY_MEMBER_COUNT))
  797. {
  798. showHtmlFile(player, npcId + "-SP.htm", npc, null);
  799. return;
  800. }
  801. if (!player.getParty().isLeader(player))
  802. {
  803. showHtmlFile(player, npcId + "-NL.htm", npc, null);
  804. return;
  805. }
  806. for (L2PcInstance mem : player.getParty().getMembers())
  807. {
  808. QuestState qs = mem.getQuestState(hostQuest.getName());
  809. if ((qs == null) || (!qs.isStarted() && !qs.isCompleted()))
  810. {
  811. showHtmlFile(player, npcId + "-NS.htm", npc, mem);
  812. return;
  813. }
  814. if (mem.getInventory().getItemByItemId(ENTRANCE_PASS) == null)
  815. {
  816. showHtmlFile(player, npcId + "-SE.htm", npc, mem);
  817. return;
  818. }
  819. if (player.getWeightPenalty() >= 3)
  820. {
  821. mem.sendPacket(SystemMessageId.INVENTORY_LESS_THAN_80_PERCENT);
  822. return;
  823. }
  824. }
  825. }
  826. else if ((Config.FS_PARTY_MEMBER_COUNT <= 1) && player.isInParty())
  827. {
  828. if (!player.getParty().isLeader(player))
  829. {
  830. showHtmlFile(player, npcId + "-NL.htm", npc, null);
  831. return;
  832. }
  833. for (L2PcInstance mem : player.getParty().getMembers())
  834. {
  835. QuestState qs = mem.getQuestState(hostQuest.getName());
  836. if ((qs == null) || (!qs.isStarted() && !qs.isCompleted()))
  837. {
  838. showHtmlFile(player, npcId + "-NS.htm", npc, mem);
  839. return;
  840. }
  841. if (mem.getInventory().getItemByItemId(ENTRANCE_PASS) == null)
  842. {
  843. showHtmlFile(player, npcId + "-SE.htm", npc, mem);
  844. return;
  845. }
  846. if (player.getWeightPenalty() >= 3)
  847. {
  848. mem.sendPacket(SystemMessageId.INVENTORY_LESS_THAN_80_PERCENT);
  849. return;
  850. }
  851. }
  852. }
  853. else
  854. {
  855. QuestState qs = player.getQuestState(hostQuest.getName());
  856. if ((qs == null) || (!qs.isStarted() && !qs.isCompleted()))
  857. {
  858. showHtmlFile(player, npcId + "-NS.htm", npc, player);
  859. return;
  860. }
  861. if (player.getInventory().getItemByItemId(ENTRANCE_PASS) == null)
  862. {
  863. showHtmlFile(player, npcId + "-SE.htm", npc, player);
  864. return;
  865. }
  866. if (player.getWeightPenalty() >= 3)
  867. {
  868. player.sendPacket(SystemMessageId.INVENTORY_LESS_THAN_80_PERCENT);
  869. return;
  870. }
  871. }
  872. if (!isEntryTime())
  873. {
  874. showHtmlFile(player, npcId + "-NE.htm", npc, null);
  875. return;
  876. }
  877. showHtmlFile(player, npcId + "-OK.htm", npc, null);
  878. entry(npcId, player);
  879. }
  880. private void entry(int npcId, L2PcInstance player)
  881. {
  882. int[] Location = _startHallSpawns.get(npcId);
  883. int driftx;
  884. int drifty;
  885. if (Config.FS_PARTY_MEMBER_COUNT > 1)
  886. {
  887. List<L2PcInstance> members = new FastList<>();
  888. for (L2PcInstance mem : player.getParty().getMembers())
  889. {
  890. if (!mem.isDead() && Util.checkIfInRange(700, player, mem, true))
  891. {
  892. members.add(mem);
  893. }
  894. }
  895. for (L2PcInstance mem : members)
  896. {
  897. GrandBossManager.getInstance().getZone(Location[0], Location[1], Location[2]).allowPlayerEntry(mem, 30);
  898. driftx = Rnd.get(-80, 80);
  899. drifty = Rnd.get(-80, 80);
  900. mem.teleToLocation(Location[0] + driftx, Location[1] + drifty, Location[2]);
  901. mem.destroyItemByItemId("Quest", ENTRANCE_PASS, 1, mem, true);
  902. if (mem.getInventory().getItemByItemId(ANTIQUE_BROOCH) == null)
  903. {
  904. mem.addItem("Quest", USED_PASS, 1, mem, true);
  905. }
  906. L2ItemInstance hallsKey = mem.getInventory().getItemByItemId(CHAPEL_KEY);
  907. if (hallsKey != null)
  908. {
  909. mem.destroyItemByItemId("Quest", CHAPEL_KEY, hallsKey.getCount(), mem, true);
  910. }
  911. }
  912. _challengers.remove(npcId);
  913. _challengers.put(npcId, player);
  914. _hallInUse.remove(npcId);
  915. _hallInUse.put(npcId, true);
  916. }
  917. if ((Config.FS_PARTY_MEMBER_COUNT <= 1) && player.isInParty())
  918. {
  919. List<L2PcInstance> members = new FastList<>();
  920. for (L2PcInstance mem : player.getParty().getMembers())
  921. {
  922. if (!mem.isDead() && Util.checkIfInRange(700, player, mem, true))
  923. {
  924. members.add(mem);
  925. }
  926. }
  927. for (L2PcInstance mem : members)
  928. {
  929. GrandBossManager.getInstance().getZone(Location[0], Location[1], Location[2]).allowPlayerEntry(mem, 30);
  930. driftx = Rnd.get(-80, 80);
  931. drifty = Rnd.get(-80, 80);
  932. mem.teleToLocation(Location[0] + driftx, Location[1] + drifty, Location[2]);
  933. mem.destroyItemByItemId("Quest", ENTRANCE_PASS, 1, mem, true);
  934. if (mem.getInventory().getItemByItemId(ANTIQUE_BROOCH) == null)
  935. {
  936. mem.addItem("Quest", USED_PASS, 1, mem, true);
  937. }
  938. L2ItemInstance hallsKey = mem.getInventory().getItemByItemId(CHAPEL_KEY);
  939. if (hallsKey != null)
  940. {
  941. mem.destroyItemByItemId("Quest", CHAPEL_KEY, hallsKey.getCount(), mem, true);
  942. }
  943. }
  944. _challengers.remove(npcId);
  945. _challengers.put(npcId, player);
  946. _hallInUse.remove(npcId);
  947. _hallInUse.put(npcId, true);
  948. }
  949. else
  950. {
  951. GrandBossManager.getInstance().getZone(Location[0], Location[1], Location[2]).allowPlayerEntry(player, 30);
  952. driftx = Rnd.get(-80, 80);
  953. drifty = Rnd.get(-80, 80);
  954. player.teleToLocation(Location[0] + driftx, Location[1] + drifty, Location[2]);
  955. player.destroyItemByItemId("Quest", ENTRANCE_PASS, 1, player, true);
  956. if (player.getInventory().getItemByItemId(ANTIQUE_BROOCH) == null)
  957. {
  958. player.addItem("Quest", USED_PASS, 1, player, true);
  959. }
  960. L2ItemInstance hallsKey = player.getInventory().getItemByItemId(CHAPEL_KEY);
  961. if (hallsKey != null)
  962. {
  963. player.destroyItemByItemId("Quest", CHAPEL_KEY, hallsKey.getCount(), player, true);
  964. }
  965. _challengers.remove(npcId);
  966. _challengers.put(npcId, player);
  967. _hallInUse.remove(npcId);
  968. _hallInUse.put(npcId, true);
  969. }
  970. }
  971. public void spawnMysteriousBox(int npcId)
  972. {
  973. if (!isAttackTime())
  974. {
  975. return;
  976. }
  977. L2Spawn spawnDat = _mysteriousBoxSpawns.get(npcId);
  978. if (spawnDat != null)
  979. {
  980. _allMobs.add(spawnDat.doSpawn());
  981. spawnDat.stopRespawn();
  982. }
  983. }
  984. public void spawnMonster(int npcId)
  985. {
  986. if (!isAttackTime())
  987. {
  988. return;
  989. }
  990. FastList<L2Spawn> monsterList;
  991. FastList<L2SepulcherMonsterInstance> mobs = new FastList<>();
  992. L2Spawn keyBoxMobSpawn;
  993. if (Rnd.get(2) == 0)
  994. {
  995. monsterList = _physicalMonsters.get(npcId);
  996. }
  997. else
  998. {
  999. monsterList = _magicalMonsters.get(npcId);
  1000. }
  1001. if (monsterList != null)
  1002. {
  1003. boolean spawnKeyBoxMob = false;
  1004. boolean spawnedKeyBoxMob = false;
  1005. for (L2Spawn spawnDat : monsterList)
  1006. {
  1007. if (spawnedKeyBoxMob)
  1008. {
  1009. spawnKeyBoxMob = false;
  1010. }
  1011. else
  1012. {
  1013. switch (npcId)
  1014. {
  1015. case 31469:
  1016. case 31474:
  1017. case 31479:
  1018. case 31484:
  1019. if (Rnd.get(48) == 0)
  1020. {
  1021. spawnKeyBoxMob = true;
  1022. // _log.info("FourSepulchersManager.SpawnMonster:
  1023. // Set to spawn Church of Viscount Key Mob.");
  1024. }
  1025. break;
  1026. default:
  1027. spawnKeyBoxMob = false;
  1028. }
  1029. }
  1030. L2SepulcherMonsterInstance mob = null;
  1031. if (spawnKeyBoxMob)
  1032. {
  1033. try
  1034. {
  1035. L2NpcTemplate template = NpcTable.getInstance().getTemplate(18149);
  1036. if (template != null)
  1037. {
  1038. keyBoxMobSpawn = new L2Spawn(template);
  1039. keyBoxMobSpawn.setAmount(1);
  1040. keyBoxMobSpawn.setLocx(spawnDat.getLocx());
  1041. keyBoxMobSpawn.setLocy(spawnDat.getLocy());
  1042. keyBoxMobSpawn.setLocz(spawnDat.getLocz());
  1043. keyBoxMobSpawn.setHeading(spawnDat.getHeading());
  1044. keyBoxMobSpawn.setRespawnDelay(3600);
  1045. SpawnTable.getInstance().addNewSpawn(keyBoxMobSpawn, false);
  1046. mob = (L2SepulcherMonsterInstance) keyBoxMobSpawn.doSpawn();
  1047. keyBoxMobSpawn.stopRespawn();
  1048. }
  1049. else
  1050. {
  1051. _log.warning("FourSepulchersManager.SpawnMonster: Data missing in NPC table for ID: 18149");
  1052. }
  1053. }
  1054. catch (Exception e)
  1055. {
  1056. _log.log(Level.WARNING, "FourSepulchersManager.SpawnMonster: Spawn could not be initialized: " + e.getMessage(), e);
  1057. }
  1058. spawnedKeyBoxMob = true;
  1059. }
  1060. else
  1061. {
  1062. mob = (L2SepulcherMonsterInstance) spawnDat.doSpawn();
  1063. spawnDat.stopRespawn();
  1064. }
  1065. if (mob != null)
  1066. {
  1067. mob.mysteriousBoxId = npcId;
  1068. switch (npcId)
  1069. {
  1070. case 31469:
  1071. case 31474:
  1072. case 31479:
  1073. case 31484:
  1074. case 31472:
  1075. case 31477:
  1076. case 31482:
  1077. case 31487:
  1078. mobs.add(mob);
  1079. }
  1080. _allMobs.add(mob);
  1081. }
  1082. }
  1083. switch (npcId)
  1084. {
  1085. case 31469:
  1086. case 31474:
  1087. case 31479:
  1088. case 31484:
  1089. _viscountMobs.put(npcId, mobs);
  1090. break;
  1091. case 31472:
  1092. case 31477:
  1093. case 31482:
  1094. case 31487:
  1095. _dukeMobs.put(npcId, mobs);
  1096. break;
  1097. }
  1098. }
  1099. }
  1100. public synchronized boolean isViscountMobsAnnihilated(int npcId)
  1101. {
  1102. FastList<L2SepulcherMonsterInstance> mobs = _viscountMobs.get(npcId);
  1103. if (mobs == null)
  1104. {
  1105. return true;
  1106. }
  1107. for (L2SepulcherMonsterInstance mob : mobs)
  1108. {
  1109. if (!mob.isDead())
  1110. {
  1111. return false;
  1112. }
  1113. }
  1114. return true;
  1115. }
  1116. public synchronized boolean isDukeMobsAnnihilated(int npcId)
  1117. {
  1118. FastList<L2SepulcherMonsterInstance> mobs = _dukeMobs.get(npcId);
  1119. if (mobs == null)
  1120. {
  1121. return true;
  1122. }
  1123. for (L2SepulcherMonsterInstance mob : mobs)
  1124. {
  1125. if (!mob.isDead())
  1126. {
  1127. return false;
  1128. }
  1129. }
  1130. return true;
  1131. }
  1132. public void spawnKeyBox(L2Npc activeChar)
  1133. {
  1134. if (!isAttackTime())
  1135. {
  1136. return;
  1137. }
  1138. L2Spawn spawnDat = _keyBoxSpawns.get(activeChar.getNpcId());
  1139. if (spawnDat != null)
  1140. {
  1141. spawnDat.setAmount(1);
  1142. spawnDat.setLocx(activeChar.getX());
  1143. spawnDat.setLocy(activeChar.getY());
  1144. spawnDat.setLocz(activeChar.getZ());
  1145. spawnDat.setHeading(activeChar.getHeading());
  1146. spawnDat.setRespawnDelay(3600);
  1147. _allMobs.add(spawnDat.doSpawn());
  1148. spawnDat.stopRespawn();
  1149. }
  1150. }
  1151. public void spawnExecutionerOfHalisha(L2Npc activeChar)
  1152. {
  1153. if (!isAttackTime())
  1154. {
  1155. return;
  1156. }
  1157. L2Spawn spawnDat = _executionerSpawns.get(activeChar.getNpcId());
  1158. if (spawnDat != null)
  1159. {
  1160. spawnDat.setAmount(1);
  1161. spawnDat.setLocx(activeChar.getX());
  1162. spawnDat.setLocy(activeChar.getY());
  1163. spawnDat.setLocz(activeChar.getZ());
  1164. spawnDat.setHeading(activeChar.getHeading());
  1165. spawnDat.setRespawnDelay(3600);
  1166. _allMobs.add(spawnDat.doSpawn());
  1167. spawnDat.stopRespawn();
  1168. }
  1169. }
  1170. public void spawnArchonOfHalisha(int npcId)
  1171. {
  1172. if (!isAttackTime())
  1173. {
  1174. return;
  1175. }
  1176. if (_archonSpawned.get(npcId))
  1177. {
  1178. return;
  1179. }
  1180. FastList<L2Spawn> monsterList = _dukeFinalMobs.get(npcId);
  1181. if (monsterList != null)
  1182. {
  1183. for (L2Spawn spawnDat : monsterList)
  1184. {
  1185. L2SepulcherMonsterInstance mob = (L2SepulcherMonsterInstance) spawnDat.doSpawn();
  1186. spawnDat.stopRespawn();
  1187. if (mob != null)
  1188. {
  1189. mob.mysteriousBoxId = npcId;
  1190. _allMobs.add(mob);
  1191. }
  1192. }
  1193. _archonSpawned.put(npcId, true);
  1194. }
  1195. }
  1196. public void spawnEmperorsGraveNpc(int npcId)
  1197. {
  1198. if (!isAttackTime())
  1199. {
  1200. return;
  1201. }
  1202. FastList<L2Spawn> monsterList = _emperorsGraveNpcs.get(npcId);
  1203. if (monsterList != null)
  1204. {
  1205. for (L2Spawn spawnDat : monsterList)
  1206. {
  1207. _allMobs.add(spawnDat.doSpawn());
  1208. spawnDat.stopRespawn();
  1209. }
  1210. }
  1211. }
  1212. protected void locationShadowSpawns()
  1213. {
  1214. int locNo = Rnd.get(4);
  1215. // _log.info("FourSepulchersManager.LocationShadowSpawns: Location index
  1216. // is " + locNo + ".");
  1217. final int[] gateKeeper =
  1218. {
  1219. 31929,
  1220. 31934,
  1221. 31939,
  1222. 31944
  1223. };
  1224. L2Spawn spawnDat;
  1225. for (int i = 0; i <= 3; i++)
  1226. {
  1227. int keyNpcId = gateKeeper[i];
  1228. spawnDat = _shadowSpawns.get(keyNpcId);
  1229. spawnDat.setLocx(_shadowSpawnLoc[locNo][i][1]);
  1230. spawnDat.setLocy(_shadowSpawnLoc[locNo][i][2]);
  1231. spawnDat.setLocz(_shadowSpawnLoc[locNo][i][3]);
  1232. spawnDat.setHeading(_shadowSpawnLoc[locNo][i][4]);
  1233. _shadowSpawns.put(keyNpcId, spawnDat);
  1234. }
  1235. }
  1236. public void spawnShadow(int npcId)
  1237. {
  1238. if (!isAttackTime())
  1239. {
  1240. return;
  1241. }
  1242. L2Spawn spawnDat = _shadowSpawns.get(npcId);
  1243. if (spawnDat != null)
  1244. {
  1245. L2SepulcherMonsterInstance mob = (L2SepulcherMonsterInstance) spawnDat.doSpawn();
  1246. spawnDat.stopRespawn();
  1247. if (mob != null)
  1248. {
  1249. mob.mysteriousBoxId = npcId;
  1250. _allMobs.add(mob);
  1251. }
  1252. }
  1253. }
  1254. public void deleteAllMobs()
  1255. {
  1256. for (L2Npc mob : _allMobs)
  1257. {
  1258. if (mob == null)
  1259. {
  1260. continue;
  1261. }
  1262. try
  1263. {
  1264. if (mob.getSpawn() != null)
  1265. {
  1266. mob.getSpawn().stopRespawn();
  1267. }
  1268. mob.deleteMe();
  1269. }
  1270. catch (Exception e)
  1271. {
  1272. _log.log(Level.SEVERE, getClass().getSimpleName() + ": Failed deleting mob.", e);
  1273. }
  1274. }
  1275. _allMobs.clear();
  1276. }
  1277. protected void closeAllDoors()
  1278. {
  1279. for (int doorId : _hallGateKeepers.values())
  1280. {
  1281. try
  1282. {
  1283. L2DoorInstance door = DoorTable.getInstance().getDoor(doorId);
  1284. if (door != null)
  1285. {
  1286. door.closeMe();
  1287. }
  1288. else
  1289. {
  1290. _log.warning(getClass().getSimpleName() + ": Attempted to close undefined door. doorId: " + doorId);
  1291. }
  1292. }
  1293. catch (Exception e)
  1294. {
  1295. _log.log(Level.SEVERE, getClass().getSimpleName() + ": Failed closing door", e);
  1296. }
  1297. }
  1298. }
  1299. protected byte minuteSelect(byte min)
  1300. {
  1301. if (((double) min % 5) != 0)// if doesn't divides on 5 fully
  1302. {
  1303. // mad table for selecting proper minutes...
  1304. // may be there is a better way to do this
  1305. switch (min)
  1306. {
  1307. case 6:
  1308. case 7:
  1309. min = 5;
  1310. break;
  1311. case 8:
  1312. case 9:
  1313. case 11:
  1314. case 12:
  1315. min = 10;
  1316. break;
  1317. case 13:
  1318. case 14:
  1319. case 16:
  1320. case 17:
  1321. min = 15;
  1322. break;
  1323. case 18:
  1324. case 19:
  1325. case 21:
  1326. case 22:
  1327. min = 20;
  1328. break;
  1329. case 23:
  1330. case 24:
  1331. case 26:
  1332. case 27:
  1333. min = 25;
  1334. break;
  1335. case 28:
  1336. case 29:
  1337. case 31:
  1338. case 32:
  1339. min = 30;
  1340. break;
  1341. case 33:
  1342. case 34:
  1343. case 36:
  1344. case 37:
  1345. min = 35;
  1346. break;
  1347. case 38:
  1348. case 39:
  1349. case 41:
  1350. case 42:
  1351. min = 40;
  1352. break;
  1353. case 43:
  1354. case 44:
  1355. case 46:
  1356. case 47:
  1357. min = 45;
  1358. break;
  1359. case 48:
  1360. case 49:
  1361. case 51:
  1362. case 52:
  1363. min = 50;
  1364. break;
  1365. case 53:
  1366. case 54:
  1367. case 56:
  1368. case 57:
  1369. min = 55;
  1370. break;
  1371. }
  1372. }
  1373. return min;
  1374. }
  1375. public void managerSay(byte min)
  1376. {
  1377. // for attack phase, sending message every 5 minutes
  1378. if (_inAttackTime)
  1379. {
  1380. if (min < 5)
  1381. {
  1382. return; // do not shout when < 5 minutes
  1383. }
  1384. min = minuteSelect(min);
  1385. NpcStringId msg = NpcStringId.MINUTES_HAVE_PASSED;
  1386. if (min == 90)
  1387. {
  1388. msg = NpcStringId.GAME_OVER_THE_TELEPORT_WILL_APPEAR_MOMENTARILY;
  1389. }
  1390. for (L2Spawn temp : _managers)
  1391. {
  1392. if (temp == null)
  1393. {
  1394. _log.warning(getClass().getSimpleName() + ": managerSay(): manager is null");
  1395. continue;
  1396. }
  1397. if (!(temp.getLastSpawn() instanceof L2SepulcherNpcInstance))
  1398. {
  1399. _log.warning(getClass().getSimpleName() + ": managerSay(): manager is not Sepulcher instance");
  1400. continue;
  1401. }
  1402. // hall not used right now, so its manager will not tell you
  1403. // anything :)
  1404. // if you don't need this - delete next two lines.
  1405. if (!_hallInUse.get(temp.getNpcid()).booleanValue())
  1406. {
  1407. continue;
  1408. }
  1409. ((L2SepulcherNpcInstance) temp.getLastSpawn()).sayInShout(msg);
  1410. }
  1411. }
  1412. else if (_inEntryTime)
  1413. {
  1414. NpcStringId msg1 = NpcStringId.YOU_MAY_NOW_ENTER_THE_SEPULCHER;
  1415. NpcStringId msg2 = NpcStringId.IF_YOU_PLACE_YOUR_HAND_ON_THE_STONE_STATUE_IN_FRONT_OF_EACH_SEPULCHER_YOU_WILL_BE_ABLE_TO_ENTER;
  1416. for (L2Spawn temp : _managers)
  1417. {
  1418. if (temp == null)
  1419. {
  1420. _log.warning(getClass().getSimpleName() + ": Something goes wrong in managerSay()...");
  1421. continue;
  1422. }
  1423. if (!(temp.getLastSpawn() instanceof L2SepulcherNpcInstance))
  1424. {
  1425. _log.warning(getClass().getSimpleName() + ": Something goes wrong in managerSay()...");
  1426. continue;
  1427. }
  1428. ((L2SepulcherNpcInstance) temp.getLastSpawn()).sayInShout(msg1);
  1429. ((L2SepulcherNpcInstance) temp.getLastSpawn()).sayInShout(msg2);
  1430. }
  1431. }
  1432. }
  1433. protected class ManagerSay implements Runnable
  1434. {
  1435. @Override
  1436. public void run()
  1437. {
  1438. if (_inAttackTime)
  1439. {
  1440. Calendar tmp = Calendar.getInstance();
  1441. tmp.setTimeInMillis(Calendar.getInstance().getTimeInMillis() - _warmUpTimeEnd);
  1442. if ((tmp.get(Calendar.MINUTE) + 5) < Config.FS_TIME_ATTACK)
  1443. {
  1444. managerSay((byte) tmp.get(Calendar.MINUTE)); // byte
  1445. // because
  1446. // minute
  1447. // cannot be
  1448. // more than
  1449. // 59
  1450. ThreadPoolManager.getInstance().scheduleGeneral(new ManagerSay(), 5 * 60000);
  1451. }
  1452. // attack time ending chat
  1453. else if ((tmp.get(Calendar.MINUTE) + 5) >= Config.FS_TIME_ATTACK)
  1454. {
  1455. managerSay((byte) 90); // sending a unique id :D
  1456. }
  1457. }
  1458. else if (_inEntryTime)
  1459. {
  1460. managerSay((byte) 0);
  1461. }
  1462. }
  1463. }
  1464. protected class ChangeEntryTime implements Runnable
  1465. {
  1466. @Override
  1467. public void run()
  1468. {
  1469. // _log.info("FourSepulchersManager:In Entry Time");
  1470. _inEntryTime = true;
  1471. _inWarmUpTime = false;
  1472. _inAttackTime = false;
  1473. _inCoolDownTime = false;
  1474. long interval = 0;
  1475. // if this is first launch - search time when entry time will be
  1476. // ended:
  1477. // counting difference between time when entry time ends and current
  1478. // time
  1479. // and then launching change time task
  1480. if (_firstTimeRun)
  1481. {
  1482. interval = _entryTimeEnd - Calendar.getInstance().getTimeInMillis();
  1483. }
  1484. else
  1485. {
  1486. interval = Config.FS_TIME_ENTRY * 60000L; // else use stupid
  1487. // method
  1488. }
  1489. // launching saying process...
  1490. ThreadPoolManager.getInstance().scheduleGeneral(new ManagerSay(), 0);
  1491. _changeWarmUpTimeTask = ThreadPoolManager.getInstance().scheduleEffect(new ChangeWarmUpTime(), interval);
  1492. if (_changeEntryTimeTask != null)
  1493. {
  1494. _changeEntryTimeTask.cancel(true);
  1495. _changeEntryTimeTask = null;
  1496. }
  1497. }
  1498. }
  1499. protected class ChangeWarmUpTime implements Runnable
  1500. {
  1501. @Override
  1502. public void run()
  1503. {
  1504. // _log.info("FourSepulchersManager:In Warm-Up Time");
  1505. _inEntryTime = true;
  1506. _inWarmUpTime = false;
  1507. _inAttackTime = false;
  1508. _inCoolDownTime = false;
  1509. long interval = 0;
  1510. // searching time when warmup time will be ended:
  1511. // counting difference between time when warmup time ends and
  1512. // current time
  1513. // and then launching change time task
  1514. if (_firstTimeRun)
  1515. {
  1516. interval = _warmUpTimeEnd - Calendar.getInstance().getTimeInMillis();
  1517. }
  1518. else
  1519. {
  1520. interval = Config.FS_TIME_WARMUP * 60000L;
  1521. }
  1522. _changeAttackTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeAttackTime(), interval);
  1523. if (_changeWarmUpTimeTask != null)
  1524. {
  1525. _changeWarmUpTimeTask.cancel(true);
  1526. _changeWarmUpTimeTask = null;
  1527. }
  1528. }
  1529. }
  1530. protected class ChangeAttackTime implements Runnable
  1531. {
  1532. @Override
  1533. public void run()
  1534. {
  1535. // _log.info("FourSepulchersManager:In Attack Time");
  1536. _inEntryTime = false;
  1537. _inWarmUpTime = false;
  1538. _inAttackTime = true;
  1539. _inCoolDownTime = false;
  1540. locationShadowSpawns();
  1541. spawnMysteriousBox(31921);
  1542. spawnMysteriousBox(31922);
  1543. spawnMysteriousBox(31923);
  1544. spawnMysteriousBox(31924);
  1545. if (!_firstTimeRun)
  1546. {
  1547. _warmUpTimeEnd = Calendar.getInstance().getTimeInMillis();
  1548. }
  1549. long interval = 0;
  1550. // say task
  1551. if (_firstTimeRun)
  1552. {
  1553. for (double min = Calendar.getInstance().get(Calendar.MINUTE); min < _newCycleMin; min++)
  1554. {
  1555. // looking for next shout time....
  1556. if ((min % 5) == 0)// check if min can be divided by 5
  1557. {
  1558. _log.info(getClass().getSimpleName() + ": " + Calendar.getInstance().getTime() + " Atk announce scheduled to " + min + " minute of this hour.");
  1559. Calendar inter = Calendar.getInstance();
  1560. inter.set(Calendar.MINUTE, (int) min);
  1561. ThreadPoolManager.getInstance().scheduleGeneral(new ManagerSay(), inter.getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
  1562. break;
  1563. }
  1564. }
  1565. }
  1566. else
  1567. {
  1568. ThreadPoolManager.getInstance().scheduleGeneral(new ManagerSay(), 5 * 60400);
  1569. }
  1570. // searching time when attack time will be ended:
  1571. // counting difference between time when attack time ends and
  1572. // current time
  1573. // and then launching change time task
  1574. if (_firstTimeRun)
  1575. {
  1576. interval = _attackTimeEnd - Calendar.getInstance().getTimeInMillis();
  1577. }
  1578. else
  1579. {
  1580. interval = Config.FS_TIME_ATTACK * 60000L;
  1581. }
  1582. _changeCoolDownTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeCoolDownTime(), interval);
  1583. if (_changeAttackTimeTask != null)
  1584. {
  1585. _changeAttackTimeTask.cancel(true);
  1586. _changeAttackTimeTask = null;
  1587. }
  1588. }
  1589. }
  1590. protected class ChangeCoolDownTime implements Runnable
  1591. {
  1592. @Override
  1593. public void run()
  1594. {
  1595. // _log.info("FourSepulchersManager:In Cool-Down Time");
  1596. _inEntryTime = false;
  1597. _inWarmUpTime = false;
  1598. _inAttackTime = false;
  1599. _inCoolDownTime = true;
  1600. clean();
  1601. Calendar time = Calendar.getInstance();
  1602. // one hour = 55th min to 55 min of next hour, so we check for this,
  1603. // also check for first launch
  1604. if ((Calendar.getInstance().get(Calendar.MINUTE) > _newCycleMin) && !_firstTimeRun)
  1605. {
  1606. time.set(Calendar.HOUR, Calendar.getInstance().get(Calendar.HOUR) + 1);
  1607. }
  1608. time.set(Calendar.MINUTE, _newCycleMin);
  1609. _log.info(getClass().getSimpleName() + ": Entry time: " + time.getTime());
  1610. if (_firstTimeRun)
  1611. {
  1612. _firstTimeRun = false; // cooldown phase ends event hour, so it
  1613. // will be not first run
  1614. }
  1615. long interval = time.getTimeInMillis() - Calendar.getInstance().getTimeInMillis();
  1616. _changeEntryTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeEntryTime(), interval);
  1617. if (_changeCoolDownTimeTask != null)
  1618. {
  1619. _changeCoolDownTimeTask.cancel(true);
  1620. _changeCoolDownTimeTask = null;
  1621. }
  1622. }
  1623. }
  1624. public TIntIntHashMap getHallGateKeepers()
  1625. {
  1626. return _hallGateKeepers;
  1627. }
  1628. public void showHtmlFile(L2PcInstance player, String file, L2Npc npc, L2PcInstance member)
  1629. {
  1630. NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
  1631. html.setFile(player.getHtmlPrefix(), "data/html/SepulcherNpc/" + file);
  1632. if (member != null)
  1633. {
  1634. html.replace("%member%", member.getName());
  1635. }
  1636. player.sendPacket(html);
  1637. }
  1638. public static final FourSepulchersManager getInstance()
  1639. {
  1640. return SingletonHolder._instance;
  1641. }
  1642. private static class SingletonHolder
  1643. {
  1644. protected static final FourSepulchersManager _instance = new FourSepulchersManager();
  1645. }
  1646. }