xRelic

Announce olympiad end season (on enter)

Jul 6th, 2021 (edited)
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. ===================================================================
  3. --- config/frozen.properties (revision 5)
  4. +++ config/frozen.properties (working copy)
  5. @@ -80,6 +80,10 @@
  6. #---------------------------------------
  7. # Announce olympiad end on enter world.
  8. #---------------------------------------
  9. # Default: False
  10. AltOlyEndAnnounce = True
  11.  
  12. ===================================================================
  13. --- java/head-src/com/l2jfrozen/Config.java (revision 5)
  14. +++ java/head-src/com/l2jfrozen/Config.java (working copy)
  15. @@ -163,6 +163,7 @@
  16. public static String PM_TEXT2;
  17. public static boolean NEW_PLAYER_EFFECT;
  18. + public static boolean ALT_OLY_END_ANNOUNCE;
  19.  
  20. @@ -790,6 +795,7 @@
  21. PM_TEXT2 = frozenSettings.getProperty("PMText2", "Vote for us every 24h");
  22. NEW_PLAYER_EFFECT = Boolean.parseBoolean(frozenSettings.getProperty("NewPlayerEffect", "True"));
  23. + ALT_OLY_END_ANNOUNCE = Boolean.parseBoolean(events.getProperty("AltOlyEndAnnounce", "False"));
  24.  
  25. ===================================================================
  26. --- java/head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java (revision 5)
  27. +++ java/head-src/com/l2jfrozen/gameserver/model/entity/olympiad/Olympiad.java(working copy)
  28. @@ -39,6 +39,8 @@
  29. import com.l2jfrozen.gameserver.model.entity.Announcements;
  30. import com.l2jfrozen.gameserver.model.entity.Hero;
  31. import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
  32. import com.l2jfrozen.gameserver.network.SystemMessageId;
  33. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  34. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  35. import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  36. import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  37. @@ -86,15 +88,15 @@
  38. public static final String COMP_LOST = "competitions_lost";
  39. public static final String COMP_DRAWN = "competitions_drawn";
  40.  
  41. - protected long _olympiadEnd;
  42. - protected long _validationEnd;
  43. + protected static long _olympiadEnd;
  44. + protected static long _validationEnd;
  45.  
  46. /**
  47. * The current period of the olympiad.<br>
  48. * <b>0 -</b> Competition period<br>
  49. * <b>1 -</b> Validation Period
  50. */
  51. - protected int _period;
  52. + protected static int _period;
  53. protected long _nextWeeklyChange;
  54. protected int _currentCycle;
  55. private long _compEnd;
  56. @@ -454,7 +456,7 @@
  57. }, getMillisToCompBegin());
  58. }
  59.  
  60. - private long getMillisToOlympiadEnd()
  61. + private static long getMillisToOlympiadEnd()
  62. {
  63. return (_olympiadEnd - Calendar.getInstance().getTimeInMillis());
  64. }
  65. @@ -467,7 +469,7 @@
  66. _scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(), 0);
  67. }
  68.  
  69. - protected long getMillisToValidationEnd()
  70. + protected static long getMillisToValidationEnd()
  71. {
  72. if (_validationEnd > Calendar.getInstance().getTimeInMillis())
  73. return (_validationEnd - Calendar.getInstance().getTimeInMillis());
  74. @@ -475,6 +477,29 @@
  75. return 10L;
  76. }
  77.  
  78. + public static void olympiadEnd(L2PcInstance player)
  79. + {
  80. + long milliToEnd;
  81. + if(_period == 0)
  82. + {
  83. + milliToEnd = getMillisToOlympiadEnd();
  84. + }
  85. + else
  86. + {
  87. + milliToEnd = getMillisToValidationEnd();
  88. + }
  89. +
  90. + double numSecs = milliToEnd / 1000 % 60;
  91. + double countDown = (milliToEnd / 1000 - numSecs) / 60;
  92. + int numMins = (int) Math.floor(countDown % 60);
  93. + countDown = (countDown - numMins) / 60;
  94. + int numHours = (int) Math.floor(countDown % 24);
  95. + int numDays = (int) Math.floor((countDown - numHours) / 24);
  96. +
  97. + CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, "", "Olympiad period ends in " + numDays + " days, " + numHours + " hours and " + numMins + " mins.");
  98. + player.sendPacket(cs);
  99. + }
  100. +
  101. public boolean isOlympiadEnd()
  102. {
  103. return (_period != 0);
  104. Index: java/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
  105. ===================================================================
  106. --- java/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (revision 5)
  107. +++ java/head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (working copy)
  108. @@ -168,6 +168,11 @@
  109. // Check for crowns
  110. CrownManager.getInstance().checkCrowns(activeChar);
  111.  
  112. + if (Config.ALT_OLY_END_ANNOUNCE)
  113. + {
  114. + Olympiad.olympiadEnd(activeChar);
  115. + }
  116. +
  117. // Check player skills
  118. if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
  119. activeChar.checkAllowedSkills();
Add Comment
Please, Sign In to add comment