Advertisement
Sarada-L2

Party Farm para Frozen

Apr 26th, 2021
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.71 KB | None | 0 0
  1. diff --git a/config/CustomMods/Events/PartyFarm.ini b/config/CustomMods/Events/PartyFarm.ini
  2. new file mode 100644
  3. index 0000000..bb00eed
  4. --- /dev/null
  5. +++ b/config/CustomMods/Events/PartyFarm.ini
  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/head-src/Dev/Events/PartyFarm/InitialPartyFarm.java b/head-src/Dev/Events/PartyFarm/InitialPartyFarm.java
  94. new file mode 100644
  95. index 0000000..b072f0a
  96. --- /dev/null
  97. +++ b/head-src/Dev/Events/PartyFarm/InitialPartyFarm.java
  98. @@ -0,0 +1,91 @@
  99. +package Dev.Events.PartyFarm;
  100. +
  101. +import com.l2jfrozen.Config;
  102. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  103. +
  104. +import java.text.SimpleDateFormat;
  105. +import java.util.Calendar;
  106. +import java.util.logging.Logger;
  107. +
  108. +public class InitialPartyFarm
  109. +{
  110. + private static InitialPartyFarm _instance = null;
  111. + protected static final Logger _log = Logger.getLogger(InitialPartyFarm.class.getName());
  112. + private Calendar NextEvent;
  113. + private final SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  114. +
  115. + public static InitialPartyFarm getInstance()
  116. + {
  117. + if (_instance == null)
  118. + {
  119. + _instance = new InitialPartyFarm();
  120. + }
  121. + return _instance;
  122. + }
  123. +
  124. + public String getRestartNextTime()
  125. + {
  126. + if (NextEvent.getTime() != null)
  127. + {
  128. + return format.format(NextEvent.getTime());
  129. + }
  130. + return "Erro";
  131. + }
  132. +
  133. + public void StartCalculationOfNextEventTime()
  134. + {
  135. + try
  136. + {
  137. + Calendar currentTime = Calendar.getInstance();
  138. + Calendar testStartTime = null;
  139. + long flush2 = 0L;
  140. + long timeL = 0L;
  141. + int count = 0;
  142. + for (String timeOfDay : Config.EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY)
  143. + {
  144. + testStartTime = Calendar.getInstance();
  145. + testStartTime.setLenient(true);
  146. + String[] splitTimeOfDay = timeOfDay.split(":");
  147. + testStartTime.set(11, Integer.parseInt(splitTimeOfDay[0]));
  148. + testStartTime.set(12, Integer.parseInt(splitTimeOfDay[1]));
  149. + testStartTime.set(13, 0);
  150. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  151. + {
  152. + testStartTime.add(5, 1);
  153. + }
  154. + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
  155. + if (count == 0)
  156. + {
  157. + flush2 = timeL;
  158. + NextEvent = testStartTime;
  159. + }
  160. + if (timeL < flush2)
  161. + {
  162. + flush2 = timeL;
  163. + NextEvent = testStartTime;
  164. + }
  165. + count++;
  166. + }
  167. + _log.info("[Party Farm]: Proximo Evento: " + NextEvent.getTime().toString());
  168. + ThreadPoolManager.getInstance().scheduleGeneral(new StartEventTask(), flush2);
  169. + }
  170. + catch (Exception e)
  171. + {
  172. + System.out.println("[Party Farm]: Algum erro nas config foi encontrado!");
  173. + }
  174. + }
  175. +
  176. + class StartEventTask implements Runnable
  177. + {
  178. + StartEventTask()
  179. + {
  180. + }
  181. +
  182. + @Override
  183. + public void run()
  184. + {
  185. + InitialPartyFarm._log.info("[Party Farm]: Event Started.");
  186. + PartyFarm.bossSpawnMonster();
  187. + }
  188. + }
  189. +}
  190. diff --git a/head-src/Dev/Events/PartyFarm/PartyFarm.java b/head-src/Dev/Events/PartyFarm/PartyFarm.java
  191. new file mode 100644
  192. index 0000000..f023a55
  193. --- /dev/null
  194. +++ b/head-src/Dev/Events/PartyFarm/PartyFarm.java
  195. @@ -0,0 +1,180 @@
  196. +package Dev.Events.PartyFarm;
  197. +
  198. +import com.l2jfrozen.Config;
  199. +import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
  200. +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable;
  201. +import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCustom;
  202. +import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
  203. +import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
  204. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  205. +import com.l2jfrozen.gameserver.util.Broadcast;
  206. +
  207. +import java.util.ArrayList;
  208. +
  209. +
  210. +public class PartyFarm
  211. +{
  212. + public static L2Spawn _monster;
  213. + public static int _bossHeading = 0;
  214. + public static String _eventName = "";
  215. + public static boolean _started = false;
  216. + public static boolean _aborted = false;
  217. + protected static boolean _finish = false;
  218. + static PartyFarm _instance;
  219. +
  220. + public static void bossSpawnMonster()
  221. + {
  222. + spawnMonsters();
  223. +
  224. + Broadcast.gameAnnounceToOnlinePlayers("Teleport Now!");
  225. + Broadcast.gameAnnounceToOnlinePlayers("[Party Farm]: Duration: " + Config.EVENT_BEST_FARM_TIME + " minute(s)!");
  226. + _aborted = false;
  227. + _started = true;
  228. +
  229. + waiter(Config.EVENT_BEST_FARM_TIME * 60 * 1000);
  230. + if (!_aborted)
  231. + {
  232. + Finish_Event();
  233. + }
  234. + }
  235. +
  236. + public static void Finish_Event()
  237. + {
  238. + unSpawnMonsters();
  239. +
  240. + _started = false;
  241. + _finish = true;
  242. +
  243. + Broadcast.gameAnnounceToOnlinePlayers("[Party Farm]: Finished!");
  244. + if (!AdminCustom._bestfarm_manual)
  245. + {
  246. + InitialPartyFarm.getInstance().StartCalculationOfNextEventTime();
  247. + }
  248. + else
  249. + {
  250. + AdminCustom._bestfarm_manual = false;
  251. + }
  252. + }
  253. +
  254. + public static void spawnMonsters()
  255. + {
  256. + for (int i = 0; i < Config.MONSTER_LOCS_COUNT; i++)
  257. + {
  258. + int[] coord = Config.MONSTER_LOCS[i];
  259. + monsters.add(spawnNPC(coord[0], coord[1], coord[2], Config.monsterId));
  260. + }
  261. + }
  262. +
  263. + public static boolean is_started()
  264. + {
  265. + return _started;
  266. + }
  267. +
  268. + public static boolean is_finish()
  269. + {
  270. + return _finish;
  271. + }
  272. +
  273. + protected static L2Spawn spawnNPC(int xPos, int yPos, int zPos, int npcId)
  274. + {
  275. + L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
  276. + try
  277. + {
  278. + L2Spawn spawn = new L2Spawn(template);
  279. + spawn.setLocx(xPos);
  280. + spawn.setLocy(yPos);
  281. + spawn.setLocz(zPos);
  282. + spawn.setHeading(0);
  283. + spawn.setRespawnDelay(Config.PARTY_FARM_MONSTER_DALAY);
  284. + spawn.setAmount(1);
  285. + SpawnTable.getInstance().addNewSpawn(spawn, false);
  286. + spawn.doSpawn();
  287. + spawn.startRespawn();
  288. + spawn.getLastSpawn().isAggressive();
  289. + spawn.getLastSpawn().decayMe();
  290. + spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
  291. + spawn.getLastSpawn().broadcastPacket(new MagicSkillUser(spawn.getLastSpawn(), spawn.getLastSpawn(), 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. + s.getLastSpawn().deleteMe();
  312. + s.stopRespawn();
  313. + SpawnTable.getInstance().deleteSpawn(s, true);
  314. +
  315. + }
  316. + }
  317. +
  318. + protected static void waiter(long interval)
  319. + {
  320. + long startWaiterTime = System.currentTimeMillis();
  321. + int seconds = (int) (interval / 1000L);
  322. + while ((startWaiterTime + interval > System.currentTimeMillis()) && (!_aborted))
  323. + {
  324. + seconds--;
  325. + switch (seconds)
  326. + {
  327. + case 3600:
  328. + if (_started)
  329. + {
  330. +
  331. + Broadcast.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds / 60 / 60 + " hour(s) till event finish!");
  332. + }
  333. + break;
  334. + case 60:
  335. + case 120:
  336. + case 180:
  337. + case 240:
  338. + case 300:
  339. + case 600:
  340. + case 900:
  341. + case 1800:
  342. + if (_started)
  343. + {
  344. +
  345. + Broadcast.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds / 60 + " minute(s) till event finish!");
  346. + }
  347. + break;
  348. + case 1:
  349. + case 2:
  350. + case 3:
  351. + case 10:
  352. + case 15:
  353. + case 30:
  354. + if (_started)
  355. + {
  356. + Broadcast.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds + " second(s) till event finish!");
  357. + }
  358. + break;
  359. + }
  360. + long startOneSecondWaiterStartTime = System.currentTimeMillis();
  361. + while (startOneSecondWaiterStartTime + 1000L > System.currentTimeMillis())
  362. + {
  363. + try
  364. + {
  365. + Thread.sleep(1L);
  366. + }
  367. + catch (InterruptedException ie)
  368. + {
  369. + ie.printStackTrace();
  370. + }
  371. + }
  372. + }
  373. + }
  374. +
  375. +}
  376. \ No newline at end of file
  377. diff --git a/head-src/Dev/Events/PartyFarm/PartyZoneReward.java b/head-src/Dev/Events/PartyFarm/PartyZoneReward.java
  378. new file mode 100644
  379. index 0000000..0f5ae13
  380. --- /dev/null
  381. +++ b/head-src/Dev/Events/PartyFarm/PartyZoneReward.java
  382. @@ -0,0 +1,101 @@
  383. +package Dev.Events.PartyFarm;
  384. +
  385. +import com.l2jfrozen.Config;
  386. +import com.l2jfrozen.gameserver.model.L2Character;
  387. +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance;
  388. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  389. +import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
  390. +import com.l2jfrozen.util.random.Rnd;
  391. +
  392. +import java.util.HashMap;
  393. +import java.util.List;
  394. +import java.util.logging.Logger;
  395. +
  396. +
  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(L2Character killer, L2NpcInstance monster)
  411. + {
  412. + if (killer instanceof L2PlayableInstance)
  413. + {
  414. + L2PcInstance player = killer.getActingPlayer();
  415. +
  416. + if (player.isInParty())
  417. + {
  418. + List<L2PcInstance> party = player.getParty().getPartyMembers();
  419. +
  420. + for (L2PcInstance 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(L2PcInstance player)
  461. + {
  462. + for (RewardHolder reward : Config.PARTY_ZONE_REWARDS)
  463. + {
  464. + if (Rnd.get(100) <= reward.getRewardChance())
  465. + {
  466. + //if (player.isVip())
  467. + // player.addItem("Random Reward", reward.getRewardId(), Rnd.get(reward.getRewardMin(), reward.getRewardMax()) * Config.VIP_DROP_RATE, player, true);
  468. + //else
  469. + player.addItem("Random Reward", reward.getRewardId(), Rnd.get(reward.getRewardMin(), reward.getRewardMax()), player, true);
  470. + }
  471. + }
  472. + }
  473. +
  474. + public static final PartyZoneReward getInstance()
  475. + {
  476. + return SingletonHolder._instance;
  477. + }
  478. +
  479. + private static class SingletonHolder
  480. + {
  481. + protected static final PartyZoneReward _instance = new PartyZoneReward();
  482. + }
  483. +}
  484. \ No newline at end of file
  485. diff --git a/head-src/Dev/Events/PartyFarm/RewardHolder.java b/head-src/Dev/Events/PartyFarm/RewardHolder.java
  486. new file mode 100644
  487. index 0000000..9540a78
  488. --- /dev/null
  489. +++ b/head-src/Dev/Events/PartyFarm/RewardHolder.java
  490. @@ -0,0 +1,76 @@
  491. +package Dev.Events.PartyFarm;
  492. +
  493. +public class RewardHolder
  494. +{
  495. + private int _id;
  496. + private int _min;
  497. + private int _max;
  498. + private int _chance;
  499. +
  500. + /**
  501. + * @param rewardId
  502. + * @param rewardMin
  503. + * @param rewardMax
  504. + */
  505. + public RewardHolder(int rewardId, int rewardMin, int rewardMax)
  506. + {
  507. + _id = rewardId;
  508. + _min = rewardMin;
  509. + _max = rewardMax;
  510. + _chance = 100;
  511. + }
  512. +
  513. + /**
  514. + * @param rewardId
  515. + * @param rewardMin
  516. + * @param rewardMax
  517. + * @param rewardChance
  518. + */
  519. + public RewardHolder(int rewardId, int rewardMin, int rewardMax, int rewardChance)
  520. + {
  521. + _id = rewardId;
  522. + _min = rewardMin;
  523. + _max = rewardMax;
  524. + _chance = rewardChance;
  525. + }
  526. +
  527. + public int getRewardId()
  528. + {
  529. + return _id;
  530. + }
  531. +
  532. + public int getRewardMin()
  533. + {
  534. + return _min;
  535. + }
  536. +
  537. + public int getRewardMax()
  538. + {
  539. + return _max;
  540. + }
  541. +
  542. + public int getRewardChance()
  543. + {
  544. + return _chance;
  545. + }
  546. +
  547. + public void setId(int id)
  548. + {
  549. + _id = id;
  550. + }
  551. +
  552. + public void setMin(int min)
  553. + {
  554. + _min = min;
  555. + }
  556. +
  557. + public void setMax(int max)
  558. + {
  559. + _max = max;
  560. + }
  561. +
  562. + public void setChance(int chance)
  563. + {
  564. + _chance = chance;
  565. + }
  566. +}
  567. \ No newline at end of file
  568. diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
  569. index e41a7fe..5a759eb 100644
  570. --- a/head-src/com/l2jfrozen/Config.java
  571. +++ b/head-src/com/l2jfrozen/Config.java
  572. @@ -51,10 +51,94 @@
  573. import com.l2jfrozen.loginserver.LoginController;
  574. import com.l2jfrozen.util.StringUtil;
  575.  
  576. +import Dev.Events.PartyFarm.RewardHolder;
  577. +
  578. public final class Config
  579. {
  580. private static final Logger LOGGER = Logger.getLogger(Config.class);
  581.  
  582. + //============================================================
  583. + public static int EVENT_BEST_FARM_TIME;
  584. + public static String[] EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY;
  585. + public static int PARTY_FARM_MONSTER_DALAY;
  586. + public static String PARTY_FARM_MESSAGE_TEXT;
  587. + public static int PARTY_FARM_MESSAGE_TIME;
  588. + public static int monsterId;
  589. + public static int MONSTER_LOCS_COUNT;
  590. + public static int[][] MONSTER_LOCS;
  591. + public static boolean PARTY_MESSAGE_ENABLED;
  592. + public static boolean ENABLE_DUALBOX_PARTYFARM;
  593. + public static boolean PARTY_FARM_BY_TIME_OF_DAY;
  594. + public static boolean START_PARTY;
  595. + public static String PART_ZONE_MONSTERS_EVENT;
  596. + public static List<Integer> PART_ZONE_MONSTERS_EVENT_ID;
  597. + public static List<RewardHolder> PARTY_ZONE_REWARDS = new ArrayList<>();
  598. + //============================================================
  599. + public static void loadPTFARMConfig()
  600. + {
  601. + final String FILENAME = "./config/CustomMods/Events/PartyFarm.ini";
  602. + try
  603. + {
  604. + Properties BestFarm = new Properties();
  605. + InputStream is = new FileInputStream(new File(FILENAME));
  606. + BestFarm.load(is);
  607. + is.close();
  608. + PART_ZONE_MONSTERS_EVENT = BestFarm.getProperty("PartyEventMonster");
  609. + PART_ZONE_MONSTERS_EVENT_ID = new ArrayList<>();
  610. + for (String id : PART_ZONE_MONSTERS_EVENT.split(","))
  611. + PART_ZONE_MONSTERS_EVENT_ID.add(Integer.parseInt(id));
  612. + PARTY_ZONE_REWARDS = parseReward(BestFarm, "PartyZoneReward");
  613. +
  614. + PARTY_FARM_MONSTER_DALAY = Integer.parseInt(BestFarm.getProperty("MonsterDelay", "10"));
  615. + PARTY_FARM_BY_TIME_OF_DAY = Boolean.parseBoolean(BestFarm.getProperty("PartyFarmEventEnabled", "false"));
  616. + START_PARTY = Boolean.parseBoolean(BestFarm.getProperty("StartSpawnPartyFarm", "false"));
  617. + ENABLE_DUALBOX_PARTYFARM = Boolean.parseBoolean(BestFarm.getProperty("RenewalDualBoxPTFarm", "false"));
  618. + EVENT_BEST_FARM_TIME = Integer.parseInt(BestFarm.getProperty("EventBestFarmTime", "1"));
  619. + EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY = BestFarm.getProperty("BestFarmStartTime", "20:00").split(",");
  620. + PARTY_MESSAGE_ENABLED = Boolean.parseBoolean(BestFarm.getProperty("ScreenPartyMessageEnable", "false"));
  621. + PARTY_FARM_MESSAGE_TEXT = BestFarm.getProperty("ScreenPartyFarmMessageText", "Welcome to l2j server!");
  622. + PARTY_FARM_MESSAGE_TIME = Integer.parseInt(BestFarm.getProperty("ScreenPartyFarmMessageTime", "10")) * 1000;
  623. +
  624. + String[] monsterLocs2 = BestFarm.getProperty("MonsterLoc", "").split(";");
  625. + String[] locSplit3 = null;
  626. +
  627. + monsterId = Integer.parseInt(BestFarm.getProperty("MonsterId", "1"));
  628. +
  629. + MONSTER_LOCS_COUNT = monsterLocs2.length;
  630. + MONSTER_LOCS = new int[MONSTER_LOCS_COUNT][3];
  631. + int g;
  632. + for (int e = 0; e < MONSTER_LOCS_COUNT; e++)
  633. + {
  634. + locSplit3 = monsterLocs2[e].split(",");
  635. + for (g = 0; g < 3; g++)
  636. + {
  637. + MONSTER_LOCS[e][g] = Integer.parseInt(locSplit3[g].trim());
  638. + }
  639. + }
  640. +
  641. + }
  642. + catch(Exception e)
  643. + {
  644. + e.printStackTrace();
  645. + throw new Error("Failed to Load " + FILENAME + " File.");
  646. + }
  647. + }
  648. + public static List<RewardHolder> parseReward(Properties propertie, String configName)
  649. + {
  650. + List<RewardHolder> auxReturn = new ArrayList<>();
  651. +
  652. + String aux = propertie.getProperty(configName).trim();
  653. + for (String randomReward : aux.split(";"))
  654. + {
  655. + final String[] infos = randomReward.split(",");
  656. +
  657. + if (infos.length > 3)
  658. + auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2]), Integer.valueOf(infos[3])));
  659. + else
  660. + auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2])));
  661. + }
  662. + return auxReturn;
  663. + }
  664. // ============================================================
  665. public static boolean EVERYBODY_HAS_ADMIN_RIGHTS;
  666. public static boolean SHOW_GM_LOGIN;
  667. @@ -4464,6 +4548,7 @@
  668. loadAccessConfig();
  669. loadPvpConfig();
  670. loadCraftConfig();
  671. + loadPTFARMConfig();
  672.  
  673. // Frozen config
  674. loadCTFConfig();
  675. diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
  676. index 703cfea..885d57f 100644
  677. --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
  678. +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
  679. @@ -152,6 +152,10 @@
  680. import com.l2jfrozen.util.Util;
  681. import com.l2jfrozen.util.database.L2DatabaseFactory;
  682.  
  683. +import Dev.Events.PartyFarm.InitialPartyFarm;
  684. +import Dev.Events.PartyFarm.PartyFarm;
  685. +import Dev.Events.PartyFarm.PartyZoneReward;
  686. +
  687. public class GameServer
  688. {
  689. private static Logger LOGGER = Logger.getLogger("Loader");
  690. @@ -245,7 +249,23 @@
  691. CharNameTable.getInstance();
  692. ExperienceData.getInstance();
  693. DuelManager.getInstance();
  694. + PartyZoneReward.getInstance();
  695. + class SpawnMonsters implements Runnable
  696. + {
  697. + public SpawnMonsters()
  698. + {
  699. + }
  700. +
  701. + @Override
  702. + public void run()
  703. + {
  704. + PartyFarm._aborted = false;
  705. + PartyFarm._started = true;
  706. +
  707. + PartyFarm.spawnMonsters();
  708. + }
  709.  
  710. + }
  711. if (Config.ENABLE_CLASS_DAMAGES)
  712. ClassDamageManager.loadConfig();
  713.  
  714. @@ -545,6 +565,16 @@
  715. LOGGER.info("All custom mods are Disabled.");
  716.  
  717. Util.printSection("EventManager");
  718. + if ((Config.PARTY_FARM_BY_TIME_OF_DAY) && (!Config.START_PARTY))
  719. + {
  720. + InitialPartyFarm.getInstance().StartCalculationOfNextEventTime();
  721. + LOGGER.info("[Party Farm Time]: Enabled");
  722. + }
  723. + else if ((Config.START_PARTY) && (!Config.PARTY_FARM_BY_TIME_OF_DAY))
  724. + {
  725. + LOGGER.info("[Start Spawn Party Farm]: Enabled");
  726. + ThreadPoolManager.getInstance().scheduleGeneral(new SpawnMonsters(), 1000L);
  727. + }
  728. EventManager.getInstance().startEventRegistration();
  729.  
  730. if (EventManager.TVT_EVENT_ENABLED || EventManager.CTF_EVENT_ENABLED || EventManager.DM_EVENT_ENABLED)
  731. diff --git a/head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java b/head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java
  732. index 6983b78..109411a 100644
  733. --- a/head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java
  734. +++ b/head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java
  735. @@ -41,6 +41,7 @@
  736. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminChristmas;
  737. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCreateItem;
  738. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
  739. +import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCustom;
  740. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminDMEngine;
  741. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminDelete;
  742. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminDonator;
  743. @@ -120,6 +121,7 @@
  744. private AdminCommandHandler()
  745. {
  746. _datatable = new FastMap<>();
  747. + registerAdminCommandHandler(new AdminCustom());
  748. registerAdminCommandHandler(new AdminAdmin());
  749. registerAdminCommandHandler(new AdminInvul());
  750. registerAdminCommandHandler(new AdminDelete());
  751. diff --git a/head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminCustom.java b/head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminCustom.java
  752. new file mode 100644
  753. index 0000000..5ccc07d
  754. --- /dev/null
  755. +++ b/head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminCustom.java
  756. @@ -0,0 +1,146 @@
  757. +package com.l2jfrozen.gameserver.handler.admincommandhandlers;
  758. +
  759. +import java.util.logging.Logger;
  760. +
  761. +import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
  762. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  763. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  764. +
  765. +import Dev.Events.PartyFarm.PartyFarm;
  766. +//import Dev.Tournament.properties.ArenaTask;
  767. +//import Dev.Tournament.properties.ArenaTask;
  768. +
  769. +public class AdminCustom implements IAdminCommandHandler
  770. +{
  771. +
  772. + private static final String[] ADMIN_COMMANDS =
  773. + {
  774. + "admin_tour",
  775. + "admin_ptfarm"
  776. +
  777. + };
  778. +
  779. + protected static final Logger _log = Logger.getLogger(AdminCustom.class.getName());
  780. + public static boolean _arena_manual = false;
  781. + public static boolean _bestfarm_manual = false;
  782. +
  783. + @Override
  784. + public boolean useAdminCommand(String command, L2PcInstance activeChar)
  785. + {
  786. +
  787. +
  788. + /*if (command.equals("admin_tour"))
  789. + {
  790. + if (ArenaTask._started)
  791. + {
  792. + _log.info("----------------------------------------------------------------------------");
  793. + _log.info("[Tournament]: Event Finished.");
  794. + _log.info("----------------------------------------------------------------------------");
  795. + ArenaTask._aborted = true;
  796. + finishEventArena();
  797. + _arena_manual = true;
  798. +
  799. + activeChar.sendMessage("SYS: Voce Finalizou o evento Tournament Manualmente..");
  800. + }
  801. + else
  802. + {
  803. + _log.info("----------------------------------------------------------------------------");
  804. + _log.info("[Tournament]: Event Started.");
  805. + _log.info("----------------------------------------------------------------------------");
  806. + initEventArena();
  807. + _arena_manual = true;
  808. + activeChar.sendMessage("SYS: Voce ativou o evento Tournament Manualmente..");
  809. + }
  810. +
  811. + return true;
  812. + }*/
  813. + if (command.equals("admin_ptfarm"))
  814. + {
  815. + if (PartyFarm._started)
  816. + {
  817. + _log.info("----------------------------------------------------------------------------");
  818. + _log.info("[Party Farm]: Event Finished.");
  819. + _log.info("----------------------------------------------------------------------------");
  820. + PartyFarm._aborted = true;
  821. + finishEventPartyFarm();
  822. +
  823. + activeChar.sendMessage("SYS: Voce Finalizou o Party Farm Manualmente..");
  824. + }
  825. + else
  826. + {
  827. + _log.info("----------------------------------------------------------------------------");
  828. + _log.info("[Party Farm]: Event Started.");
  829. + _log.info("----------------------------------------------------------------------------");
  830. + initEventPartyFarm();
  831. + _bestfarm_manual = true;
  832. + activeChar.sendMessage("SYS: Voce ativou o Best Farm Manualmente..");
  833. + }
  834. + }
  835. + return true;
  836. +
  837. + }
  838. +
  839. +
  840. + private static void initEventPartyFarm()
  841. + {
  842. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  843. + {
  844. + @Override
  845. + public void run()
  846. + {
  847. +
  848. + PartyFarm.bossSpawnMonster();
  849. + }
  850. + }, 1L);
  851. + }
  852. +
  853. + private static void finishEventPartyFarm()
  854. + {
  855. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  856. + {
  857. + @Override
  858. + public void run()
  859. + {
  860. +
  861. + PartyFarm.Finish_Event();
  862. +
  863. + }
  864. + }, 1L);
  865. + }
  866. +
  867. +
  868. + /*private static void initEventArena()
  869. + {
  870. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  871. + {
  872. + @Override
  873. + public void run()
  874. + {
  875. +
  876. + ArenaTask.SpawnEvent();
  877. + }
  878. + }, 10L);
  879. + }
  880. +
  881. + private static void finishEventArena()
  882. + {
  883. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  884. + {
  885. + @Override
  886. + public void run()
  887. + {
  888. +
  889. + ArenaTask.finishEvent();
  890. + }
  891. + }, 10L);
  892. + }*/
  893. +
  894. +
  895. +
  896. +
  897. + @Override
  898. + public String[] getAdminCommandList()
  899. + {
  900. + return ADMIN_COMMANDS;
  901. + }
  902. +}
  903. \ No newline at end of file
  904. diff --git a/head-src/com/l2jfrozen/gameserver/model/L2Attackable.java b/head-src/com/l2jfrozen/gameserver/model/L2Attackable.java
  905. index ddadde1..a1d51cd 100644
  906. --- a/head-src/com/l2jfrozen/gameserver/model/L2Attackable.java
  907. +++ b/head-src/com/l2jfrozen/gameserver/model/L2Attackable.java
  908. @@ -67,6 +67,8 @@
  909. import com.l2jfrozen.gameserver.util.Util;
  910. import com.l2jfrozen.util.random.Rnd;
  911.  
  912. +import Dev.Events.PartyFarm.PartyZoneReward;
  913. +
  914. /**
  915. * This class manages all NPC that can be attacked.<BR>
  916. * <BR>
  917. @@ -1833,7 +1835,8 @@
  918. // Don't drop anything if the last attacker or ownere isn't L2PcInstance
  919. if (player == null)
  920. return;
  921. -
  922. + if (Config.PART_ZONE_MONSTERS_EVENT_ID.contains(Integer.valueOf(npcTemplate.getNpcId())))
  923. + PartyZoneReward.addPartyZoneReward(player, this);
  924. final int levelModifier = calculateLevelModifierForDrop(player); // level modifier in %'s (will be subtracted from drop chance)
  925.  
  926. // Check the drop of a cursed weapon
  927. diff --git a/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java b/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
  928. index c443f3f..7f6e7fa 100644
  929. --- a/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
  930. +++ b/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
  931. @@ -97,6 +97,8 @@
  932. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  933. import com.l2jfrozen.gameserver.util.Util;
  934.  
  935. +import Dev.Events.PartyFarm.PartyFarm;
  936. +
  937. /**
  938. * Enter World Packet Handler
  939. */
  940. @@ -281,7 +283,10 @@
  941.  
  942. SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
  943. Announcements.getInstance().showAnnouncements(activeChar);
  944. -
  945. + if ((PartyFarm.is_started()) && (Config.PARTY_FARM_BY_TIME_OF_DAY))
  946. + {
  947. + activeChar.sendPacket(new CreatureSay(0, 3, ".", "" + Config.PARTY_FARM_MESSAGE_TEXT + ":."));
  948. + }
  949. loadTutorial(activeChar);
  950.  
  951. // Check for crowns
  952. diff --git a/head-src/com/l2jfrozen/gameserver/util/Broadcast.java b/head-src/com/l2jfrozen/gameserver/util/Broadcast.java
  953. index 6a4ad16..d861b38 100644
  954. --- a/head-src/com/l2jfrozen/gameserver/util/Broadcast.java
  955. +++ b/head-src/com/l2jfrozen/gameserver/util/Broadcast.java
  956. @@ -38,7 +38,9 @@
  957. import com.l2jfrozen.gameserver.model.L2Character;
  958. import com.l2jfrozen.gameserver.model.L2World;
  959. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  960. +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
  961. import com.l2jfrozen.gameserver.network.serverpackets.CharInfo;
  962. +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
  963. import com.l2jfrozen.gameserver.network.serverpackets.L2GameServerPacket;
  964. import com.l2jfrozen.gameserver.network.serverpackets.RelationChanged;
  965.  
  966. @@ -237,4 +239,9 @@
  967. onlinePlayer.sendPacket(mov);
  968. }
  969. }
  970. +
  971. + public static void gameAnnounceToOnlinePlayers(String text)
  972. + {
  973. + toAllOnlinePlayers(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "", text));
  974. + }
  975. }
  976.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement