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 2465682f8..10d4007d9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -106,7 +106,7 @@ public class McMMOPlayer { toolMode.put(toolType, false); } - experienceBarManager = new ExperienceBarManager(this); + experienceBarManager = new ExperienceBarManager(pluginRef,this); fillPersonalXPModifiers(); //Cache players XP rates } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 3475200b0..41dcb4fd6 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -167,7 +167,7 @@ public class mcMMO extends JavaPlugin { registerCustomRecipes(); initParties(); - formulaManager = new FormulaManager(); + formulaManager = new FormulaManager(this); for (Player player : getServer().getOnlinePlayers()) { new PlayerProfileLoadingTask(this, player).runTaskLaterAsynchronously(this, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java b/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java index 0888740af..94c538efb 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java @@ -22,7 +22,7 @@ public final class CommandTools { } public boolean isChildSkill(CommandSender sender, PrimarySkillType skill) { - if (skill == null || !skill.isChildSkill()) { + if (skill == null || !pluginRef.getSkillTools().isChildSkill(skill)) { return false; } @@ -160,7 +160,7 @@ public final class CommandTools { * @param display The sender to display stats to */ public void printGatheringSkills(Player inspect, CommandSender display) { - printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Gathering"), PrimarySkillType.GATHERING_SKILLS); + printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Gathering"), pluginRef.getSkillTools().GATHERING_SKILLS); } public void printGatheringSkills(Player player) { @@ -174,7 +174,7 @@ public final class CommandTools { * @param display The sender to display stats to */ public void printCombatSkills(Player inspect, CommandSender display) { - printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Combat"), PrimarySkillType.COMBAT_SKILLS); + printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Combat"), pluginRef.getSkillTools().COMBAT_SKILLS); } public void printCombatSkills(Player player) { @@ -188,7 +188,7 @@ public final class CommandTools { * @param display The sender to display stats to */ public void printMiscSkills(Player inspect, CommandSender display) { - printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Misc"), PrimarySkillType.MISC_SKILLS); + printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Misc"), pluginRef.getSkillTools().MISC_SKILLS); } public void printMiscSkills(Player player) { @@ -196,7 +196,7 @@ public final class CommandTools { } public String displaySkill(PlayerProfile profile, PrimarySkillType skill) { - if (skill.isChildSkill()) { + if (pluginRef.getSkillTools().isChildSkill(skill)) { return pluginRef.getLocaleManager().getString("Skills.ChildStats", pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill)); } @@ -212,9 +212,9 @@ public final class CommandTools { List displayData = new ArrayList<>(); displayData.add(header); - for (PrimarySkillType skill : skillGroup) { - if (skill.doesPlayerHaveSkillPermission(inspect)) { - displayData.add(displaySkill(profile, skill)); + for (PrimarySkillType primarySkillType : skillGroup) { + if (pluginRef.getSkillTools().doesPlayerHaveSkillPermission(primarySkillType, inspect)) { + displayData.add(displaySkill(profile, primarySkillType)); } } diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java index 69d2d477e..71a700b65 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.util.experience; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask; import org.bukkit.plugin.Plugin; @@ -15,8 +16,11 @@ public class ExperienceBarManager { HashMap experienceBars; HashMap experienceBarHideTaskHashMap; private McMMOPlayer mcMMOPlayer; + private final mcMMO pluginRef; + + public ExperienceBarManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) { + this.pluginRef = pluginRef; - public ExperienceBarManager(McMMOPlayer mcMMOPlayer) { //Init map experienceBars = new HashMap<>(); experienceBarHideTaskHashMap = new HashMap<>(); @@ -30,7 +34,7 @@ public class ExperienceBarManager { //Init Bar if (experienceBars.get(primarySkillType) == null) - experienceBars.put(primarySkillType, new ExperienceBarWrapper(primarySkillType, mcMMOPlayer)); + experienceBars.put(primarySkillType, new ExperienceBarWrapper(pluginRef, primarySkillType, mcMMOPlayer)); //Get Bar ExperienceBarWrapper experienceBarWrapper = experienceBars.get(primarySkillType); 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 e07e32866..6d70043ce 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.util.experience; 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 org.bukkit.boss.BarColor; @@ -20,6 +21,7 @@ public class ExperienceBarWrapper { private final PrimarySkillType primarySkillType; //Primary Skill private BossBar bossBar; private int lastLevelUpdated; + private final mcMMO pluginRef; /* * This is stored to help optimize updating the title @@ -27,7 +29,8 @@ public class ExperienceBarWrapper { protected String niceSkillName; protected String title; - public ExperienceBarWrapper(PrimarySkillType primarySkillType, McMMOPlayer mcMMOPlayer) { + public ExperienceBarWrapper(mcMMO pluginRef, PrimarySkillType primarySkillType, McMMOPlayer mcMMOPlayer) { + this.pluginRef = pluginRef; this.mcMMOPlayer = mcMMOPlayer; this.primarySkillType = primarySkillType; title = ""; diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index 34f6978e2..9611f1a7f 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.util.experience; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import java.util.HashMap; import java.util.Map; @@ -14,8 +15,10 @@ public class FormulaManager { private Map experienceNeededStandardExponential; private FormulaType currentFormula; + private final mcMMO pluginRef; - public FormulaManager() { + public FormulaManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; currentFormula = pluginRef.getConfigManager().getConfigLeveling().getFormulaType(); initExperienceNeededMaps(); } diff --git a/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java b/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java index 5de5c8ec9..4418da4a8 100644 --- a/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java +++ b/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util.nbt; +import com.gmail.nossr50.mcMMO; import net.minecraft.server.v1_13_R2.NBTBase; import net.minecraft.server.v1_13_R2.NBTList; import net.minecraft.server.v1_13_R2.NBTTagCompound; @@ -13,8 +14,10 @@ public class NBTManager { private static final String CRAFT_META_ITEM_CLASS_PATH = "org.bukkit.craftbukkit.inventory.CraftMetaItem"; private Class craftMetaItemClass; + private final mcMMO pluginRef; - public NBTManager() { + public NBTManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; init(); //Setup method references etc } diff --git a/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java b/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java index 9c3aa5c76..1d72abe85 100644 --- a/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java +++ b/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.util.nbt; +import com.gmail.nossr50.mcMMO; import net.minecraft.server.v1_13_R2.NBTBase; /** @@ -27,7 +28,7 @@ public class RawNBT { this.nbtContents = nbtContents; } - public NBTBase getNbtData() { + public NBTBase getNbtData(mcMMO pluginRef) { return pluginRef.getNbtManager().constructNBT(nbtContents); } }