Static Abuse Removal - PlayerLevelUtils -> PlayerLevelTools

This commit is contained in:
nossr50 2019-07-04 06:03:44 -07:00
parent 376e156646
commit 8f540796ff
5 changed files with 19 additions and 16 deletions

View File

@ -186,7 +186,7 @@ public class McMMOPlayer {
continue; continue;
//Set the players custom XP modifier, defaults to 1.0D on missing entries //Set the players custom XP modifier, defaults to 1.0D on missing entries
personalXPModifiers.put(primarySkillType, pluginRef.getPlayerLevelUtils().determineXpPerkValue(player, primarySkillType)); personalXPModifiers.put(primarySkillType, pluginRef.getPlayerLevelTools().determineXpPerkValue(player, primarySkillType));
} }
} }

View File

@ -7,7 +7,7 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.PlayerLevelUtils; import com.gmail.nossr50.util.player.PlayerLevelTools;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -86,7 +86,7 @@ public class SelfListener implements Listener {
int earlyGameBonusXP = 0; int earlyGameBonusXP = 0;
//Give some bonus XP for low levels //Give some bonus XP for low levels
if(PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) if(PlayerLevelTools.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType))
{ {
earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05); earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05);
event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP); event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP);

View File

@ -36,7 +36,7 @@ import com.gmail.nossr50.util.commands.CommandTools;
import com.gmail.nossr50.util.experience.FormulaManager; import com.gmail.nossr50.util.experience.FormulaManager;
import com.gmail.nossr50.util.nbt.NBTManager; import com.gmail.nossr50.util.nbt.NBTManager;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.PlayerLevelUtils; import com.gmail.nossr50.util.player.PlayerLevelTools;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.CombatTools; import com.gmail.nossr50.util.skills.CombatTools;
@ -71,8 +71,6 @@ public class mcMMO extends JavaPlugin {
private DynamicSettingsManager dynamicSettingsManager; private DynamicSettingsManager dynamicSettingsManager;
private DatabaseManager databaseManager; private DatabaseManager databaseManager;
private FormulaManager formulaManager; private FormulaManager formulaManager;
private MaterialMapStore materialMapStore;
private PlayerLevelUtils playerLevelUtils;
private NotificationManager notificationManager; private NotificationManager notificationManager;
private CommandRegistrationManager commandRegistrationManager; private CommandRegistrationManager commandRegistrationManager;
private NBTManager nbtManager; private NBTManager nbtManager;
@ -91,6 +89,8 @@ public class mcMMO extends JavaPlugin {
private SkillTools skillTools; //TODO: Remove once a new skill system is in place private SkillTools skillTools; //TODO: Remove once a new skill system is in place
private CombatTools combatTools; //TODO: Rewrite this garbo private CombatTools combatTools; //TODO: Rewrite this garbo
private TextComponentFactory textComponentFactory; private TextComponentFactory textComponentFactory;
private PlayerLevelTools playerLevelTools;
private MaterialMapStore materialMapStore;
/* Never-Ending tasks */ /* Never-Ending tasks */
private BleedTimerTask bleedTimerTask; private BleedTimerTask bleedTimerTask;
@ -179,7 +179,7 @@ public class mcMMO extends JavaPlugin {
commandRegistrationManager = new CommandRegistrationManager(this); commandRegistrationManager = new CommandRegistrationManager(this);
commandRegistrationManager.registerCommands(); commandRegistrationManager.registerCommands();
nbtManager = new NBTManager(); nbtManager = new NBTManager(this);
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
@ -215,7 +215,7 @@ public class mcMMO extends JavaPlugin {
materialMapStore = new MaterialMapStore(); materialMapStore = new MaterialMapStore();
//Init player level values //Init player level values
playerLevelUtils = new PlayerLevelUtils(); playerLevelTools = new PlayerLevelTools(this);
//Init Notification Manager //Init Notification Manager
notificationManager = new NotificationManager(this); notificationManager = new NotificationManager(this);
@ -309,8 +309,8 @@ public class mcMMO extends JavaPlugin {
getPartyManager().loadParties(); getPartyManager().loadParties();
} }
public PlayerLevelUtils getPlayerLevelUtils() { public PlayerLevelTools getPlayerLevelTools() {
return playerLevelUtils; return playerLevelTools;
} }
/** /**

View File

@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.PlayerLevelUtils; import com.gmail.nossr50.util.player.PlayerLevelTools;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle; import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar; import org.bukkit.boss.BossBar;
@ -55,7 +55,7 @@ public class ExperienceBarWrapper {
private String getTitleTemplate() { private String getTitleTemplate() {
//If they are using extra details //If they are using extra details
if(pluginRef.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { if(pluginRef.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelTools.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) {
return pluginRef.getLocaleManager().getString("XPBar.Template.EarlyGameBoost"); return pluginRef.getLocaleManager().getString("XPBar.Template.EarlyGameBoost");
} else if(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().isMoreDetailedXPBars()) } else if(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().isMoreDetailedXPBars())
return pluginRef.getLocaleManager().getString("XPBar.Complex.Template", pluginRef.getLocaleManager().getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); return pluginRef.getLocaleManager().getString("XPBar.Complex.Template", pluginRef.getLocaleManager().getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
@ -122,7 +122,7 @@ public class ExperienceBarWrapper {
bossBar.setProgress(v); bossBar.setProgress(v);
//Check player level //Check player level
if(pluginRef.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { if(pluginRef.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelTools.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) {
setColor(BarColor.YELLOW); setColor(BarColor.YELLOW);
} else { } else {
setColor(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().getXPBarColor(primarySkillType)); setColor(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().getXPBarColor(primarySkillType));

View File

@ -3,16 +3,19 @@ package com.gmail.nossr50.util.player;
import com.gmail.nossr50.datatypes.experience.CustomXPPerk; import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
public class PlayerLevelUtils { public class PlayerLevelTools {
private final mcMMO pluginRef;
private HashSet<CustomXPPerk> customXpPerkNodes; private HashSet<CustomXPPerk> customXpPerkNodes;
public PlayerLevelUtils() { public PlayerLevelTools(mcMMO pluginRef) {
this.pluginRef = pluginRef;
registerCustomPerkPermissions(); registerCustomPerkPermissions();
applyConfigPerks(); applyConfigPerks();
} }
@ -39,7 +42,7 @@ public class PlayerLevelUtils {
* @param primarySkillType target skill * @param primarySkillType target skill
* @return if the player would qualify for the XP boost if its enabled * @return if the player would qualify for the XP boost if its enabled
*/ */
public static boolean qualifiesForEarlyGameBoost(McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType) { public boolean qualifiesForEarlyGameBoost(McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType) {
return mcMMOPlayer.getSkillLevel(primarySkillType) < 1; return mcMMOPlayer.getSkillLevel(primarySkillType) < 1;
} }