Sarada-L2

Party Farm Acis 382 Clean

Aug 11th, 2021 (edited)
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.69 KB | None | 0 0
  1. diff --git a/config/PartyFarm.properties b/config/PartyFarm.properties
  2. new file mode 100644
  3. index 0000000..bb00eed
  4. --- /dev/null
  5. +++ b/config/PartyFarm.properties
  6. @@ -0,0 +1,86 @@
  7. +#=====================================================
  8. +# PARTY FARM EVENT
  9. +#=====================================================
  10. +
  11. +MonsterLoc = -50324, 137542, -2871;\
  12. +-49694, 138843, -2919;\
  13. +-48580, 139801, -2930;\
  14. +-51061, 139072, -2925;\
  15. +-52648, 139600, -2937;\
  16. +-52084, 137211, -2884;\
  17. +-51885, 140437, -2859;\
  18. +-51313, 141965, -2878;\
  19. +-53470, 141986, -2858;\
  20. +-54383, 139210, -2906;\
  21. +-55321, 137909, -2911;\
  22. +-57082, 138361, -2714;\
  23. +-57845, 140766, -2649;\
  24. +-56629, 143361, -2566;\
  25. +-59379, 139309, -2466;\
  26. +-60082, 137623, -2327;\
  27. +-58639, 135770, -2457;\
  28. +-56714, 135084, -2433;\
  29. +-56715, 136673, -2789;\
  30. +-56264, 141358, -2628;\
  31. +-54986, 142629, -2839;\
  32. +-53362, 143202, -2892;\
  33. +-52410, 141770, -2925;\
  34. +-50588, 143081, -2895;\
  35. +-51088, 144450, -2893;\
  36. +-50856, 145485, -2812;\
  37. +-52172, 145466, -2820;\
  38. +-54007, 145158, -2875;\
  39. +-54325, 146502, -2877;\
  40. +-52890, 144172, -2908;\
  41. +-54113, 137140, -2752;\
  42. +-51976, 138979, -2952;\
  43. +-53666, 139817, -2857;\
  44. +-52753, 137986, -2921;\
  45. +-50593, 140423, -2855;\
  46. +-51996, 143661, -2892;
  47. +
  48. +#=========================================================
  49. +# PARTY DROP REWARD
  50. +#=========================================================
  51. +# Party Zone Monster ID
  52. +PartyEventMonster = 50056
  53. +
  54. +# Format: itemId,min,max,chance(%);itemId,min,max,(chance(%)(optional));.
  55. +# Normal hour reward
  56. +PartyZoneReward = 6392,600,900;6393,1,1,30;6577,1,2,70;6578,1,2,70;
  57. +#=========================================================
  58. +# Tempo em Segundos para o MOB aparecer apos ser morto
  59. +# Default: 300 (5 minutos)
  60. +MonsterDelay = 10
  61. +
  62. +# Id do Mob
  63. +MonsterId = 50056
  64. +
  65. +# Remover protesao renewal por ip?
  66. +# Retail = False (Manter Protesao)
  67. +RenewalDualBoxPTFarm = False
  68. +
  69. +#Ativar o Party Farm Event por tempo igual TvT
  70. +PartyFarmEventEnabled = False
  71. +
  72. +# Iniciar party farm ao ligar o server
  73. +StartSpawnPartyFarm = False
  74. +
  75. +#=========================================================
  76. +# CONFIG START TIME EVENT
  77. +#=========================================================
  78. +# PartyFarmEventEnabled=11:00,15:00,19:00,23:00,
  79. +#
  80. +# PartyFarm comando spawn manual //ptfarm ou //ptfarm para terminar o evento.
  81. +#
  82. +EventBestFarmTime = 50
  83. +BestFarmStartTime = 00:45,00:47,21:46,
  84. +
  85. +# Show screen Party message on character login
  86. +# Default: False
  87. +ScreenPartyMessageEnable = True
  88. +
  89. +# Screen Party Farm message text
  90. +ScreenPartyFarmMessageText = Party Farm is active
  91. +# Show screen PartyFarm message for x seconds.
  92. +ScreenPartyFarmMessageTime = 6
  93. diff --git a/java/Dev/Events/PartyFarm/InitialPartyFarm.java b/java/Dev/Events/PartyFarm/InitialPartyFarm.java
  94. new file mode 100644
  95. index 0000000..6454a60
  96. --- /dev/null
  97. +++ b/java/Dev/Events/PartyFarm/InitialPartyFarm.java
  98. @@ -0,0 +1,92 @@
  99. +package Dev.Events.PartyFarm;
  100. +
  101. +import java.text.SimpleDateFormat;
  102. +import java.util.Calendar;
  103. +import java.util.logging.Logger;
  104. +
  105. +import net.sf.l2j.commons.concurrent.ThreadPool;
  106. +
  107. +import net.sf.l2j.Config;
  108. +
  109. +public class InitialPartyFarm
  110. +{
  111. + private static InitialPartyFarm _instance = null;
  112. + protected static final Logger _log = Logger.getLogger(InitialPartyFarm.class.getName());
  113. + private Calendar NextEvent;
  114. + private final SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  115. +
  116. + public static InitialPartyFarm getInstance()
  117. + {
  118. + if (_instance == null)
  119. + {
  120. + _instance = new InitialPartyFarm();
  121. + }
  122. + return _instance;
  123. + }
  124. +
  125. + public String getRestartNextTime()
  126. + {
  127. + if (NextEvent.getTime() != null)
  128. + {
  129. + return format.format(NextEvent.getTime());
  130. + }
  131. + return "Erro";
  132. + }
  133. +
  134. + public void StartCalculationOfNextEventTime()
  135. + {
  136. + try
  137. + {
  138. + Calendar currentTime = Calendar.getInstance();
  139. + Calendar testStartTime = null;
  140. + long flush2 = 0L;
  141. + long timeL = 0L;
  142. + int count = 0;
  143. + for (String timeOfDay : Config.EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY)
  144. + {
  145. + testStartTime = Calendar.getInstance();
  146. + testStartTime.setLenient(true);
  147. + String[] splitTimeOfDay = timeOfDay.split(":");
  148. + testStartTime.set(11, Integer.parseInt(splitTimeOfDay[0]));
  149. + testStartTime.set(12, Integer.parseInt(splitTimeOfDay[1]));
  150. + testStartTime.set(13, 0);
  151. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  152. + {
  153. + testStartTime.add(5, 1);
  154. + }
  155. + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
  156. + if (count == 0)
  157. + {
  158. + flush2 = timeL;
  159. + NextEvent = testStartTime;
  160. + }
  161. + if (timeL < flush2)
  162. + {
  163. + flush2 = timeL;
  164. + NextEvent = testStartTime;
  165. + }
  166. + count++;
  167. + }
  168. + _log.info("[Party Farm]: Proximo Evento: " + NextEvent.getTime().toString());
  169. + ThreadPool.schedule(new StartEventTask(), flush2);
  170. + }
  171. + catch (Exception e)
  172. + {
  173. + System.out.println("[Party Farm]: Algum erro nas config foi encontrado!");
  174. + }
  175. + }
  176. +
  177. + class StartEventTask implements Runnable
  178. + {
  179. + StartEventTask()
  180. + {
  181. + }
  182. +
  183. + @Override
  184. + public void run()
  185. + {
  186. + InitialPartyFarm._log.info("[Party Farm]: Event Started.");
  187. + PartyFarm.bossSpawnMonster();
  188. + }
  189. + }
  190. +}
  191. \ No newline at end of file
  192. diff --git a/java/Dev/Events/PartyFarm/PartyFarm.java b/java/Dev/Events/PartyFarm/PartyFarm.java
  193. new file mode 100644
  194. index 0000000..4f0a5c0
  195. --- /dev/null
  196. +++ b/java/Dev/Events/PartyFarm/PartyFarm.java
  197. @@ -0,0 +1,179 @@
  198. +package Dev.Events.PartyFarm;
  199. +
  200. +import java.util.ArrayList;
  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.handler.admincommandhandlers.AdminCustom;
  206. +import net.sf.l2j.gameserver.model.World;
  207. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  208. +import net.sf.l2j.gameserver.model.spawn.L2Spawn;
  209. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  210. +
  211. +
  212. +public class PartyFarm
  213. +{
  214. + public static L2Spawn _monster;
  215. + public static int _bossHeading = 0;
  216. + public static String _eventName = "";
  217. + public static boolean _started = false;
  218. + public static boolean _aborted = false;
  219. + protected static boolean _finish = false;
  220. + static PartyFarm _instance;
  221. +
  222. + public static void bossSpawnMonster()
  223. + {
  224. + spawnMonsters();
  225. +
  226. + World.gameAnnounceToOnlinePlayers("Teleport Now!");
  227. + World.gameAnnounceToOnlinePlayers("[Party Farm]: Duration: " + Config.EVENT_BEST_FARM_TIME + " minute(s)!");
  228. + _aborted = false;
  229. + _started = true;
  230. +
  231. + waiter(Config.EVENT_BEST_FARM_TIME * 60 * 1000);
  232. + if (!_aborted)
  233. + {
  234. + Finish_Event();
  235. + }
  236. + }
  237. +
  238. + public static void Finish_Event()
  239. + {
  240. + unSpawnMonsters();
  241. +
  242. + _started = false;
  243. + _finish = true;
  244. +
  245. + World.gameAnnounceToOnlinePlayers("[Party Farm]: Finished!");
  246. + if (!AdminCustom._bestfarm_manual)
  247. + {
  248. + InitialPartyFarm.getInstance().StartCalculationOfNextEventTime();
  249. + }
  250. + else
  251. + {
  252. + AdminCustom._bestfarm_manual = false;
  253. + }
  254. + }
  255. +
  256. + public static void spawnMonsters()
  257. + {
  258. + for (int i = 0; i < Config.MONSTER_LOCS_COUNT; i++)
  259. + {
  260. + int[] coord = Config.MONSTER_LOCS[i];
  261. + monsters.add(spawnNPC(coord[0], coord[1], coord[2], Config.monsterId));
  262. + }
  263. + }
  264. +
  265. + public static boolean is_started()
  266. + {
  267. + return _started;
  268. + }
  269. +
  270. + public static boolean is_finish()
  271. + {
  272. + return _finish;
  273. + }
  274. +
  275. + protected static L2Spawn spawnNPC(int xPos, int yPos, int zPos, int npcId)
  276. + {
  277. + NpcTemplate template = NpcData.getInstance().getTemplate(npcId);
  278. + try
  279. + {
  280. + L2Spawn spawn = new L2Spawn(template);
  281. + spawn.setLoc(xPos, yPos, zPos, 0);
  282. + spawn.setRespawnDelay(Config.PARTY_FARM_MONSTER_DALAY);
  283. +
  284. + SpawnTable.getInstance().addSpawn(spawn, false);
  285. +
  286. + spawn.setRespawnState(true);
  287. + spawn.doSpawn(false);
  288. + spawn.getNpc().isAggressive();
  289. + spawn.getNpc().decayMe();
  290. + spawn.getNpc().spawnMe(spawn.getNpc().getX(), spawn.getNpc().getY(), spawn.getNpc().getZ());
  291. + spawn.getNpc().broadcastPacket(new MagicSkillUse(spawn.getNpc(), spawn.getNpc(), 1034, 1, 1, 1));
  292. + return spawn;
  293. + }
  294. + catch (Exception e)
  295. + {
  296. + }
  297. + return null;
  298. + }
  299. +
  300. + protected static ArrayList<L2Spawn> monsters = new ArrayList<>();
  301. +
  302. + protected static void unSpawnMonsters()
  303. + {
  304. + for (L2Spawn s : monsters)
  305. + {
  306. + if (s == null)
  307. + {
  308. + monsters.remove(s);
  309. + return;
  310. + }
  311. +
  312. + s.getNpc().deleteMe();
  313. + s.setRespawnState(false);
  314. + SpawnTable.getInstance().deleteSpawn(s, true);
  315. +
  316. + }
  317. + }
  318. +
  319. + protected static void waiter(long interval)
  320. + {
  321. + long startWaiterTime = System.currentTimeMillis();
  322. + int seconds = (int) (interval / 1000L);
  323. + while ((startWaiterTime + interval > System.currentTimeMillis()) && (!_aborted))
  324. + {
  325. + seconds--;
  326. + switch (seconds)
  327. + {
  328. + case 3600:
  329. + if (_started)
  330. + {
  331. +
  332. + World.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds / 60 / 60 + " hour(s) till event finish!");
  333. + }
  334. + break;
  335. + case 60:
  336. + case 120:
  337. + case 180:
  338. + case 240:
  339. + case 300:
  340. + case 600:
  341. + case 900:
  342. + case 1800:
  343. + if (_started)
  344. + {
  345. +
  346. + World.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds / 60 + " minute(s) till event finish!");
  347. + }
  348. + break;
  349. + case 1:
  350. + case 2:
  351. + case 3:
  352. + case 10:
  353. + case 15:
  354. + case 30:
  355. + if (_started)
  356. + {
  357. + World.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds + " second(s) till event finish!");
  358. + }
  359. + break;
  360. + }
  361. + long startOneSecondWaiterStartTime = System.currentTimeMillis();
  362. + while (startOneSecondWaiterStartTime + 1000L > System.currentTimeMillis())
  363. + {
  364. + try
  365. + {
  366. + Thread.sleep(1L);
  367. + }
  368. + catch (InterruptedException ie)
  369. + {
  370. + ie.printStackTrace();
  371. + }
  372. + }
  373. + }
  374. + }
  375. +
  376. +}
  377. \ No newline at end of file
  378. diff --git a/java/Dev/Events/PartyFarm/PartyZoneReward.java b/java/Dev/Events/PartyFarm/PartyZoneReward.java
  379. new file mode 100644
  380. index 0000000..2a721d5
  381. --- /dev/null
  382. +++ b/java/Dev/Events/PartyFarm/PartyZoneReward.java
  383. @@ -0,0 +1,97 @@
  384. +package Dev.Events.PartyFarm;
  385. +
  386. +import java.util.HashMap;
  387. +import java.util.List;
  388. +import java.util.logging.Logger;
  389. +
  390. +import net.sf.l2j.commons.random.Rnd;
  391. +
  392. +import net.sf.l2j.Config;
  393. +import net.sf.l2j.gameserver.model.actor.Creature;
  394. +import net.sf.l2j.gameserver.model.actor.Npc;
  395. +import net.sf.l2j.gameserver.model.actor.Playable;
  396. +import net.sf.l2j.gameserver.model.actor.Player;
  397. +
  398. +public class PartyZoneReward
  399. +{
  400. + protected static final Logger _log = Logger.getLogger(PartyZoneReward.class.getName());
  401. +
  402. + protected PartyZoneReward()
  403. + {
  404. + }
  405. +
  406. + private static boolean _canReward = false;
  407. + private static HashMap<String, Integer> _playerHwids = new HashMap<>();
  408. +
  409. + // Give Reward
  410. + public final static void addPartyZoneReward(Creature killer, Npc monster)
  411. + {
  412. + if (killer instanceof Playable)
  413. + {
  414. + Player player = killer.getActingPlayer();
  415. +
  416. + if (player.isInParty())
  417. + {
  418. + List<Player> party = player.getParty().getMembers();
  419. +
  420. + for (Player member : party)
  421. + {
  422. + //String pHwid = member.getHWID();
  423. + String pHwid = member.getClient().getConnection().getInetAddress().getHostAddress();
  424. + if (!_playerHwids.containsKey(pHwid) || Config.ENABLE_DUALBOX_PARTYFARM)
  425. + {
  426. + _playerHwids.put(pHwid, 1);
  427. + _canReward = true;
  428. + }
  429. + else
  430. + {
  431. + int count = _playerHwids.get(pHwid);
  432. +
  433. + if (count < 1)
  434. + {
  435. + _playerHwids.remove(pHwid);
  436. + _playerHwids.put(pHwid, count + 1);
  437. + _canReward = true;
  438. + }
  439. + else
  440. + {
  441. + member.sendMessage("You are Other PC Reward.");
  442. + _canReward = false;
  443. + }
  444. + }
  445. + if (_canReward)
  446. + {
  447. + if (member.isInsideRadius(monster.getX(), monster.getY(), monster.getZ(), 1000, false, false))
  448. + RandomReward(member);
  449. + else
  450. + member.sendMessage("You are too far from your party to be rewarded.");
  451. + }
  452. + }
  453. + _playerHwids.clear();
  454. + }
  455. + else
  456. + RandomReward(player);
  457. + }
  458. + }
  459. +
  460. + public static void RandomReward(Player player)
  461. + {
  462. + for (RewardHolder reward : Config.PARTY_ZONE_REWARDS)
  463. + {
  464. + if (Rnd.get(100) <= reward.getRewardChance())
  465. + {
  466. + player.addItem("Random Reward", reward.getRewardId(), Rnd.get(reward.getRewardMin(), reward.getRewardMax()), player, true);
  467. + }
  468. + }
  469. + }
  470. +
  471. + public static final PartyZoneReward getInstance()
  472. + {
  473. + return SingletonHolder._instance;
  474. + }
  475. +
  476. + private static class SingletonHolder
  477. + {
  478. + protected static final PartyZoneReward _instance = new PartyZoneReward();
  479. + }
  480. +}
  481. \ No newline at end of file
  482. diff --git a/java/Dev/Events/PartyFarm/RewardHolder.java b/java/Dev/Events/PartyFarm/RewardHolder.java
  483. new file mode 100644
  484. index 0000000..9540a78
  485. --- /dev/null
  486. +++ b/java/Dev/Events/PartyFarm/RewardHolder.java
  487. @@ -0,0 +1,76 @@
  488. +package Dev.Events.PartyFarm;
  489. +
  490. +public class RewardHolder
  491. +{
  492. + private int _id;
  493. + private int _min;
  494. + private int _max;
  495. + private int _chance;
  496. +
  497. + /**
  498. + * @param rewardId
  499. + * @param rewardMin
  500. + * @param rewardMax
  501. + */
  502. + public RewardHolder(int rewardId, int rewardMin, int rewardMax)
  503. + {
  504. + _id = rewardId;
  505. + _min = rewardMin;
  506. + _max = rewardMax;
  507. + _chance = 100;
  508. + }
  509. +
  510. + /**
  511. + * @param rewardId
  512. + * @param rewardMin
  513. + * @param rewardMax
  514. + * @param rewardChance
  515. + */
  516. + public RewardHolder(int rewardId, int rewardMin, int rewardMax, int rewardChance)
  517. + {
  518. + _id = rewardId;
  519. + _min = rewardMin;
  520. + _max = rewardMax;
  521. + _chance = rewardChance;
  522. + }
  523. +
  524. + public int getRewardId()
  525. + {
  526. + return _id;
  527. + }
  528. +
  529. + public int getRewardMin()
  530. + {
  531. + return _min;
  532. + }
  533. +
  534. + public int getRewardMax()
  535. + {
  536. + return _max;
  537. + }
  538. +
  539. + public int getRewardChance()
  540. + {
  541. + return _chance;
  542. + }
  543. +
  544. + public void setId(int id)
  545. + {
  546. + _id = id;
  547. + }
  548. +
  549. + public void setMin(int min)
  550. + {
  551. + _min = min;
  552. + }
  553. +
  554. + public void setMax(int max)
  555. + {
  556. + _max = max;
  557. + }
  558. +
  559. + public void setChance(int chance)
  560. + {
  561. + _chance = chance;
  562. + }
  563. +}
  564. \ No newline at end of file
  565. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  566. index 4b7181f..632fe49 100644
  567. --- a/java/net/sf/l2j/Config.java
  568. +++ b/java/net/sf/l2j/Config.java
  569. @@ -18,6 +18,8 @@
  570.  
  571. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  572.  
  573. +import Dev.Events.PartyFarm.RewardHolder;
  574.  
  575. /**
  576. * This class contains global server configuration.<br>
  577. * It has static final fields initialized from configuration files.
  578. @@ -35,7 +37,7 @@
  579. public static final String PLAYERS_FILE = "./config/players.properties";
  580. public static final String SERVER_FILE = "./config/server.properties";
  581. public static final String SIEGE_FILE = "./config/siege.properties";
  582. + public static final String PARTY_FILE = "./config/PartyFarm.properties";
  583. // --------------------------------------------------
  584. // Clans settings
  585. // --------------------------------------------------
  586. @@ -462,6 +464,26 @@
  587. public static int ATTACKERS_RESPAWN_DELAY;
  588.  
  589. + // --------------------------------------------------
  590. + // Party Farm
  591. + // --------------------------------------------------
  592. +
  593. + public static int EVENT_BEST_FARM_TIME;
  594. + public static String[] EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY;
  595. + public static int PARTY_FARM_MONSTER_DALAY;
  596. + public static String PARTY_FARM_MESSAGE_TEXT;
  597. + public static int PARTY_FARM_MESSAGE_TIME;
  598. + public static int monsterId;
  599. + public static int MONSTER_LOCS_COUNT;
  600. + public static int[][] MONSTER_LOCS;
  601. + public static boolean PARTY_MESSAGE_ENABLED;
  602. + public static boolean ENABLE_DUALBOX_PARTYFARM;
  603. + public static boolean PARTY_FARM_BY_TIME_OF_DAY;
  604. + public static boolean START_PARTY;
  605. + public static String PART_ZONE_MONSTERS_EVENT;
  606. + public static List<Integer> PART_ZONE_MONSTERS_EVENT_ID;
  607. + public static List<RewardHolder> PARTY_ZONE_REWARDS = new ArrayList<>();
  608. +
  609. // --------------------------------------------------
  610. // Server
  611. // --------------------------------------------------
  612.  
  613. @@ -1089,6 +1111,65 @@
  614. }
  615.  
  616. + /**
  617. + * Loads Party Farm settings.
  618. + */
  619. +
  620. + private static final void loadPtFarm()
  621. + {
  622. + final ExProperties BestFarm = initProperties(Config.PARTY_FILE);
  623. +
  624. + PART_ZONE_MONSTERS_EVENT = BestFarm.getProperty("PartyEventMonster");
  625. + PART_ZONE_MONSTERS_EVENT_ID = new ArrayList<>();
  626. + for (String id : PART_ZONE_MONSTERS_EVENT.split(","))
  627. + PART_ZONE_MONSTERS_EVENT_ID.add(Integer.parseInt(id));
  628. + PARTY_ZONE_REWARDS = parseReward(BestFarm, "PartyZoneReward");
  629. +
  630. + PARTY_FARM_MONSTER_DALAY = Integer.parseInt(BestFarm.getProperty("MonsterDelay", "10"));
  631. + PARTY_FARM_BY_TIME_OF_DAY = Boolean.parseBoolean(BestFarm.getProperty("PartyFarmEventEnabled", "false"));
  632. + START_PARTY = Boolean.parseBoolean(BestFarm.getProperty("StartSpawnPartyFarm", "false"));
  633. + ENABLE_DUALBOX_PARTYFARM = Boolean.parseBoolean(BestFarm.getProperty("RenewalDualBoxPTFarm", "false"));
  634. + EVENT_BEST_FARM_TIME = Integer.parseInt(BestFarm.getProperty("EventBestFarmTime", "1"));
  635. + EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY = BestFarm.getProperty("BestFarmStartTime", "20:00").split(",");
  636. + PARTY_MESSAGE_ENABLED = Boolean.parseBoolean(BestFarm.getProperty("ScreenPartyMessageEnable", "false"));
  637. + PARTY_FARM_MESSAGE_TEXT = BestFarm.getProperty("ScreenPartyFarmMessageText", "Welcome to l2j server!");
  638. + PARTY_FARM_MESSAGE_TIME = Integer.parseInt(BestFarm.getProperty("ScreenPartyFarmMessageTime", "10")) * 1000;
  639. +
  640. + String[] monsterLocs2 = BestFarm.getProperty("MonsterLoc", "").split(";");
  641. + String[] locSplit3 = null;
  642. +
  643. + monsterId = Integer.parseInt(BestFarm.getProperty("MonsterId", "1"));
  644. +
  645. + MONSTER_LOCS_COUNT = monsterLocs2.length;
  646. + MONSTER_LOCS = new int[MONSTER_LOCS_COUNT][3];
  647. + int g;
  648. + for (int e = 0; e < MONSTER_LOCS_COUNT; e++)
  649. + {
  650. + locSplit3 = monsterLocs2[e].split(",");
  651. + for (g = 0; g < 3; g++)
  652. + {
  653. + MONSTER_LOCS[e][g] = Integer.parseInt(locSplit3[g].trim());
  654. + }
  655. + }
  656. + }
  657. +
  658. + public static List<RewardHolder> parseReward(Properties propertie, String configName)
  659. + {
  660. + List<RewardHolder> auxReturn = new ArrayList<>();
  661. +
  662. + String aux = propertie.getProperty(configName).trim();
  663. + for (String randomReward : aux.split(";"))
  664. + {
  665. + final String[] infos = randomReward.split(",");
  666. +
  667. + if (infos.length > 3)
  668. + auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2]), Integer.valueOf(infos[3])));
  669. + else
  670. + auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2])));
  671. + }
  672. + return auxReturn;
  673. + }
  674. +
  675. /**
  676. * Loads siege settings.
  677. */
  678. private static final void loadSieges()
  679. @@ -1307,6 +1388,9 @@
  680. // siege settings
  681. loadSieges();
  682.  
  683. + // party farm settings
  684. + loadPtFarm();
  685. +
  686. // server settings
  687. loadServer();
  688. }
  689. diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
  690. index 41a9f92..952d76a 100644
  691. --- a/java/net/sf/l2j/gameserver/GameServer.java
  692. +++ b/java/net/sf/l2j/gameserver/GameServer.java
  693. @@ -102,6 +102,10 @@
  694. import net.sf.l2j.util.DeadLockDetector;
  695. import net.sf.l2j.util.IPv4Filter;
  696.  
  697. +import Dev.Events.PartyFarm.InitialPartyFarm;
  698. +import Dev.Events.PartyFarm.PartyFarm;
  699. +import Dev.Events.PartyFarm.PartyZoneReward;
  700. +
  701. public class GameServer
  702. {
  703. private static final CLogger LOGGER = new CLogger(GameServer.class.getName());
  704. @@ -214,7 +218,34 @@
  705. RandomAnimationTaskManager.getInstance();
  706. ShadowItemTaskManager.getInstance();
  707. WaterTaskManager.getInstance();
  708. + PartyZoneReward.getInstance();
  709. + class SpawnMonsters implements Runnable
  710. + {
  711. + public SpawnMonsters()
  712. + {
  713. + }
  714. +
  715. + @Override
  716. + public void run()
  717. + {
  718. + PartyFarm._aborted = false;
  719. + PartyFarm._started = true;
  720. +
  721. + PartyFarm.spawnMonsters();
  722. + }
  723. +
  724. + }
  725. + StringUtil.printSection("Party Farm Events");
  726. + if ((Config.PARTY_FARM_BY_TIME_OF_DAY) && (!Config.START_PARTY))
  727. + {
  728. + InitialPartyFarm.getInstance().StartCalculationOfNextEventTime();
  729. + LOGGER.info("[Party Farm Time]: Enabled");
  730. + }
  731. + else if ((Config.START_PARTY) && (!Config.PARTY_FARM_BY_TIME_OF_DAY))
  732. + {
  733. + LOGGER.info("[Start Spawn Party Farm]: Enabled");
  734. + ThreadPool.schedule(new SpawnMonsters(), 1000L);
  735. + }
  736. StringUtil.printSection("Auto Spawns");
  737. AutoSpawnTable.getInstance();
  738.  
  739. @@ -258,7 +289,6 @@
  740. BoatRunePrimeval.load();
  741. BoatTalkingGludin.load();
  742. }
  743. StringUtil.printSection("Events");
  744. DerbyTrackManager.getInstance();
  745. LotteryManager.getInstance();
  746. diff --git a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  747. index 7d72334..a8b1dce 100644
  748. --- a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  749. +++ b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  750. @@ -12,6 +12,7 @@
  751. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminClanHall;
  752. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCreateItem;
  753. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
  754. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCustom;
  755. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminDelete;
  756. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminDoorControl;
  757. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEditChar;
  758. @@ -53,6 +54,7 @@
  759.  
  760. protected AdminCommandHandler()
  761. {
  762. + registerHandler(new AdminCustom());
  763. registerHandler(new AdminAdmin());
  764. registerHandler(new AdminAnnouncements());
  765. registerHandler(new AdminBan());
  766. diff --git a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCustom.java b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCustom.java
  767. new file mode 100644
  768. index 0000000..99e74ce
  769. --- /dev/null
  770. +++ b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCustom.java
  771. @@ -0,0 +1,86 @@
  772. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  773. +
  774. +import java.util.logging.Logger;
  775. +
  776. +import net.sf.l2j.commons.concurrent.ThreadPool;
  777. +
  778. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  779. +import net.sf.l2j.gameserver.model.actor.Player;
  780. +
  781. +import Dev.Events.PartyFarm.PartyFarm;
  782. +
  783. +public class AdminCustom implements IAdminCommandHandler
  784. +{
  785. +
  786. + private static final String[] ADMIN_COMMANDS =
  787. + {
  788. + "admin_tour",
  789. + "admin_ptfarm"
  790. +
  791. + };
  792. +
  793. + protected static final Logger _log = Logger.getLogger(AdminCustom.class.getName());
  794. + public static boolean _arena_manual = false;
  795. + public static boolean _bestfarm_manual = false;
  796. +
  797. + @Override
  798. + public boolean useAdminCommand(String command, Player activeChar)
  799. + {
  800. + if (command.equals("admin_ptfarm"))
  801. + {
  802. + if (PartyFarm._started)
  803. + {
  804. + _log.info("----------------------------------------------------------------------------");
  805. + _log.info("[Party Farm]: Event Finished.");
  806. + _log.info("----------------------------------------------------------------------------");
  807. + PartyFarm._aborted = true;
  808. + finishEventPartyFarm();
  809. +
  810. + activeChar.sendMessage("SYS: Voce Finalizou o Party Farm Manualmente..");
  811. + }
  812. + else
  813. + {
  814. + _log.info("----------------------------------------------------------------------------");
  815. + _log.info("[Party Farm]: Event Started.");
  816. + _log.info("----------------------------------------------------------------------------");
  817. + initEventPartyFarm();
  818. + _bestfarm_manual = true;
  819. + activeChar.sendMessage("SYS: Voce ativou o Best Farm Manualmente..");
  820. + }
  821. + }
  822. + return true;
  823. + }
  824. +
  825. + private static void initEventPartyFarm()
  826. + {
  827. + ThreadPool.schedule(new Runnable()
  828. + {
  829. + @Override
  830. + public void run()
  831. + {
  832. +
  833. + PartyFarm.bossSpawnMonster();
  834. + }
  835. + }, 1L);
  836. + }
  837. +
  838. + private static void finishEventPartyFarm()
  839. + {
  840. + ThreadPool.schedule(new Runnable()
  841. + {
  842. + @Override
  843. + public void run()
  844. + {
  845. +
  846. + PartyFarm.Finish_Event();
  847. +
  848. + }
  849. + }, 1L);
  850. + }
  851. +
  852. + @Override
  853. + public String[] getAdminCommandList()
  854. + {
  855. + return ADMIN_COMMANDS;
  856. + }
  857. +}
  858. \ No newline at end of file
  859. diff --git a/java/net/sf/l2j/gameserver/model/World.java b/java/net/sf/l2j/gameserver/model/World.java
  860. index a2feebc..14ab8c4 100644
  861. --- a/java/net/sf/l2j/gameserver/model/World.java
  862. +++ b/java/net/sf/l2j/gameserver/model/World.java
  863. @@ -250,7 +250,10 @@
  864. {
  865. toAllOnlinePlayers(new CreatureSay(0, (critical) ? Say2.CRITICAL_ANNOUNCE : Say2.ANNOUNCEMENT, "", text));
  866. }
  867. + public static void gameAnnounceToOnlinePlayers(String text)
  868. + {
  869. + toAllOnlinePlayers(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "", text));
  870. + }
  871. public static World getInstance()
  872. {
  873. return SingletonHolder.INSTANCE;
  874. diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java b/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java
  875. index 22f8b21..6607601 100644
  876. --- a/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java
  877. +++ b/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java
  878. @@ -35,6 +35,8 @@
  879. import net.sf.l2j.gameserver.network.SystemMessageId;
  880. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  881.  
  882. +import Dev.Events.PartyFarm.PartyZoneReward;
  883. +
  884. /**
  885. * A monster extends {@link Attackable} class.<br>
  886. * <br>
  887. @@ -1091,7 +1093,8 @@
  888. final Player player = mainDamageDealer.getActingPlayer();
  889. if (player == null)
  890. return;
  891. + if (Config.PART_ZONE_MONSTERS_EVENT_ID.contains(Integer.valueOf(npcTemplate.getNpcId())))
  892. + PartyZoneReward.addPartyZoneReward(player, this);
  893. // level modifier in %'s (will be subtracted from drop chance)
  894. final int levelModifier = calculateLevelModifierForDrop(player);
  895.  
  896. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  897. index 9e45695..0977fdd 100644
  898. --- a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  899. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  900. @@ -37,6 +37,7 @@
  901. import net.sf.l2j.gameserver.network.GameClient.GameClientState;
  902. import net.sf.l2j.gameserver.network.SystemMessageId;
  903. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  904. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  905. import net.sf.l2j.gameserver.network.serverpackets.Die;
  906. import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
  907. import net.sf.l2j.gameserver.network.serverpackets.ExMailArrived;
  908. @@ -59,6 +60,8 @@
  909. import net.sf.l2j.gameserver.scripting.QuestState;
  910. import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager;
  911.  
  912. +import Dev.Events.PartyFarm.PartyFarm;
  913. +
  914. public class EnterWorld extends L2GameClientPacket
  915. {
  916. private static final String LOAD_PLAYER_QUESTS = "SELECT name,var,value FROM character_quests WHERE charId=?";
  917. @@ -208,6 +211,11 @@
  918. player.sendPacket(SevenSignsManager.getInstance().getCurrentPeriod().getMessageId());
  919. AnnouncementData.getInstance().showAnnouncements(player, false);
  920.  
  921. + if ((PartyFarm.is_started()) && (Config.PARTY_FARM_BY_TIME_OF_DAY))
  922. + {
  923. + player.sendPacket(new CreatureSay(0, 3, ".", "" + Config.PARTY_FARM_MESSAGE_TEXT + ":."));
  924. + }
  925. +
  926. // if player is DE, check for shadow sense skill at night
  927. if (player.getRace() == ClassRace.DARK_ELF && player.hasSkill(L2Skill.SKILL_SHADOW_SENSE))
  928. player.sendPacket(SystemMessage.getSystemMessage((GameTimeTaskManager.getInstance().isNight()) ? SystemMessageId.NIGHT_S1_EFFECT_APPLIES : SystemMessageId.DAY_S1_EFFECT_DISAPPEARS).addSkillName(L2Skill.SKILL_SHADOW_SENSE));
  929.  
Add Comment
Please, Sign In to add comment