mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
Static Abuse Removal PerkUtils
This commit is contained in:
parent
f7aaf25d93
commit
f52144fb3e
@ -31,7 +31,6 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.GameMode;
|
||||
@ -1012,7 +1011,7 @@ public class McMMOPlayer {
|
||||
*/
|
||||
public int calculateTimeRemaining(SuperAbilityType superAbilityType) {
|
||||
long deactivatedTimestamp = profile.getAbilityDATS(superAbilityType) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR;
|
||||
return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player,
|
||||
return (int) (((deactivatedTimestamp + (pluginRef.getPerkUtils().handleCooldownPerks(player,
|
||||
pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType)) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
@ -221,7 +220,7 @@ public class Roll extends AcrobaticsSubSkill {
|
||||
}
|
||||
|
||||
private int getActivationChance(McMMOPlayer mcMMOPlayer) {
|
||||
return PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), getPrimarySkill());
|
||||
return pluginRef.getPerkUtils().handleLuckyPerks(mcMMOPlayer.getPlayer(), getPrimarySkill());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,6 +41,7 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceTools;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.CombatTools;
|
||||
import com.gmail.nossr50.util.skills.PerkUtils;
|
||||
import com.gmail.nossr50.util.skills.RankTools;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@ -86,6 +87,7 @@ public class mcMMO extends JavaPlugin {
|
||||
private UserManager userManager;
|
||||
private ScoreboardManager scoreboardManager;
|
||||
private SoundManager soundManager;
|
||||
private HardcoreManager hardcoreManager;
|
||||
|
||||
/* Not-Managers but my naming scheme sucks */
|
||||
private DatabaseManagerFactory databaseManagerFactory;
|
||||
@ -105,7 +107,7 @@ public class mcMMO extends JavaPlugin {
|
||||
private MessageOfTheDayUtils messageOfTheDayUtils;
|
||||
private MiscTools miscTools;
|
||||
private ZipLibrary zipLibrary;
|
||||
private HardcoreManager hardcoreManager;
|
||||
private PerkUtils perkUtils;
|
||||
|
||||
/* Never-Ending tasks */
|
||||
private BleedTimerTask bleedTimerTask;
|
||||
@ -297,6 +299,9 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
//Init HardcoreManager
|
||||
hardcoreManager = new HardcoreManager(this);
|
||||
|
||||
//Init PerkUtils
|
||||
perkUtils = new PerkUtils(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -849,4 +854,8 @@ public class mcMMO extends JavaPlugin {
|
||||
public HardcoreManager getHardcoreManager() {
|
||||
return hardcoreManager;
|
||||
}
|
||||
|
||||
public PerkUtils getPerkUtils() {
|
||||
return perkUtils;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -58,7 +57,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
pluginRef.getSkillTools().sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS,
|
||||
pluginRef.getSkillTools().getSuperAbilityOtherPlayerDeactivationStr(superAbilityType));
|
||||
new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType).runTaskLater(pluginRef,
|
||||
PerksUtils.handleCooldownPerks(player,
|
||||
pluginRef.getPerkUtils().handleCooldownPerks(player,
|
||||
pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR));
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
@ -88,7 +87,7 @@ public final class MessageOfTheDayUtils {
|
||||
*/
|
||||
public void displayXpPerks(Player player) {
|
||||
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
||||
// if (PerksUtils.handleXpPerks(player, 1, skill) > 1) {
|
||||
// if (pluginRef.getPerkUtils().handleXpPerks(player, 1, skill) > 1) {
|
||||
// player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.XP.Name"), pluginRef.getLocaleManager().getString("Perks.XP.Desc")));
|
||||
// return;
|
||||
// }
|
||||
@ -101,7 +100,7 @@ public final class MessageOfTheDayUtils {
|
||||
* @param player Target player
|
||||
*/
|
||||
public void displayCooldownPerks(Player player) {
|
||||
double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0);
|
||||
double cooldownReduction = 1 - (pluginRef.getPerkUtils().handleCooldownPerks(player, 12) / 12.0);
|
||||
|
||||
if (cooldownReduction > 0.0) {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
|
@ -1,16 +1,19 @@
|
||||
package com.gmail.nossr50.util.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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;
|
||||
public final class PerkUtils {
|
||||
private final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
||||
private final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
private PerksUtils() {
|
||||
public PerkUtils(mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public static int handleCooldownPerks(Player player, int cooldown) {
|
||||
public int handleCooldownPerks(Player player, int cooldown) {
|
||||
if (pluginRef.getPermissionTools().halvedCooldowns(player)) {
|
||||
cooldown *= 0.5;
|
||||
} else if (pluginRef.getPermissionTools().thirdedCooldowns(player)) {
|
||||
@ -29,7 +32,7 @@ public final class PerksUtils {
|
||||
* @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) {
|
||||
public int handleLuckyPerks(Player player, PrimarySkillType skill) {
|
||||
if (pluginRef.getPermissionTools().lucky(player, skill)) {
|
||||
return LUCKY_SKILL_ACTIVATION_CHANCE;
|
||||
}
|
@ -315,7 +315,7 @@ public class SkillTools {
|
||||
* @return the number of seconds remaining before the cooldown expires
|
||||
*/
|
||||
public int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
|
||||
return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
|
||||
return (int) (((deactivatedTimeStamp + (pluginRef.getPerkUtils().handleCooldownPerks(player, cooldown) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -401,10 +401,10 @@ public class SkillTools {
|
||||
|
||||
if(abilityLengthCap > 0)
|
||||
{
|
||||
ticks = PerksUtils.calculateAbilityLength(player, Math.min(abilityLengthCap, 2 + (mcMMOPlayer.getSkillLevel(skill) / abilityLengthVar)),
|
||||
ticks = pluginRef.getPerkUtils().calculateAbilityLength(player, Math.min(abilityLengthCap, 2 + (mcMMOPlayer.getSkillLevel(skill) / abilityLengthVar)),
|
||||
skill.getSuperAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
|
||||
} else {
|
||||
ticks = PerksUtils.calculateAbilityLength(player, 2 + ((mcMMOPlayer.getSkillLevel(skill)) / abilityLengthVar),
|
||||
ticks = pluginRef.getPerkUtils().calculateAbilityLength(player, 2 + ((mcMMOPlayer.getSkillLevel(skill)) / abilityLengthVar),
|
||||
skill.getSuperAbility().getMaxLength()) * Misc.TICK_CONVERSION_FACTOR;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user