CavernOfThePirateCaptain.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package instances.CavernOfThePirateCaptain;
  20. import java.util.ArrayList;
  21. import java.util.Calendar;
  22. import java.util.List;
  23. import ai.npc.AbstractNpcAI;
  24. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  25. import com.l2jserver.gameserver.model.L2Party;
  26. import com.l2jserver.gameserver.model.L2World;
  27. import com.l2jserver.gameserver.model.Location;
  28. import com.l2jserver.gameserver.model.PcCondOverride;
  29. import com.l2jserver.gameserver.model.actor.L2Attackable;
  30. import com.l2jserver.gameserver.model.actor.L2Npc;
  31. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  32. import com.l2jserver.gameserver.model.entity.Instance;
  33. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  34. import com.l2jserver.gameserver.network.NpcStringId;
  35. import com.l2jserver.gameserver.network.SystemMessageId;
  36. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  37. /**
  38. * Cavern Of The Pirate Captain (Day Dream) instance Zone.
  39. * @author St3eT
  40. */
  41. public class CavernOfThePirateCaptain extends AbstractNpcAI
  42. {
  43. protected class CavernOfThePirateCaptainWorld extends InstanceWorld
  44. {
  45. ArrayList<L2PcInstance> playersInside = new ArrayList<>();
  46. L2Attackable _zaken;
  47. long storeTime = 0;
  48. boolean _is83;
  49. int _zakenRoom;
  50. int _blueFounded;
  51. }
  52. // NPCs
  53. private static final int PATHFINDER = 32713; // Pathfinder Worker
  54. private static final int ZAKEN_60 = 29176; // Zaken
  55. private static final int ZAKEN_83 = 29181; // Zaken
  56. private static final int CANDLE = 32705; // Zaken's Candle
  57. private static final int DOLL_BLADER_60 = 29023; // Doll Blader
  58. private static final int DOLL_BLADER_83 = 29182; // Doll Blader
  59. private static final int VALE_MASTER_60 = 29024; // Veil Master
  60. private static final int VALE_MASTER_83 = 29183; // Veil Master
  61. private static final int PIRATES_ZOMBIE_60 = 29027; // Pirate Zombie
  62. private static final int PIRATES_ZOMBIE_83 = 29185; // Pirate Zombie
  63. private static final int PIRATES_ZOMBIE_CAPTAIN_60 = 29026; // Pirate Zombie Captain
  64. private static final int PIRATES_ZOMBIE_CAPTAIN_83 = 29184; // Pirate Zombie Captain
  65. // Items
  66. private static final int VORPAL_RING = 15763; // Sealed Vorpal Ring
  67. private static final int VORPAL_EARRING = 15764; // Sealed Vorpal Earring
  68. private static final int FIRE = 15280; // Transparent 1HS (for NPC)
  69. private static final int RED = 15281; // Transparent 1HS (for NPC)
  70. private static final int BLUE = 15302; // Transparent Bow (for NPC)
  71. // Locations
  72. private static final Location[] ENTER_LOC =
  73. {
  74. new Location(52684, 219989, -3496),
  75. new Location(52669, 219120, -3224),
  76. new Location(52672, 219439, -3312),
  77. };
  78. private static final Location[] CANDLE_LOC =
  79. {
  80. // Floor 1
  81. new Location(53313, 220133, -3498),
  82. new Location(53313, 218079, -3498),
  83. new Location(54240, 221045, -3498),
  84. new Location(54325, 219095, -3498),
  85. new Location(54240, 217155, -3498),
  86. new Location(55257, 220028, -3498),
  87. new Location(55257, 218172, -3498),
  88. new Location(56280, 221045, -3498),
  89. new Location(56195, 219095, -3498),
  90. new Location(56280, 217155, -3498),
  91. new Location(57215, 220133, -3498),
  92. new Location(57215, 218079, -3498),
  93. // Floor 2
  94. new Location(53313, 220133, -3226),
  95. new Location(53313, 218079, -3226),
  96. new Location(54240, 221045, -3226),
  97. new Location(54325, 219095, -3226),
  98. new Location(54240, 217155, -3226),
  99. new Location(55257, 220028, -3226),
  100. new Location(55257, 218172, -3226),
  101. new Location(56280, 221045, -3226),
  102. new Location(56195, 219095, -3226),
  103. new Location(56280, 217155, -3226),
  104. new Location(57215, 220133, -3226),
  105. new Location(57215, 218079, -3226),
  106. // Floor 3
  107. new Location(53313, 220133, -2954),
  108. new Location(53313, 218079, -2954),
  109. new Location(54240, 221045, -2954),
  110. new Location(54325, 219095, -2954),
  111. new Location(54240, 217155, -2954),
  112. new Location(55257, 220028, -2954),
  113. new Location(55257, 218172, -2954),
  114. new Location(56280, 221045, -2954),
  115. new Location(56195, 219095, -2954),
  116. new Location(56280, 217155, -2954),
  117. new Location(57215, 220133, -2954),
  118. new Location(57215, 218079, -2954),
  119. };
  120. // Misc
  121. private static final int MIN_LV_60 = 55;
  122. private static final int MIN_LV_83 = 78;
  123. private static final int PLAYERS_60_MIN = 9;
  124. private static final int PLAYERS_60_MAX = 27;
  125. private static final int PLAYERS_83_MIN = 9;
  126. private static final int PLAYERS_83_MAX = 27;
  127. private static final int INSTANCE_ID_60 = 133;
  128. private static final int INSTANCE_ID_83 = 135;
  129. private static final int HOURS = 6;
  130. private static final int MINUTES = 30;
  131. private static final int DAY_A = Calendar.MONDAY;
  132. private static final int DAY_B = Calendar.WEDNESDAY;
  133. private static final int DAY_C = Calendar.FRIDAY;
  134. //@formatter:off
  135. private static final int[][] ROOM_DATA =
  136. {
  137. // Floor 1
  138. {54240, 220133, -3498, 1, 3, 4, 6},
  139. {54240, 218073, -3498, 2, 5, 4, 7},
  140. {55265, 219095, -3498, 4, 9, 6, 7},
  141. {56289, 220133, -3498, 8, 11, 6, 9},
  142. {56289, 218073, -3498, 10, 12, 7, 9},
  143. // Floor 2
  144. {54240, 220133, -3226, 13, 15, 16, 18},
  145. {54240, 218073, -3226, 14, 17, 16, 19},
  146. {55265, 219095, -3226, 21, 16, 19, 18},
  147. {56289, 220133, -3226, 20, 23, 21, 18},
  148. {56289, 218073, -3226, 22, 24, 19, 21},
  149. // Floor 3
  150. {54240, 220133, -2954, 25, 27, 28, 30},
  151. {54240, 218073, -2954, 26, 29, 28, 31},
  152. {55265, 219095, -2954, 33, 28, 31, 30},
  153. {56289, 220133, -2954, 32, 35, 30, 33},
  154. {56289, 218073, -2954, 34, 36, 31, 33}
  155. };
  156. //@formatter:on
  157. private CavernOfThePirateCaptain()
  158. {
  159. super(CavernOfThePirateCaptain.class.getSimpleName(), "instances");
  160. addStartNpc(PATHFINDER);
  161. addTalkId(PATHFINDER);
  162. addKillId(ZAKEN_60, ZAKEN_83);
  163. addFirstTalkId(CANDLE);
  164. }
  165. private void enterInstance(L2PcInstance player, String template, boolean is83)
  166. {
  167. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  168. if (world != null)
  169. {
  170. if (world instanceof CavernOfThePirateCaptainWorld)
  171. {
  172. teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId(), false);
  173. return;
  174. }
  175. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  176. return;
  177. }
  178. if (checkConditions(player, is83))
  179. {
  180. world = new CavernOfThePirateCaptainWorld();
  181. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
  182. world.setTemplateId(is83 ? INSTANCE_ID_83 : INSTANCE_ID_60);
  183. world.setStatus(0);
  184. InstanceManager.getInstance().addWorld(world);
  185. final CavernOfThePirateCaptainWorld curworld = (CavernOfThePirateCaptainWorld) world;
  186. curworld._is83 = is83;
  187. curworld.storeTime = System.currentTimeMillis();
  188. if (!player.isInParty())
  189. {
  190. managePlayerEnter(player, curworld);
  191. }
  192. else if (player.getParty().isInCommandChannel())
  193. {
  194. for (L2PcInstance players : player.getParty().getCommandChannel().getMembers())
  195. {
  196. managePlayerEnter(players, curworld);
  197. }
  198. }
  199. else
  200. {
  201. for (L2PcInstance players : player.getParty().getMembers())
  202. {
  203. managePlayerEnter(players, curworld);
  204. }
  205. }
  206. manageNpcSpawn(curworld);
  207. }
  208. }
  209. private void managePlayerEnter(L2PcInstance player, CavernOfThePirateCaptainWorld world)
  210. {
  211. if (!world._is83)
  212. {
  213. player.stopAllEffectsExceptThoseThatLastThroughDeath();
  214. if (player.hasSummon())
  215. {
  216. player.getSummon().stopAllEffectsExceptThoseThatLastThroughDeath();
  217. }
  218. }
  219. world.playersInside.add(player);
  220. world.addAllowed(player.getObjectId());
  221. teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId(), false);
  222. }
  223. private boolean checkConditions(L2PcInstance player, boolean is83)
  224. {
  225. if (player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
  226. {
  227. return true;
  228. }
  229. if (!player.isInParty())
  230. {
  231. broadcastSystemMessage(player, null, SystemMessageId.NOT_IN_PARTY_CANT_ENTER, false);
  232. return false;
  233. }
  234. final L2Party party = player.getParty();
  235. final boolean isInCC = party.isInCommandChannel();
  236. final List<L2PcInstance> members = (isInCC) ? party.getCommandChannel().getMembers() : party.getMembers();
  237. final boolean isPartyLeader = (isInCC) ? party.getCommandChannel().isLeader(player) : party.isLeader(player);
  238. if (!isPartyLeader)
  239. {
  240. broadcastSystemMessage(player, null, SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER, false);
  241. return false;
  242. }
  243. if ((members.size() < (is83 ? PLAYERS_83_MIN : PLAYERS_60_MIN)) || (members.size() > (is83 ? PLAYERS_83_MAX : PLAYERS_60_MAX)))
  244. {
  245. broadcastSystemMessage(player, null, SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER, false);
  246. return false;
  247. }
  248. for (L2PcInstance groupMembers : members)
  249. {
  250. if (groupMembers.getLevel() < (is83 ? MIN_LV_83 : MIN_LV_60))
  251. {
  252. broadcastSystemMessage(player, groupMembers, SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT, true);
  253. return false;
  254. }
  255. if (!player.isInsideRadius(groupMembers, 1000, true, true))
  256. {
  257. broadcastSystemMessage(player, groupMembers, SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED, true);
  258. return false;
  259. }
  260. final Long reentertime = InstanceManager.getInstance().getInstanceTime(groupMembers.getObjectId(), (is83 ? INSTANCE_ID_83 : INSTANCE_ID_60));
  261. if (System.currentTimeMillis() < reentertime)
  262. {
  263. broadcastSystemMessage(player, groupMembers, SystemMessageId.C1_MAY_NOT_REENTER_YET, true);
  264. return false;
  265. }
  266. }
  267. return true;
  268. }
  269. private void broadcastSystemMessage(L2PcInstance player, L2PcInstance member, SystemMessageId msgId, boolean toGroup)
  270. {
  271. final SystemMessage sm = SystemMessage.getSystemMessage(msgId);
  272. if (toGroup)
  273. {
  274. sm.addPcName(member);
  275. if (player.getParty().isInCommandChannel())
  276. {
  277. player.getParty().getCommandChannel().broadcastPacket(sm);
  278. }
  279. else
  280. {
  281. player.getParty().broadcastPacket(sm);
  282. }
  283. }
  284. else
  285. {
  286. player.broadcastPacket(sm);
  287. }
  288. }
  289. @Override
  290. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  291. {
  292. if (event.equals("enter60"))
  293. {
  294. enterInstance(player, "CavernOfThePirateCaptainWorldDay60.xml", false);
  295. }
  296. else if (event.equals("enter83"))
  297. {
  298. enterInstance(player, "CavernOfThePirateCaptainWorldDay83.xml", true);
  299. }
  300. else
  301. {
  302. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  303. if ((tmpworld != null) && (tmpworld instanceof CavernOfThePirateCaptainWorld))
  304. {
  305. final CavernOfThePirateCaptainWorld world = (CavernOfThePirateCaptainWorld) tmpworld;
  306. switch (event)
  307. {
  308. case "BURN_BLUE":
  309. {
  310. if (npc.getRightHandItem() == 0)
  311. {
  312. npc.setRHandId(FIRE);
  313. startQuestTimer("BURN_BLUE2", 3000, npc, player);
  314. if (world._blueFounded == 4)
  315. {
  316. startQuestTimer("SHOW_ZAKEN", 5000, npc, player);
  317. }
  318. }
  319. break;
  320. }
  321. case "BURN_BLUE2":
  322. {
  323. if (npc.getRightHandItem() == FIRE)
  324. {
  325. npc.setRHandId(BLUE);
  326. }
  327. break;
  328. }
  329. case "BURN_RED":
  330. {
  331. if (npc.getRightHandItem() == 0)
  332. {
  333. npc.setRHandId(FIRE);
  334. startQuestTimer("BURN_RED2", 3000, npc, player);
  335. }
  336. break;
  337. }
  338. case "BURN_RED2":
  339. {
  340. if (npc.getRightHandItem() == FIRE)
  341. {
  342. final int room = getRoomByCandle(npc);
  343. npc.setRHandId(RED);
  344. manageScreenMsg(world, NpcStringId.THE_CANDLES_CAN_LEAD_YOU_TO_ZAKEN_DESTROY_HIM);
  345. spawnNpc(world._is83 ? DOLL_BLADER_83 : DOLL_BLADER_60, room, player, world);
  346. spawnNpc(world._is83 ? VALE_MASTER_83 : VALE_MASTER_60, room, player, world);
  347. spawnNpc(world._is83 ? PIRATES_ZOMBIE_83 : PIRATES_ZOMBIE_60, room, player, world);
  348. spawnNpc(world._is83 ? PIRATES_ZOMBIE_CAPTAIN_83 : PIRATES_ZOMBIE_CAPTAIN_60, room, player, world);
  349. }
  350. break;
  351. }
  352. case "SHOW_ZAKEN":
  353. {
  354. if (world._is83)
  355. {
  356. manageScreenMsg(world, NpcStringId.WHO_DARES_AWKAWEN_THE_MIGHTY_ZAKEN);
  357. }
  358. world._zaken.setInvisible(false);
  359. world._zaken.setIsParalyzed(false);
  360. spawnNpc(world._is83 ? DOLL_BLADER_83 : DOLL_BLADER_60, world._zakenRoom, player, world);
  361. spawnNpc(world._is83 ? PIRATES_ZOMBIE_83 : PIRATES_ZOMBIE_60, world._zakenRoom, player, world);
  362. spawnNpc(world._is83 ? PIRATES_ZOMBIE_CAPTAIN_83 : PIRATES_ZOMBIE_CAPTAIN_60, world._zakenRoom, player, world);
  363. break;
  364. }
  365. }
  366. }
  367. }
  368. return super.onAdvEvent(event, npc, player);
  369. }
  370. @Override
  371. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  372. {
  373. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  374. if ((tmpworld != null) && (tmpworld instanceof CavernOfThePirateCaptainWorld))
  375. {
  376. final CavernOfThePirateCaptainWorld world = (CavernOfThePirateCaptainWorld) tmpworld;
  377. final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
  378. if (npc.getId() == ZAKEN_83)
  379. {
  380. for (L2PcInstance playersInside : world.playersInside)
  381. {
  382. if ((playersInside != null) && ((playersInside.getInstanceId() == world.getInstanceId()) && playersInside.isInsideRadius(npc, 1500, true, true)))
  383. {
  384. final long time = System.currentTimeMillis() - world.storeTime;
  385. if (time <= 300000) // 5 minutes
  386. {
  387. if (getRandomBoolean())
  388. {
  389. giveItems(playersInside, VORPAL_RING, 1);
  390. }
  391. }
  392. else if (time <= 600000) // 10 minutes
  393. {
  394. if (getRandom(100) < 30)
  395. {
  396. giveItems(playersInside, VORPAL_EARRING, 1);
  397. }
  398. }
  399. else if (time <= 900000) // 15 minutes
  400. {
  401. if (getRandom(100) < 25)
  402. {
  403. giveItems(playersInside, VORPAL_RING, 1);
  404. }
  405. }
  406. }
  407. }
  408. }
  409. saveReenterForPlayers(world);
  410. inst.setDuration(300000);
  411. inst.setEmptyDestroyTime(0);
  412. }
  413. return super.onKill(npc, killer, isSummon);
  414. }
  415. @Override
  416. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  417. {
  418. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  419. if ((tmpworld != null) && (tmpworld instanceof CavernOfThePirateCaptainWorld))
  420. {
  421. final CavernOfThePirateCaptainWorld world = (CavernOfThePirateCaptainWorld) tmpworld;
  422. final boolean isBlue = npc.getVariables().getInt("isBlue", 0) == 1;
  423. if (npc.isScriptValue(0))
  424. {
  425. if (isBlue)
  426. {
  427. world._blueFounded++;
  428. startQuestTimer("BURN_BLUE", 500, npc, player);
  429. }
  430. else
  431. {
  432. startQuestTimer("BURN_RED", 500, npc, player);
  433. }
  434. npc.setScriptValue(1);
  435. }
  436. }
  437. return null;
  438. }
  439. private int getRoomByCandle(L2Npc npc)
  440. {
  441. final int candleId = npc.getVariables().getInt("candleId", 0);
  442. for (int i = 0; i < 15; i++)
  443. {
  444. if ((ROOM_DATA[i][3] == candleId) || (ROOM_DATA[i][4] == candleId))
  445. {
  446. return i + 1;
  447. }
  448. }
  449. if ((candleId == 6) || (candleId == 7))
  450. {
  451. return 3;
  452. }
  453. else if ((candleId == 18) || (candleId == 19))
  454. {
  455. return 8;
  456. }
  457. else if ((candleId == 30) || (candleId == 31))
  458. {
  459. return 13;
  460. }
  461. return 0;
  462. }
  463. private void manageScreenMsg(CavernOfThePirateCaptainWorld world, NpcStringId stringId)
  464. {
  465. for (L2PcInstance players : world.playersInside)
  466. {
  467. if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
  468. {
  469. showOnScreenMsg(players, stringId, 2, 6000);
  470. }
  471. }
  472. }
  473. private L2Attackable spawnNpc(int npcId, int roomId, L2PcInstance player, CavernOfThePirateCaptainWorld world)
  474. {
  475. if ((player != null) && (npcId != ZAKEN_60) && (npcId != ZAKEN_83))
  476. {
  477. final L2Attackable mob = (L2Attackable) addSpawn(npcId, ROOM_DATA[roomId - 1][0] + getRandom(350), ROOM_DATA[roomId - 1][1] + getRandom(350), ROOM_DATA[roomId - 1][2], 0, false, 0, false, world.getInstanceId());
  478. attackPlayer(mob, player);
  479. return mob;
  480. }
  481. return (L2Attackable) addSpawn(npcId, ROOM_DATA[roomId - 1][0], ROOM_DATA[roomId - 1][1], ROOM_DATA[roomId - 1][2], 0, false, 0, false, world.getInstanceId());
  482. }
  483. private void manageNpcSpawn(CavernOfThePirateCaptainWorld world)
  484. {
  485. final List<L2Npc> candles = new ArrayList<>();
  486. world._zakenRoom = getRandom(1, 15);
  487. for (int i = 0; i < 36; i++)
  488. {
  489. final L2Npc candle = addSpawn(CANDLE, CANDLE_LOC[i], false, 0, false, world.getInstanceId());
  490. candle.getVariables().set("candleId", i + 1);
  491. candles.add(candle);
  492. }
  493. for (int i = 3; i < 7; i++)
  494. {
  495. candles.get(ROOM_DATA[world._zakenRoom - 1][i] - 1).getVariables().set("isBlue", 1);
  496. }
  497. world._zaken = spawnNpc(world._is83 ? ZAKEN_83 : ZAKEN_60, world._zakenRoom, null, world);
  498. world._zaken.setInvisible(true);
  499. world._zaken.setIsParalyzed(true);
  500. }
  501. private void saveReenterForPlayers(InstanceWorld world)
  502. {
  503. final Calendar reenter = Calendar.getInstance();
  504. reenter.set(Calendar.MINUTE, MINUTES);
  505. reenter.set(Calendar.HOUR_OF_DAY, HOURS);
  506. if (reenter.getTimeInMillis() <= System.currentTimeMillis())
  507. {
  508. reenter.add(Calendar.DAY_OF_MONTH, 1);
  509. }
  510. if ((reenter.get(Calendar.DAY_OF_WEEK) <= DAY_A) || (reenter.get(Calendar.DAY_OF_WEEK) > DAY_C))
  511. {
  512. while (reenter.get(Calendar.DAY_OF_WEEK) != DAY_A)
  513. {
  514. reenter.add(Calendar.DAY_OF_MONTH, 1);
  515. }
  516. }
  517. else if (reenter.get(Calendar.DAY_OF_WEEK) <= DAY_B)
  518. {
  519. while (reenter.get(Calendar.DAY_OF_WEEK) != DAY_B)
  520. {
  521. reenter.add(Calendar.DAY_OF_MONTH, 1);
  522. }
  523. }
  524. else
  525. {
  526. while (reenter.get(Calendar.DAY_OF_WEEK) != DAY_C)
  527. {
  528. reenter.add(Calendar.DAY_OF_MONTH, 1);
  529. }
  530. }
  531. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED);
  532. sm.addString(InstanceManager.getInstance().getInstanceIdName(world.getTemplateId()));
  533. for (int objectId : world.getAllowed())
  534. {
  535. final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
  536. InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
  537. if ((player != null) && player.isOnline())
  538. {
  539. player.sendPacket(sm);
  540. }
  541. }
  542. }
  543. public static void main(String[] args)
  544. {
  545. new CavernOfThePirateCaptain();
  546. }
  547. }