Advertisement
-JRGames-

Oly End Console Acis 389

Mar 29th, 2021
1,404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.73 KB | None | 0 0
  1. diff --git a/aCis_gameserver/config/events.properties b/aCis_gameserver/config/events.properties
  2. index 3f19588..b305edc 100644
  3. --- a/aCis_gameserver/config/events.properties
  4. +++ b/aCis_gameserver/config/events.properties
  5. @@ -93,7 +93,9 @@
  6.  AltOlyPeriod = WEEK
  7.  AltOlyPeriodMultiplier = 2
  8.  
  9. +# Announce olympiad end on enter world.
  10. +# Default: False
  11. +AltOlyEndAnnounce = True
  12.  
  13.  #=============================================================
  14.  #                  Seven Signs && Festival
  15. diff --git a/aCis_gameserver/java/net/sf/l2j/Config.java b/aCis_gameserver/java/net/sf/l2j/Config.java
  16. index 61fdf2b..6e01ee8 100644
  17. --- a/aCis_gameserver/java/net/sf/l2j/Config.java
  18. +++ b/aCis_gameserver/java/net/sf/l2j/Config.java
  19. @@ -150,7 +150,8 @@
  20.     /** Olly Period */
  21.     public static OlympiadPeriod ALT_OLY_PERIOD;
  22.     public static int ALT_OLY_PERIOD_MULTIPLIER;
  23. +   public static boolean ALT_OLY_END_ANNOUNCE;
  24. +  
  25.     /** SevenSigns Festival */
  26.     public static boolean SEVEN_SIGNS_BYPASS_PREREQUISITES;
  27.     public static int FESTIVAL_MIN_PLAYER;
  28. @@ -769,6 +770,7 @@
  29.        
  30.         ALT_OLY_PERIOD = OlympiadPeriod.valueOf(events.getProperty("AltOlyPeriod", "MONTH"));
  31.         ALT_OLY_PERIOD_MULTIPLIER = events.getProperty("AltOlyPeriodMultiplier", 1);
  32. +       ALT_OLY_END_ANNOUNCE = Boolean.parseBoolean(events.getProperty("AltOlyEndAnnounce", "False"));
  33.        
  34.         SEVEN_SIGNS_BYPASS_PREREQUISITES = events.getProperty("SevenSignsBypassPrerequisites", false);
  35.         FESTIVAL_MIN_PLAYER = MathUtil.limit(events.getProperty("FestivalMinPlayer", 5), 2, 9);
  36. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  37. index c198961..75fcdb2 100644
  38. --- a/aCis_gameserver/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  39. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
  40. @@ -20,7 +20,6 @@
  41.  import net.sf.l2j.Config;
  42.  import net.sf.l2j.gameserver.data.manager.HeroManager;
  43.  import net.sf.l2j.gameserver.data.manager.ZoneManager;
  44. -import net.sf.l2j.gameserver.enums.OlympiadState;
  45.  import net.sf.l2j.gameserver.enums.OlympiadType;
  46.  import net.sf.l2j.gameserver.enums.SayType;
  47.  import net.sf.l2j.gameserver.model.World;
  48. @@ -28,6 +27,7 @@
  49.  import net.sf.l2j.gameserver.model.actor.instance.OlympiadManagerNpc;
  50.  import net.sf.l2j.gameserver.model.zone.type.OlympiadStadiumZone;
  51.  import net.sf.l2j.gameserver.network.SystemMessageId;
  52. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  53.  import net.sf.l2j.gameserver.network.serverpackets.NpcSay;
  54.  import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  55.  
  56. @@ -63,10 +63,10 @@
  57.     public static final String COMP_LOST = "competitions_lost";
  58.     public static final String COMP_DRAWN = "competitions_drawn";
  59.    
  60. -   protected long _olympiadEnd;
  61. -   protected long _validationEnd;
  62. -  
  63. -   protected OlympiadState _period;
  64. +   protected static long _olympiadEnd;
  65. +   protected static long _validationEnd;  
  66. +
  67. +   protected static int _period;
  68.     protected long _nextWeeklyChange;
  69.     protected int _currentCycle;
  70.     private long _compEnd;
  71. @@ -85,7 +85,7 @@
  72.     {
  73.         load();
  74.        
  75. -       if (_period == OlympiadState.COMPETITION)
  76. +       if (_period == 0)
  77.             init();
  78.     }
  79.    
  80. @@ -110,9 +110,32 @@
  81.         return (set == null) ? 0 : set.getInteger(POINTS);
  82.     }
  83.    
  84. +   public static void olympiadEnd(Player player)
  85. +   {
  86. +           long milliToEnd;
  87. +           if(_period == 0)
  88. +           {
  89. +               milliToEnd = getMillisToOlympiadEnd();
  90. +           }
  91. +           else
  92. +           {
  93. +               milliToEnd = getMillisToValidationEnd();
  94. +           }
  95. +
  96. +           double numSecs = milliToEnd / 1000 % 60;
  97. +           double countDown = (milliToEnd / 1000 - numSecs) / 60;
  98. +           int numMins = (int) Math.floor(countDown % 60);
  99. +           countDown = (countDown - numMins) / 60;
  100. +           int numHours = (int) Math.floor(countDown % 24);
  101. +           int numDays = (int) Math.floor((countDown - numHours) / 24);
  102. +
  103. +           CreatureSay cs = new CreatureSay(0, SayType.PARTY, "", "Olympiad period ends in " + numDays + " days, " + numHours + " hours and " + numMins + " mins.");
  104. +           player.sendPacket(cs);
  105. +   }
  106. +  
  107.     public boolean isOlympiadEnd()
  108.     {
  109. -       return _period == OlympiadState.VALIDATION;
  110. +       return _period == 0;
  111.     }
  112.    
  113.     public boolean isInCompPeriod()
  114. @@ -134,7 +157,8 @@
  115.             if (rs.next())
  116.             {
  117.                 _currentCycle = rs.getInt("current_cycle");
  118. -               _period = Enum.valueOf(OlympiadState.class, rs.getString("period"));
  119. +               //_period = Enum.valueOf(OlympiadState.class, rs.getString("period"));
  120. +               _period = rs.getInt("period");
  121.                 _olympiadEnd = rs.getLong("olympiad_end");
  122.                 _validationEnd = rs.getLong("validation_end");
  123.                 _nextWeeklyChange = rs.getLong("next_weekly_change");
  124. @@ -142,7 +166,7 @@
  125.             else
  126.             {
  127.                 _currentCycle = 1;
  128. -               _period = OlympiadState.COMPETITION;
  129. +               _period = 0;
  130.                 _olympiadEnd = 0;
  131.                 _validationEnd = 0;
  132.                 _nextWeeklyChange = 0;
  133. @@ -157,14 +181,14 @@
  134.        
  135.         switch (_period)
  136.         {
  137. -           case COMPETITION:
  138. +           case 0:
  139.                 if (_olympiadEnd == 0 || _olympiadEnd < Calendar.getInstance().getTimeInMillis())
  140.                     setNewOlympiadEnd();
  141.                 else
  142.                     scheduleWeeklyChange();
  143.                 break;
  144.            
  145. -           case VALIDATION:
  146. +           case 1:
  147.                 if (_validationEnd > Calendar.getInstance().getTimeInMillis())
  148.                 {
  149.                     // Process rank rewards.
  150. @@ -175,7 +199,7 @@
  151.                 else
  152.                 {
  153.                     _currentCycle++;
  154. -                   _period = OlympiadState.COMPETITION;
  155. +                   _period = 0;
  156.                    
  157.                     deleteNobles();
  158.                     setNewOlympiadEnd();
  159. @@ -209,14 +233,14 @@
  160.         synchronized (this)
  161.         {
  162.             long milliToEnd;
  163. -           if (_period == OlympiadState.COMPETITION)
  164. +           if (_period == 0)
  165.                 milliToEnd = getMillisToOlympiadEnd();
  166.             else
  167.                 milliToEnd = getMillisToValidationEnd();
  168.            
  169.             LOGGER.info("{} minutes until Olympiad period ends.", Math.round(milliToEnd / 60000));
  170.            
  171. -           if (_period == OlympiadState.COMPETITION)
  172. +           if (_period == 0)
  173.             {
  174.                 milliToEnd = getMillisToWeekChange();
  175.                 LOGGER.info("Next weekly Olympiad change is in {} minutes.", Math.round(milliToEnd / 60000));
  176. @@ -287,7 +311,7 @@
  177.    
  178.     private void init()
  179.     {
  180. -       if (_period == OlympiadState.VALIDATION)
  181. +       if (_period == 0)
  182.             return;
  183.        
  184.         _compStart = Calendar.getInstance();
  185. @@ -399,7 +423,7 @@
  186.         }, getMillisToCompBegin());
  187.     }
  188.    
  189. -   private long getMillisToOlympiadEnd()
  190. +   private static long getMillisToOlympiadEnd()
  191.     {
  192.         return (_olympiadEnd - Calendar.getInstance().getTimeInMillis());
  193.     }
  194. @@ -412,7 +436,7 @@
  195.         _olympiadEndTask = ThreadPool.schedule(this::olympiadEnd, 0);
  196.     }
  197.    
  198. -   private long getMillisToValidationEnd()
  199. +   private static long getMillisToValidationEnd()
  200.     {
  201.         if (_validationEnd > Calendar.getInstance().getTimeInMillis())
  202.             return (_validationEnd - Calendar.getInstance().getTimeInMillis());
  203. @@ -522,7 +546,7 @@
  204.         {
  205.             _nextWeeklyChange = Calendar.getInstance().getTimeInMillis() + Config.OLY_WPERIOD;
  206.            
  207. -           if (_period == OlympiadState.VALIDATION)
  208. +           if (_period == 0)
  209.                 return;
  210.            
  211.             for (StatSet set : _nobles.values())
  212. @@ -574,7 +598,7 @@
  213.     /**
  214.      * Save current olympiad status and update noblesse table in database
  215.      */
  216. -   public void saveOlympiadStatus()
  217. +/**    public void saveOlympiadStatus()
  218.     {
  219.         saveNobleData();
  220.        
  221. @@ -597,7 +621,35 @@
  222.         {
  223.             LOGGER.error("Couldn't save Olympiad status.", e);
  224.         }
  225. +   }*/
  226. +  
  227. +   public void saveOlympiadStatus()
  228. +   {
  229. +       saveNobleData();
  230. +      
  231. +       try (Connection con = ConnectionPool.getConnection();
  232. +           PreparedStatement ps = con.prepareStatement(INSERT_OLYMPIAD_DATA))
  233. +       {
  234. +           ps.setInt(1, _currentCycle);
  235. +           ps.setInt(2, _period);
  236. +           ps.setLong(3, _olympiadEnd);
  237. +           ps.setLong(4, _validationEnd);
  238. +           ps.setLong(5, _nextWeeklyChange);
  239. +           ps.setInt(6, _currentCycle);
  240. +           ps.setInt(7, _period);
  241. +           ps.setLong(8, _olympiadEnd);
  242. +           ps.setLong(9, _validationEnd);
  243. +           ps.setLong(10, _nextWeeklyChange);
  244. +          
  245. +           ps.execute();
  246. +           ps.close();
  247. +       }
  248. +       catch (Exception e)
  249. +       {
  250. +           LOGGER.error("Couldn't save Olympiad status.", e);
  251. +       }
  252.     }
  253. +
  254.    
  255.     public List<String> getClassLeaderBoard(int classId)
  256.     {
  257. @@ -624,7 +676,7 @@
  258.    
  259.     public int getNoblessePasses(Player player, boolean clear)
  260.     {
  261. -       if (player == null || _period != OlympiadState.VALIDATION)
  262. +       if (player == null || _period != 0)
  263.             return 0;
  264.        
  265.         final Integer rankReward = _rankRewards.get(player.getObjectId());
  266. @@ -707,7 +759,7 @@
  267.        
  268.         saveNobleData();
  269.        
  270. -       _period = OlympiadState.VALIDATION;
  271. +       _period = 0;
  272.        
  273.         HeroManager.getInstance().resetData();
  274.         HeroManager.getInstance().computeNewHeroes();
  275. @@ -737,7 +789,7 @@
  276.    
  277.     private void validationEnd()
  278.     {
  279. -       _period = OlympiadState.COMPETITION;
  280. +       _period = 0;
  281.         _currentCycle++;
  282.        
  283.         deleteNobles();
  284. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  285. index 2a9b743..cdc54ea 100644
  286. --- a/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  287. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  288. @@ -222,6 +222,8 @@
  289.         player.sendPacket(SevenSignsManager.getInstance().getCurrentPeriod().getMessageId());
  290.         AnnouncementData.getInstance().showAnnouncements(player, false);
  291.        
  292. +       if (Config.ALT_OLY_END_ANNOUNCE) { Olympiad.olympiadEnd(player); }
  293. +
  294.         // If the Player is a Dark Elf, check for Shadow Sense at night.
  295.         if (player.getRace() == ClassRace.DARK_ELF && player.hasSkill(L2Skill.SKILL_SHADOW_SENSE))
  296.             player.sendPacket(SystemMessage.getSystemMessage((GameTimeTaskManager.getInstance().isNight()) ? SystemMessageId.NIGHT_S1_EFFECT_APPLIES : SystemMessageId.DAY_S1_EFFECT_DISAPPEARS).addSkillName(L2Skill.SKILL_SHADOW_SENSE));
  297.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement