Advertisement
Sarada-L2

Trocar Periodo Olympiadas L2jLisvus C4

Mar 1st, 2023
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.77 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P core
  3. diff --git java/config/Olympiad.properties
  4. index 5c25403..d0c9afb 100644
  5. --- java/config/Olympiad.properties
  6. +++ java/config/Olympiad.properties
  7. @@ -12,40 +12,50 @@
  8.  
  9. # Olympiad Battle Period, Default 3 minutes. (If set different, should be < AltOlyBWait)
  10. AltOlyBattle = 180000
  11.  
  12. # Olympiad Battle Wait, Default 10 Minutes
  13. AltOlyBWait = 600000
  14.  
  15. # Olympiad Initial Wait Period, Default 5 minutes
  16. AltOlyIWait = 300000
  17.  
  18. # Olympiad Weekly Period, Default 1 week
  19. AltOlyWPeriod = 604800000
  20.  
  21. # Olympiad Validation Period, Default 24 Hours.
  22. AltOlyVPeriod = 86400000
  23.  
  24. # Required number of participants for Classed and Non-Classed matches, Default 5 & 9
  25. AltOlyClassedParticipants = 5
  26. AltOlyNonClassedParticipants = 9
  27.  
  28. +#======================================================================================================
  29. +# Trocar Periodo Olympiadas
  30. +#======================================================================================================
  31. +# Voce pode decidir se habilitar o recurso de configurasao de periodo personalizado. Uma vez ativado,
  32. +# Periodo Alt Oly: MONTH / DAY / WEEK
  33. +# es. 2 semanas -> AltOlyPeriod = WEEK e AltOlyPeriodMultiplier = 2
  34. +AltOlyUseCustomPeriodSettings= True
  35. +AltOlyPeriod = DAY
  36. +AltOlyPeriodMultiplier = 15
  37.  
  38. # Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
  39. # 0 for displaying digits instead of text phrase (old style).
  40. # Default: 10
  41. AltOlyRegistrationDisplayNumber = 10
  42.  
  43. # Olympiad battle winner reward for Class and Non_Class games.
  44. # Retail 6651(Gate Pass)
  45. AltOlyBattleRewItem = 6651
  46. # Retail 50 per winning
  47. AltOlyClassedRewItemCount = 50
  48. # Retail 30 per winning
  49. AltOlyNonClassedRewItemCount = 30
  50.  
  51. # Olympiad Competition Rewards
  52. # ItemId for this Reward, Retail 6651(Gate Pass)
  53. AltOlyCompRewItem = 6651
  54. # Rate to exchange Points to Reward item, Retail 1 Point * 1000
  55. AltOlyGPPerPoint = 1000
  56.  
  57. # Noblesse points awarded to Heros. Retail 300
  58. diff --git java/net/sf/l2j/Config.java
  59. index a600870..0542bc5 100644
  60. --- java/net/sf/l2j/Config.java
  61. +++ java/net/sf/l2j/Config.java
  62. @@ -15,40 +15,41 @@
  63. package net.sf.l2j;
  64.  
  65. import java.io.File;
  66. import java.io.FileInputStream;
  67. import java.io.FileOutputStream;
  68. import java.io.InputStream;
  69. import java.io.OutputStream;
  70. import java.math.BigInteger;
  71. import java.nio.file.Path;
  72. import java.nio.file.Paths;
  73. import java.util.ArrayList;
  74. import java.util.HashMap;
  75. import java.util.List;
  76. import java.util.Map;
  77. import java.util.Properties;
  78. import java.util.StringTokenizer;
  79. import java.util.logging.Logger;
  80.  
  81. import net.sf.l2j.gameserver.model.L2World;
  82. import net.sf.l2j.gameserver.model.base.Experience;
  83. +import net.sf.l2j.gameserver.model.olympiad.OlympiadPeriod;
  84. import net.sf.l2j.gameserver.util.FloodProtectorConfig;
  85. import net.sf.l2j.util.StringUtil;
  86.  
  87. /**
  88. * This class contains global server configuration.<br>
  89. * It has static final fields initialized from configuration files.<br>
  90. * It's initialized at the very begin of startup, and later JIT will optimize away debug/unused code.
  91. * @author mkizub
  92. */
  93. public final class Config
  94. {
  95. private final static Logger _log = Logger.getLogger(Config.class.getName());
  96.  
  97. /** Properties file for access level configurations */
  98. public static final String ACCESS_LEVELS_FILE = "./config/AccessLevels.properties";
  99. /** Properties file for alternative configurations */
  100. public static final String ALT_SETTINGS_FILE = "./config/AltSettings.properties";
  101. /** Properties file for custom configurations */
  102. public static final String CUSTOM_FILE = "./config/Custom.properties";
  103. /** Properties file for events configurations */
  104. @@ -321,40 +322,44 @@
  105. public static int ALT_CHANNEL_ACTIVATION_COUNT;
  106.  
  107. /** Alternative gaming - all new characters always are newbies. */
  108. public static boolean ALT_GAME_NEW_CHAR_ALWAYS_IS_NEWBIE;
  109. /** Newbie level range. */
  110. public static byte ALT_MIN_NEWBIE_LEVEL;
  111. public static byte ALT_MAX_NEWBIE_LEVEL;
  112.  
  113. /** Spell Book needed to learn skill */
  114. public static boolean SP_BOOK_NEEDED;
  115. /** Spell Book needet to enchant skill */
  116. public static boolean ES_SP_BOOK_NEEDED;
  117. /** Logging Chat Window */
  118. public static boolean LOG_CHAT;
  119. /** Logging Item Window */
  120. public static boolean LOG_ITEMS;
  121.  
  122. /** Olympiad Competition Starting time */
  123. public static int ALT_OLY_START_TIME;
  124.  
  125. + public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
  126. + public static OlympiadPeriod ALT_OLY_PERIOD;
  127. + public static int ALT_OLY_PERIOD_MULTIPLIER;
  128.  
  129. /** Olympiad Minutes */
  130. public static int ALT_OLY_MIN;
  131.  
  132. /** Olympiad Competition Period */
  133. public static long ALT_OLY_CPERIOD;
  134.  
  135. /** Olympiad Battle Period */
  136. public static long ALT_OLY_BATTLE;
  137.  
  138. /** Olympiad Battle Wait */
  139. public static long ALT_OLY_BWAIT;
  140.  
  141. /** Olympiad Inital Wait */
  142. public static long ALT_OLY_IWAIT;
  143.  
  144. /** Olympiad Weekly Period */
  145. public static long ALT_OLY_WPERIOD;
  146.  
  147. /** Olympiad Validation Period */
  148. public static long ALT_OLY_VPERIOD;
  149. @@ -1905,41 +1910,43 @@
  150. RIFT_AUTO_JUMPS_TIME_MAX = Integer.parseInt(altSettings.getProperty("AutoJumpsDelayMax", "600"));
  151. RIFT_ENTER_COST_RECRUIT = Integer.parseInt(altSettings.getProperty("RecruitCost", "18"));
  152. RIFT_ENTER_COST_SOLDIER = Integer.parseInt(altSettings.getProperty("SoldierCost", "21"));
  153. RIFT_ENTER_COST_OFFICER = Integer.parseInt(altSettings.getProperty("OfficerCost", "24"));
  154. RIFT_ENTER_COST_CAPTAIN = Integer.parseInt(altSettings.getProperty("CaptainCost", "27"));
  155. RIFT_ENTER_COST_COMMANDER = Integer.parseInt(altSettings.getProperty("CommanderCost", "30"));
  156. RIFT_ENTER_COST_HERO = Integer.parseInt(altSettings.getProperty("HeroCost", "33"));
  157. RIFT_BOSS_ROOM_TIME_MULTIPLIER = Float.parseFloat(altSettings.getProperty("BossRoomTimeMultiplier", "1.5"));
  158.  
  159. // Olympiad settings
  160. Properties olympiadSettings = new Properties();
  161. try (InputStream is = new FileInputStream(new File(OLYMPIAD_FILE)))
  162. {
  163. olympiadSettings.load(is);
  164. }
  165. catch (Exception e)
  166. {
  167. e.printStackTrace();
  168. throw new Error("Failed to Load " + OLYMPIAD_FILE + " File.");
  169. }
  170. + ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Boolean.parseBoolean(olympiadSettings.getProperty("AltOlyUseCustomPeriodSettings", "false"));
  171. + ALT_OLY_PERIOD = OlympiadPeriod.valueOf(olympiadSettings.getProperty("AltOlyPeriod", "MONTH"));
  172. + ALT_OLY_PERIOD_MULTIPLIER = Integer.parseInt(olympiadSettings.getProperty("AltOlyPeriodMultiplier", "1"));
  173. ALT_OLY_START_TIME = Integer.parseInt(olympiadSettings.getProperty("AltOlyStartTime", "20"));
  174. ALT_OLY_MIN = Integer.parseInt(olympiadSettings.getProperty("AltOlyMin", "00"));
  175. ALT_OLY_CPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyCPeriod", "14400000"));
  176. ALT_OLY_BATTLE = Long.parseLong(olympiadSettings.getProperty("AltOlyBattle", "180000"));
  177. ALT_OLY_BWAIT = Long.parseLong(olympiadSettings.getProperty("AltOlyBWait", "600000"));
  178. ALT_OLY_IWAIT = Long.parseLong(olympiadSettings.getProperty("AltOlyIWait", "300000"));
  179. ALT_OLY_WPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyWPeriod", "604800000"));
  180. ALT_OLY_VPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyVPeriod", "86400000"));
  181. ALT_OLY_CLASSED = Integer.parseInt(olympiadSettings.getProperty("AltOlyClassedParticipants", "5"));
  182. ALT_OLY_REG_DISPLAY = Integer.parseInt(olympiadSettings.getProperty("AltOlyRegistrationDisplayNumber","10"));
  183. ALT_OLY_NONCLASSED = Integer.parseInt(olympiadSettings.getProperty("AltOlyNonClassedParticipants", "9"));
  184. ALT_OLY_BATTLE_REWARD_ITEM = Integer.parseInt(olympiadSettings.getProperty("AltOlyBattleRewItem", "6651"));
  185. ALT_OLY_CLASSED_RITEM_C = Integer.parseInt(olympiadSettings.getProperty("AltOlyClassedRewItemCount", "50"));
  186. ALT_OLY_NONCLASSED_RITEM_C = Integer.parseInt(olympiadSettings.getProperty("AltOlyNonClassedRewItemCount", "30"));
  187. ALT_OLY_COMP_RITEM = Integer.parseInt(olympiadSettings.getProperty("AltOlyCompRewItem", "6651"));
  188. ALT_OLY_GP_PER_POINT = Integer.parseInt(olympiadSettings.getProperty("AltOlyGPPerPoint", "1000"));
  189. ALT_OLY_HERO_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyHeroPoints", "300"));
  190. ALT_OLY_RANK1_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyRank1Points", "100"));
  191. ALT_OLY_RANK2_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyRank2Points", "75"));
  192. ALT_OLY_RANK3_POINTS = Integer.parseInt(olympiadSettings.getProperty("AltOlyRank3Points", "55"));
  193. diff --git java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  194. index 42e27b2..872b93f 100644
  195. --- java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  196. +++ java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  197. @@ -700,40 +700,46 @@
  198. if (_scheduledOlympiadEnd != null)
  199. _scheduledOlympiadEnd.cancel(true);
  200.  
  201. _scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(), 0);
  202. }
  203.  
  204. protected long getMillisToValidationEnd()
  205. {
  206. if (_validationEnd > Calendar.getInstance().getTimeInMillis())
  207. return (_validationEnd - Calendar.getInstance().getTimeInMillis());
  208. return 10L;
  209. }
  210.  
  211. public boolean isOlympiadEnd()
  212. {
  213. return (_period != 0);
  214. }
  215.  
  216. protected void setNewOlympiadEnd()
  217. {
  218. + if (Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
  219. + {
  220. + setNewOlympiadEndCustom();
  221. + return;
  222. + }
  223. SystemMessage sm = new SystemMessage(SystemMessage.OLYMPIAD_PERIOD_S1_HAS_STARTED);
  224. sm.addNumber(_currentCycle);
  225.  
  226. Announcements.getInstance().announceToAll(sm);
  227.  
  228. Calendar currentTime = Calendar.getInstance();
  229. currentTime.add(Calendar.MONTH, 1);
  230. currentTime.set(Calendar.DAY_OF_MONTH, 1);
  231. currentTime.set(Calendar.AM_PM, Calendar.AM);
  232. currentTime.set(Calendar.HOUR, 12);
  233. currentTime.set(Calendar.MINUTE, 0);
  234. currentTime.set(Calendar.SECOND, 0);
  235. _olympiadEnd = currentTime.getTimeInMillis();
  236.  
  237. Calendar nextChange = Calendar.getInstance();
  238. _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
  239. scheduleWeeklyChange();
  240. }
  241.  
  242. public byte getCompPeriodState()
  243. @@ -763,40 +769,46 @@
  244.  
  245. _log.info("Olympiad System: New Schedule @ " + _compStart.getTime());
  246.  
  247. return (_compStart.getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
  248. }
  249.  
  250. protected long getMillisToCompEnd()
  251. {
  252. return (_compEnd - Calendar.getInstance().getTimeInMillis());
  253. }
  254.  
  255. private long getMillisToWeekChange()
  256. {
  257. if (_nextWeeklyChange > Calendar.getInstance().getTimeInMillis())
  258. return (_nextWeeklyChange - Calendar.getInstance().getTimeInMillis());
  259. return 10L;
  260. }
  261.  
  262. private void scheduleWeeklyChange()
  263. {
  264. + if (Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
  265. + {
  266. + schedulePointsRestoreCustom();
  267. + return;
  268. + }
  269. _scheduledWeeklyTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  270. {
  271. @Override
  272. public void run()
  273. {
  274. addWeeklyPoints();
  275. _log.info("Olympiad System: Added weekly points to nobles");
  276.  
  277. Calendar nextChange = Calendar.getInstance();
  278. _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
  279. }
  280. }, getMillisToWeekChange(), WEEKLY_PERIOD);
  281. }
  282.  
  283. protected synchronized void addWeeklyPoints()
  284. {
  285. if (_period == 1)
  286. return;
  287.  
  288. for (Integer nobleId : _nobles.keySet())
  289. @@ -1307,26 +1319,144 @@
  290.  
  291. spectator.sendPacket(new ExOlympiadUserInfo(player));
  292.  
  293. ExOlympiadSpelledInfo os = new ExOlympiadSpelledInfo(player);
  294.  
  295. // Get all player effects
  296. L2Effect[] effects = player.getAllEffects();
  297. for (L2Effect e : effects)
  298. {
  299. if (e == null || !e.getShowIcon())
  300. continue;
  301.  
  302. if (e.getInUse())
  303. {
  304. e.addOlympiadSpelledIcon(os);
  305. }
  306. }
  307. spectator.sendPacket(os);
  308. }
  309. }
  310. + protected void setNewOlympiadEndCustom()
  311. + {
  312. + SystemMessage sm = new SystemMessage(SystemMessage.OLYMPIAD_PERIOD_S1_HAS_STARTED);
  313. + sm.addNumber(_currentCycle);
  314. +
  315. + Calendar currentTime = Calendar.getInstance();
  316. + currentTime.set(Calendar.AM_PM, Calendar.AM);
  317. + currentTime.set(Calendar.HOUR, 12);
  318. + currentTime.set(Calendar.MINUTE, 0);
  319. + currentTime.set(Calendar.SECOND, 0);
  320. +
  321. + Calendar nextChange = Calendar.getInstance();
  322. +
  323. + switch (Config.ALT_OLY_PERIOD)
  324. + {
  325. + case DAY:
  326. + {
  327. + currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
  328. + currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
  329. +
  330. + if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
  331. + {
  332. + _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
  333. + }
  334. + else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
  335. + {
  336. + _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
  337. + }
  338. + else
  339. + {
  340. + // nothing to do, too low period
  341. + }
  342. +
  343. + }
  344. + break;
  345. + case WEEK:
  346. + {
  347. + currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
  348. + currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
  349. +
  350. + if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
  351. + {
  352. + _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
  353. + }
  354. + else
  355. + {
  356. + _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
  357. + }
  358. +
  359. + }
  360. + break;
  361. + case MONTH:
  362. + {
  363. + currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
  364. + currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
  365. +
  366. + _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
  367. +
  368. + }
  369. + break;
  370. + }
  371. +
  372. + _olympiadEnd = currentTime.getTimeInMillis();
  373. +
  374. + scheduleWeeklyChange();
  375. + }
  376. + private void schedulePointsRestoreCustom()
  377. + {
  378. + long final_change_period = WEEKLY_PERIOD;
  379. +
  380. + switch (Config.ALT_OLY_PERIOD)
  381. + {
  382. + case DAY:
  383. + {
  384. +
  385. + if (Config.ALT_OLY_PERIOD_MULTIPLIER < 10)
  386. + {
  387. +
  388. + final_change_period = WEEKLY_PERIOD / 2;
  389. +
  390. + }
  391. +
  392. + }
  393. + break;
  394. + case WEEK:
  395. + {
  396. +
  397. + if (Config.ALT_OLY_PERIOD_MULTIPLIER == 1)
  398. + {
  399. + final_change_period = WEEKLY_PERIOD / 2;
  400. + }
  401. +
  402. + }
  403. + break;
  404. + }
  405. +
  406. + _scheduledWeeklyTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new OlympiadPointsRestoreTask(final_change_period), getMillisToWeekChange(), final_change_period);
  407. + }
  408. + class OlympiadPointsRestoreTask implements Runnable
  409. + {
  410. +
  411. + private long restoreTime;
  412. +
  413. + public OlympiadPointsRestoreTask(long restoreTime)
  414. + {
  415. + this.restoreTime = restoreTime;
  416. + }
  417. +
  418. + @Override
  419. + public void run()
  420. + {
  421. + addWeeklyPoints();
  422. + _log.info("Olympiad System: Added points to nobles");
  423. +
  424. + Calendar nextChange = Calendar.getInstance();
  425. + _nextWeeklyChange = nextChange.getTimeInMillis() + restoreTime;
  426. + }
  427. +
  428. + }
  429. private static class SingletonHolder
  430. {
  431. protected static final Olympiad _instance = new Olympiad();
  432. }
  433. }
  434. \ No newline at end of file
  435. diff --git java/net/sf/l2j/gameserver/model/olympiad/OlympiadPeriod.java
  436. new file mode 100644
  437. index 0000000..c3759af
  438. --- /dev/null
  439. +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadPeriod.java
  440. @@ -0,0 +1,6 @@
  441. +package net.sf.l2j.gameserver.model.olympiad;
  442. +
  443. +public enum OlympiadPeriod
  444. +{
  445. + MONTH,WEEK,DAY
  446. +}
  447. \ No newline at end of file
  448.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement