2013-03-01 00:52:01 -05:00
|
|
|
package com.gmail.nossr50.util.skills;
|
|
|
|
|
2018-12-29 05:24:55 -08:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkill;
|
2013-03-01 00:52:01 -05:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2014-01-18 23:27:18 +01:00
|
|
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
2013-03-01 00:52:01 -05:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
|
|
|
|
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)) {
|
2013-12-02 08:30:45 -05:00
|
|
|
cooldown *= (2.0 / 3.0);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
else if (Permissions.quarteredCooldowns(player)) {
|
|
|
|
cooldown *= 0.75;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cooldown;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
|
2013-05-14 23:52:56 -04:00
|
|
|
if (maxTicks != 0) {
|
|
|
|
ticks = Math.min(ticks, maxTicks);
|
|
|
|
}
|
|
|
|
|
2013-03-01 00:52:01 -05:00
|
|
|
if (Permissions.twelveSecondActivationBoost(player)) {
|
|
|
|
ticks += 12;
|
|
|
|
}
|
|
|
|
else if (Permissions.eightSecondActivationBoost(player)) {
|
|
|
|
ticks += 8;
|
|
|
|
}
|
|
|
|
else if (Permissions.fourSecondActivationBoost(player)) {
|
|
|
|
ticks += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ticks;
|
|
|
|
}
|
|
|
|
|
2018-12-29 05:24:55 -08:00
|
|
|
public static float handleXpPerks(Player player, float xp, PrimarySkill skill) {
|
2016-01-28 13:37:21 -05:00
|
|
|
if (Permissions.customXpBoost(player, skill)) {
|
|
|
|
xp *= ExperienceConfig.getInstance().getCustomXpPerkBoost();
|
|
|
|
}
|
|
|
|
else if (Permissions.quadrupleXp(player, skill)) {
|
2013-03-01 00:52:01 -05:00
|
|
|
xp *= 4;
|
|
|
|
}
|
2013-09-03 09:24:58 -04:00
|
|
|
else if (Permissions.tripleXp(player, skill)) {
|
2013-03-01 00:52:01 -05:00
|
|
|
xp *= 3;
|
|
|
|
}
|
2013-09-03 09:24:58 -04:00
|
|
|
else if (Permissions.doubleAndOneHalfXp(player, skill)) {
|
2013-03-01 00:52:01 -05:00
|
|
|
xp *= 2.5;
|
|
|
|
}
|
2013-09-03 09:24:58 -04:00
|
|
|
else if (Permissions.doubleXp(player, skill)) {
|
2013-03-01 00:52:01 -05:00
|
|
|
xp *= 2;
|
|
|
|
}
|
2013-09-03 09:24:58 -04:00
|
|
|
else if (Permissions.oneAndOneHalfXp(player, skill)) {
|
2013-03-01 00:52:01 -05:00
|
|
|
xp *= 1.5;
|
|
|
|
}
|
2014-01-18 23:08:40 +01:00
|
|
|
else if (Permissions.oneAndOneTenthXp(player, skill)) {
|
|
|
|
xp *= 1.1;
|
|
|
|
}
|
2013-03-01 00:52:01 -05:00
|
|
|
|
|
|
|
return xp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate activation chance for a skill.
|
|
|
|
*
|
2013-08-10 20:10:45 +02:00
|
|
|
* @param player Player to check the activation chance for
|
2018-12-29 05:24:55 -08:00
|
|
|
* @param skill PrimarySkill to check the activation chance of
|
2013-08-10 20:10:45 +02:00
|
|
|
* @return the activation chance with "lucky perk" accounted for
|
2013-03-01 00:52:01 -05:00
|
|
|
*/
|
2018-12-29 05:24:55 -08:00
|
|
|
public static int handleLuckyPerks(Player player, PrimarySkill skill) {
|
2013-03-01 00:52:01 -05:00
|
|
|
if (Permissions.lucky(player, skill)) {
|
|
|
|
return LUCKY_SKILL_ACTIVATION_CHANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NORMAL_SKILL_ACTIVATION_CHANCE;
|
|
|
|
}
|
|
|
|
}
|