From 8f540796ff2ed7118429ff2a46df106ada312e93 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 4 Jul 2019 06:03:44 -0700 Subject: [PATCH] Static Abuse Removal - PlayerLevelUtils -> PlayerLevelTools --- .../nossr50/datatypes/player/McMMOPlayer.java | 2 +- .../com/gmail/nossr50/listeners/SelfListener.java | 4 ++-- src/main/java/com/gmail/nossr50/mcMMO.java | 14 +++++++------- .../util/experience/ExperienceBarWrapper.java | 6 +++--- ...PlayerLevelUtils.java => PlayerLevelTools.java} | 9 ++++++--- 5 files changed, 19 insertions(+), 16 deletions(-) rename src/main/java/com/gmail/nossr50/util/player/{PlayerLevelUtils.java => PlayerLevelTools.java} (93%) diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 10d4007d9..6c26a3443 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -186,7 +186,7 @@ public class McMMOPlayer { continue; //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)); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 127332328..b94f64a51 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -7,7 +7,7 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; 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.worldguard.WorldGuardUtils; import org.bukkit.entity.Player; @@ -86,7 +86,7 @@ public class SelfListener implements Listener { int earlyGameBonusXP = 0; //Give some bonus XP for low levels - if(PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) + if(PlayerLevelTools.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { earlyGameBonusXP += (mcMMOPlayer.getXpToLevel(primarySkillType) * 0.05); event.setRawXpGained(event.getRawXpGained() + earlyGameBonusXP); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 41dcb4fd6..072c0c98b 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -36,7 +36,7 @@ import com.gmail.nossr50.util.commands.CommandTools; import com.gmail.nossr50.util.experience.FormulaManager; import com.gmail.nossr50.util.nbt.NBTManager; 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.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.CombatTools; @@ -71,8 +71,6 @@ public class mcMMO extends JavaPlugin { private DynamicSettingsManager dynamicSettingsManager; private DatabaseManager databaseManager; private FormulaManager formulaManager; - private MaterialMapStore materialMapStore; - private PlayerLevelUtils playerLevelUtils; private NotificationManager notificationManager; private CommandRegistrationManager commandRegistrationManager; 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 CombatTools combatTools; //TODO: Rewrite this garbo private TextComponentFactory textComponentFactory; + private PlayerLevelTools playerLevelTools; + private MaterialMapStore materialMapStore; /* Never-Ending tasks */ private BleedTimerTask bleedTimerTask; @@ -179,7 +179,7 @@ public class mcMMO extends JavaPlugin { commandRegistrationManager = new CommandRegistrationManager(this); commandRegistrationManager.registerCommands(); - nbtManager = new NBTManager(); + nbtManager = new NBTManager(this); placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager @@ -215,7 +215,7 @@ public class mcMMO extends JavaPlugin { materialMapStore = new MaterialMapStore(); //Init player level values - playerLevelUtils = new PlayerLevelUtils(); + playerLevelTools = new PlayerLevelTools(this); //Init Notification Manager notificationManager = new NotificationManager(this); @@ -309,8 +309,8 @@ public class mcMMO extends JavaPlugin { getPartyManager().loadParties(); } - public PlayerLevelUtils getPlayerLevelUtils() { - return playerLevelUtils; + public PlayerLevelTools getPlayerLevelTools() { + return playerLevelTools; } /** diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java index 6d70043ce..4af9146fc 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java @@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; 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.BarStyle; import org.bukkit.boss.BossBar; @@ -55,7 +55,7 @@ public class ExperienceBarWrapper { private String getTitleTemplate() { //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"); } else if(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().isMoreDetailedXPBars()) 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); //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); } else { setColor(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().getXPBarColor(primarySkillType)); diff --git a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelTools.java similarity index 93% rename from src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java rename to src/main/java/com/gmail/nossr50/util/player/PlayerLevelTools.java index 8f39e6ecb..f273fdb81 100644 --- a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java +++ b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelTools.java @@ -3,16 +3,19 @@ package com.gmail.nossr50.util.player; import com.gmail.nossr50.datatypes.experience.CustomXPPerk; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.entity.Player; import java.util.Collections; import java.util.HashSet; -public class PlayerLevelUtils { +public class PlayerLevelTools { + private final mcMMO pluginRef; private HashSet customXpPerkNodes; - public PlayerLevelUtils() { + public PlayerLevelTools(mcMMO pluginRef) { + this.pluginRef = pluginRef; registerCustomPerkPermissions(); applyConfigPerks(); } @@ -39,7 +42,7 @@ public class PlayerLevelUtils { * @param primarySkillType target skill * @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; }