2019-05-08 06:44:19 -07:00

57 lines
1.7 KiB
Java

package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.entity.Player;
public final class PerksUtils {
private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
private PerksUtils() {
}
public static int handleCooldownPerks(Player player, int cooldown) {
if (Permissions.halvedCooldowns(player)) {
cooldown *= 0.5;
} else if (Permissions.thirdedCooldowns(player)) {
cooldown *= (2.0 / 3.0);
} else if (Permissions.quarteredCooldowns(player)) {
cooldown *= 0.75;
}
return cooldown;
}
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
if (maxTicks != 0) {
ticks = Math.min(ticks, maxTicks);
}
if (Permissions.twelveSecondActivationBoost(player)) {
ticks += 12;
} else if (Permissions.eightSecondActivationBoost(player)) {
ticks += 8;
} else if (Permissions.fourSecondActivationBoost(player)) {
ticks += 4;
}
return ticks;
}
/**
* Calculate activation chance for a skill.
*
* @param player Player to check the activation chance for
* @param skill PrimarySkillType to check the activation chance of
* @return the activation chance with "lucky perk" accounted for
*/
public static int handleLuckyPerks(Player player, PrimarySkillType skill) {
if (Permissions.lucky(player, skill)) {
return LUCKY_SKILL_ACTIVATION_CHANCE;
}
return NORMAL_SKILL_ACTIVATION_CHANCE;
}
}