TaskRaidPointsReset.java 3.4 KB

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