diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 569badc04..73f9a6e7c 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -988,8 +988,8 @@ public final class ExperienceAPI { public static void addXpFromBlocks(ArrayList blockStates, McMMOPlayer mcMMOPlayer) { for (BlockState bs : blockStates) { for (PrimarySkillType skillType : PrimarySkillType.values()) { - if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) { - mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); + if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, bs.getType()) > 0) { + mcMMOPlayer.applyXpGain(skillType, mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); } } } @@ -1004,8 +1004,8 @@ public final class ExperienceAPI { */ public static void addXpFromBlocksBySkill(ArrayList blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) { for (BlockState bs : blockStates) { - if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) { - mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); + if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, bs.getType()) > 0) { + mcMMOPlayer.applyXpGain(skillType, mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); } } } @@ -1018,8 +1018,8 @@ public final class ExperienceAPI { */ public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) { for (PrimarySkillType skillType : PrimarySkillType.values()) { - if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) { - mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); + if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, blockState.getType()) > 0) { + mcMMOPlayer.applyXpGain(skillType, mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); } } } @@ -1032,8 +1032,8 @@ public final class ExperienceAPI { * @param skillType target primary skill */ public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) { - if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) { - mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); + if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, blockState.getType()) > 0) { + mcMMOPlayer.applyXpGain(skillType, mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); } } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 6ddf253b2..f5992dd82 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import org.bukkit.block.BlockState; @@ -25,11 +26,7 @@ public class Excavation { } protected static int getBlockXP(BlockState blockState) { - int xp = ExperienceConfig.getInstance().getXp(PrimarySkillType.EXCAVATION, blockState.getType()); - - /*if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) { - xp = mcMMO.getModManager().getBlock(blockState).getXpGain(); - }*/ + int xp = mcMMO.getConfigManager().getExperienceMapManager().getExcavationXp(blockState.getType()); return xp; } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 9942a6615..0639a1a89 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -148,7 +148,7 @@ public class HerbalismManager extends SkillManager { // } // } // else { - xp = ExperienceConfig.getInstance().getXp(skill, blockState.getType()); + xp = mcMMO.getConfigManager().getExperienceMapManager().getHerbalismXp(blockState.getType()); if (!oneBlockPlant) { //Kelp is actually two blocks mixed together diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index 51672ea9e..f7c96f73a 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -34,11 +34,7 @@ public class Mining { * @param blockState The {@link BlockState} to check ability activation for */ public static int getBlockXp(BlockState blockState) { - int xp = ExperienceConfig.getInstance().getXp(PrimarySkillType.MINING, blockState.getType()); - - /*if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) { - xp = mcMMO.getModManager().getBlock(blockState).getXpGain(); - }*/ + int xp = mcMMO.getConfigManager().getExperienceMapManager().getMiningXp(blockState.getType()); return xp; } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 20a60127a..59f8c923a 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -45,7 +45,7 @@ public final class Woodcutting { return mcMMO.getModManager().getBlock(blockState).getXpGain(); }*/ - return ExperienceConfig.getInstance().getXp(PrimarySkillType.WOODCUTTING, blockState.getType()); + return mcMMO.getConfigManager().getExperienceMapManager().getWoodcuttingXp(blockState.getType()); } /** diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java index c6cfbb801..c09333803 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.util.experience; +import com.gmail.nossr50.api.exceptions.InvalidSkillException; import com.gmail.nossr50.config.Unload; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; @@ -155,13 +156,37 @@ public class ExperienceMapManager implements Unload { return globalXpMult; } + /** + * Gets the block break XP value for a specific skill + * @param primarySkillType target skill + * @param material target material + * @return XP value for breaking this block for said skill + * @throws InvalidSkillException for skills that don't give block break experience + * @deprecated its faster to use direct calls to get XP, for example getMiningXP(Material material) instead of using this method + */ + @Deprecated + public float getBlockBreakXpValue(PrimarySkillType primarySkillType, Material material) throws InvalidSkillException { + switch(primarySkillType) + { + case MINING: + return getMiningXp(material); + case HERBALISM: + return getHerbalismXp(material); + case EXCAVATION: + return getExcavationXp(material); + case WOODCUTTING: + return getWoodcuttingXp(material); + default: + throw new InvalidSkillException(); + } + } + /** * Gets the taming XP for this entity * @param entityType target entity * @return value of XP for this entity */ - public float getTamingXp(EntityType entityType) - { + public float getTamingXp(EntityType entityType) { return tamingExperienceMap.get(entityType); }