TaskRaidPointsReset.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.taskmanager.tasks;
  16. import java.util.Calendar;
  17. import java.util.Map;
  18. import net.sf.l2j.Config;
  19. import net.sf.l2j.gameserver.datatables.ClanTable;
  20. import net.sf.l2j.gameserver.instancemanager.RaidBossPointsManager;
  21. import net.sf.l2j.gameserver.model.L2Clan;
  22. import net.sf.l2j.gameserver.network.serverpackets.PledgeShowInfoUpdate;
  23. import net.sf.l2j.gameserver.taskmanager.Task;
  24. import net.sf.l2j.gameserver.taskmanager.TaskManager;
  25. import net.sf.l2j.gameserver.taskmanager.TaskTypes;
  26. import net.sf.l2j.gameserver.taskmanager.TaskManager.ExecutedTask;
  27. import java.util.logging.Logger;
  28. public class TaskRaidPointsReset extends Task
  29. {
  30. private static final Logger _log = Logger.getLogger(TaskRaidPointsReset.class.getName());
  31. public static final String NAME = "raid_points_reset";
  32. @Override
  33. public String getName()
  34. {
  35. return NAME;
  36. }
  37. @Override
  38. public void onTimeElapsed(ExecutedTask task)
  39. {
  40. Calendar cal = Calendar.getInstance();
  41. if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY)
  42. {
  43. // reward clan reputation points
  44. Map<Integer, Integer> rankList = RaidBossPointsManager.getRankList();
  45. for (L2Clan c : ClanTable.getInstance().getClans())
  46. {
  47. for (Map.Entry<Integer, Integer> entry : rankList.entrySet())
  48. {
  49. if (entry.getValue() <= 100 && c.isMember(entry.getKey()))
  50. {
  51. int reputation = 0;
  52. switch (entry.getValue())
  53. {
  54. case 1:
  55. reputation = Config.RAID_RANKING_1ST;
  56. break;
  57. case 2:
  58. reputation = Config.RAID_RANKING_2ND;
  59. break;
  60. case 3:
  61. reputation = Config.RAID_RANKING_3RD;
  62. break;
  63. case 4:
  64. reputation = Config.RAID_RANKING_4TH;
  65. break;
  66. case 5:
  67. reputation = Config.RAID_RANKING_5TH;
  68. break;
  69. case 6:
  70. reputation = Config.RAID_RANKING_6TH;
  71. break;
  72. case 7:
  73. reputation = Config.RAID_RANKING_7TH;
  74. break;
  75. case 8:
  76. reputation = Config.RAID_RANKING_8TH;
  77. break;
  78. case 9:
  79. reputation = Config.RAID_RANKING_9TH;
  80. break;
  81. case 10:
  82. reputation = Config.RAID_RANKING_10TH;
  83. break;
  84. default:
  85. if (entry.getValue() <= 50)
  86. reputation = Config.RAID_RANKING_UP_TO_50TH;
  87. else
  88. reputation = Config.RAID_RANKING_UP_TO_100TH;
  89. break;
  90. }
  91. c.setReputationScore(c.getReputationScore() + reputation, true);
  92. c.broadcastToOnlineMembers(new PledgeShowInfoUpdate(c));
  93. }
  94. }
  95. }
  96. RaidBossPointsManager.cleanUp();
  97. _log.info("Raid Points Reset Global Task: launched.");
  98. }
  99. }
  100. @Override
  101. public void initializate()
  102. {
  103. super.initializate();
  104. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "00:10:00", "");
  105. }
  106. }