Advertisement
admhoro

Announce olympiad period end

May 22nd, 2023 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 KB | None | 0 0
  1. diff --git a/core/java/config/Olympiad.properties b/core/java/config/Olympiad.properties
  2. index 5c25403..9918cc6 100644
  3. --- a/core/java/config/Olympiad.properties
  4. +++ b/core/java/config/Olympiad.properties
  5. @@ -85,4 +85,11 @@
  6.  
  7. # Enchant limit for items during Olympiad games. Disabled = -1.
  8. # Default: -1
  9. -AltOlyEnchantLimit = -1
  10. \ No newline at end of file
  11. +AltOlyEnchantLimit = -1
  12. +
  13. +#=====================================================
  14. +# Announce Time Olympiad in Enter World
  15. +#=====================================================
  16. +# Announce olympiad end on enter world.
  17. +# Default: False
  18. +AltOlyEndAnnounce = True
  19. \ No newline at end of file
  20. diff --git a/core/java/net/sf/l2j/Config.java b/core/java/net/sf/l2j/Config.java
  21. index 88ec0a3..d757665 100644
  22. --- a/core/java/net/sf/l2j/Config.java
  23. +++ b/core/java/net/sf/l2j/Config.java
  24. @@ -400,6 +400,9 @@
  25. /** Enchant limit for player items in Grand Olympiad games */
  26. public static int ALT_OLY_ENCHANT_LIMIT;
  27.  
  28. + /** Olympiad Announce End Time */
  29. + public static boolean ALT_OLY_END_ANNOUNCE;
  30. +
  31. /** Manor Refresh Starting time */
  32. public static int ALT_MANOR_REFRESH_TIME;
  33.  
  34. @@ -1952,6 +1955,7 @@
  35. ALT_OLY_LOSE_POINTS_ON_TIE = Boolean.valueOf(olympiadSettings.getProperty("AltOlyLosePointsOnTie", "true"));
  36. ALT_OLY_SHOW_MONTHLY_WINNERS = Boolean.valueOf(olympiadSettings.getProperty("AltOlyShowMonthlyWinners", "true"));
  37. ALT_OLY_ENCHANT_LIMIT = Integer.parseInt(olympiadSettings.getProperty("AltOlyEnchantLimit", "-1"));
  38. + ALT_OLY_END_ANNOUNCE = Boolean.parseBoolean(olympiadSettings.getProperty("AltOlyEndAnnounce", "False"));
  39.  
  40. // Custom settings
  41. Properties customSettings = new Properties();
  42. diff --git a/core/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java b/core/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  43. index 7daf15e..0201a6a 100644
  44. --- a/core/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  45. +++ b/core/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  46. @@ -38,6 +38,8 @@
  47. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  48. import net.sf.l2j.gameserver.model.entity.Hero;
  49. import net.sf.l2j.gameserver.model.zone.type.L2OlympiadStadiumZone;
  50. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  51. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  52. import net.sf.l2j.gameserver.network.serverpackets.ExOlympiadMatchEnd;
  53. import net.sf.l2j.gameserver.network.serverpackets.ExOlympiadSpelledInfo;
  54. import net.sf.l2j.gameserver.network.serverpackets.ExOlympiadUserInfo;
  55. @@ -114,9 +116,9 @@
  56.  
  57. // Default values
  58. protected int _currentCycle = 1;
  59. - protected int _period = 0;
  60. - protected long _olympiadEnd = 0;
  61. - protected long _validationEnd = 0;
  62. + protected static int _period = 0;
  63. + protected static long _olympiadEnd = 0;
  64. + protected static long _validationEnd = 0;
  65. protected long _nextWeeklyChange = 0;
  66.  
  67. private long _compEnd;
  68. @@ -686,7 +688,7 @@
  69. }, getMillisToCompBegin());
  70. }
  71.  
  72. - private long getMillisToOlympiadEnd()
  73. + private static long getMillisToOlympiadEnd()
  74. {
  75. return (_olympiadEnd - Calendar.getInstance().getTimeInMillis());
  76. }
  77. @@ -699,7 +701,7 @@
  78. _scheduledOlympiadEnd = ThreadPoolManager.getInstance().scheduleGeneral(new OlympiadEndTask(), 0);
  79. }
  80.  
  81. - protected long getMillisToValidationEnd()
  82. + protected static long getMillisToValidationEnd()
  83. {
  84. if (_validationEnd > Calendar.getInstance().getTimeInMillis())
  85. return (_validationEnd - Calendar.getInstance().getTimeInMillis());
  86. @@ -861,7 +863,28 @@
  87. {
  88. return ZoneManager.getInstance().getOlympiadStadium(player) != null;
  89. }
  90. + public static void olympiadEnd(L2PcInstance player)
  91. + {
  92. + long milliToEnd;
  93. + if(_period == 0)
  94. + {
  95. + milliToEnd = getMillisToOlympiadEnd();
  96. + }
  97. + else
  98. + {
  99. + milliToEnd = getMillisToValidationEnd();
  100. + }
  101.  
  102. + double numSecs = milliToEnd / 1000 % 60;
  103. + double countDown = (milliToEnd / 1000 - numSecs) / 60;
  104. + int numMins = (int) Math.floor(countDown % 60);
  105. + countDown = (countDown - numMins) / 60;
  106. + int numHours = (int) Math.floor(countDown % 24);
  107. + int numDays = (int) Math.floor((countDown - numHours) / 24);
  108. +
  109. + CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, "", "Olympiad period ends in " + numDays + " days, " + numHours + " hours and " + numMins + " mins.");
  110. + player.sendPacket(cs);
  111. + }
  112. public int[] getWaitingList()
  113. {
  114. int[] array = new int[2];
  115. diff --git a/core/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/core/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  116. index 4e171f1..8036258 100644
  117. --- a/core/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  118. +++ b/core/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  119. @@ -151,7 +151,10 @@
  120. {
  121. activeChar.setIsDead(true);
  122. }
  123. -
  124. + if (Config.ALT_OLY_END_ANNOUNCE)
  125. + {
  126. + Olympiad.olympiadEnd(activeChar);
  127. + }
  128. L2Clan clan = activeChar.getClan();
  129. if (clan != null)
  130. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement