PerksUtils.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.gmail.nossr50.util.skills;
  2. import org.bukkit.entity.Player;
  3. import com.gmail.nossr50.datatypes.skills.SkillType;
  4. import com.gmail.nossr50.util.Permissions;
  5. public final class PerksUtils {
  6. private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
  7. private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
  8. private PerksUtils() {}
  9. public static int handleCooldownPerks(Player player, int cooldown) {
  10. if (Permissions.halvedCooldowns(player)) {
  11. cooldown *= 0.5;
  12. }
  13. else if (Permissions.thirdedCooldowns(player)) {
  14. cooldown *= (1.0 / 3.0);
  15. }
  16. else if (Permissions.quarteredCooldowns(player)) {
  17. cooldown *= 0.75;
  18. }
  19. return cooldown;
  20. }
  21. public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
  22. if (maxTicks != 0) {
  23. ticks = Math.min(ticks, maxTicks);
  24. }
  25. if (Permissions.twelveSecondActivationBoost(player)) {
  26. ticks += 12;
  27. }
  28. else if (Permissions.eightSecondActivationBoost(player)) {
  29. ticks += 8;
  30. }
  31. else if (Permissions.fourSecondActivationBoost(player)) {
  32. ticks += 4;
  33. }
  34. return ticks;
  35. }
  36. public static float handleXpPerks(Player player, float xp, SkillType skill) {
  37. if (Permissions.quadrupleXp(player, skill)) {
  38. xp *= 4;
  39. }
  40. else if (Permissions.tripleXp(player, skill)) {
  41. xp *= 3;
  42. }
  43. else if (Permissions.doubleAndOneHalfXp(player, skill)) {
  44. xp *= 2.5;
  45. }
  46. else if (Permissions.doubleXp(player, skill)) {
  47. xp *= 2;
  48. }
  49. else if (Permissions.oneAndOneHalfXp(player, skill)) {
  50. xp *= 1.5;
  51. }
  52. return xp;
  53. }
  54. /**
  55. * Calculate activation chance for a skill.
  56. *
  57. * @param player Player to check the activation chance for
  58. * @param skill SkillType to check the activation chance of
  59. *
  60. * @return the activation chance with "lucky perk" accounted for
  61. */
  62. public static int handleLuckyPerks(Player player, SkillType skill) {
  63. if (Permissions.lucky(player, skill)) {
  64. return LUCKY_SKILL_ACTIVATION_CHANCE;
  65. }
  66. return NORMAL_SKILL_ACTIVATION_CHANCE;
  67. }
  68. }