TaskRaidPointsReset.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.taskmanager.Task;
  23. import net.sf.l2j.gameserver.taskmanager.TaskManager;
  24. import net.sf.l2j.gameserver.taskmanager.TaskTypes;
  25. import net.sf.l2j.gameserver.taskmanager.TaskManager.ExecutedTask;
  26. import java.util.logging.Logger;
  27. public class TaskRaidPointsReset extends Task
  28. {
  29. private static final Logger _log = Logger.getLogger(TaskRaidPointsReset.class.getName());
  30. public static final String NAME = "raid_points_reset";
  31. @Override
  32. public String getName()
  33. {
  34. return NAME;
  35. }
  36. @Override
  37. public void onTimeElapsed(ExecutedTask task)
  38. {
  39. Calendar cal = Calendar.getInstance();
  40. if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY)
  41. {
  42. // reward clan reputation points
  43. Map<Integer, Integer> rankList = RaidBossPointsManager.getRankList();
  44. for (L2Clan c : ClanTable.getInstance().getClans())
  45. {
  46. for (Map.Entry<Integer, Integer> entry : rankList.entrySet())
  47. {
  48. if (entry.getValue() <= 100 && c.isMember(entry.getKey()))
  49. {
  50. int reputation = 0;
  51. switch (entry.getValue())
  52. {
  53. case 1:
  54. reputation = Config.RAID_RANKING_1ST;
  55. break;
  56. case 2:
  57. reputation = Config.RAID_RANKING_2ND;
  58. break;
  59. case 3:
  60. reputation = Config.RAID_RANKING_3RD;
  61. break;
  62. case 4:
  63. reputation = Config.RAID_RANKING_4TH;
  64. break;
  65. case 5:
  66. reputation = Config.RAID_RANKING_5TH;
  67. break;
  68. case 6:
  69. reputation = Config.RAID_RANKING_6TH;
  70. break;
  71. case 7:
  72. reputation = Config.RAID_RANKING_7TH;
  73. break;
  74. case 8:
  75. reputation = Config.RAID_RANKING_8TH;
  76. break;
  77. case 9:
  78. reputation = Config.RAID_RANKING_9TH;
  79. break;
  80. case 10:
  81. reputation = Config.RAID_RANKING_10TH;
  82. break;
  83. default:
  84. if (entry.getValue() <= 50)
  85. reputation = Config.RAID_RANKING_UP_TO_50TH;
  86. else
  87. reputation = Config.RAID_RANKING_UP_TO_100TH;
  88. break;
  89. }
  90. c.setReputationScore(c.getReputationScore() + reputation, true);
  91. }
  92. }
  93. }
  94. RaidBossPointsManager.cleanUp();
  95. _log.info("Raid Points Reset Global Task: launched.");
  96. }
  97. }
  98. @Override
  99. public void initializate()
  100. {
  101. super.initializate();
  102. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "00:10:00", "");
  103. }
  104. }