Wire up Mining/Excavation/Herbalism/Woodcutting XP values

This commit is contained in:
nossr50 2019-04-30 02:08:11 -07:00
parent 2efa64ae17
commit 4d8e4d0e70
6 changed files with 40 additions and 22 deletions

View File

@ -988,8 +988,8 @@ public final class ExperienceAPI {
public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) { public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) {
for (BlockState bs : blockStates) { for (BlockState bs : blockStates) {
for (PrimarySkillType skillType : PrimarySkillType.values()) { for (PrimarySkillType skillType : PrimarySkillType.values()) {
if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) { if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, bs.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); 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<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) { public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
for (BlockState bs : blockStates) { for (BlockState bs : blockStates) {
if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) { if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, bs.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF); 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) { public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) {
for (PrimarySkillType skillType : PrimarySkillType.values()) { for (PrimarySkillType skillType : PrimarySkillType.values()) {
if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) { if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, blockState.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); 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 * @param skillType target primary skill
*/ */
public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) { public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) { if (mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, blockState.getType()) > 0) {
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF); mcMMOPlayer.applyXpGain(skillType, mcMMO.getConfigManager().getExperienceMapManager().getBlockBreakXpValue(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
} }
} }

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -25,11 +26,7 @@ public class Excavation {
} }
protected static int getBlockXP(BlockState blockState) { protected static int getBlockXP(BlockState blockState) {
int xp = ExperienceConfig.getInstance().getXp(PrimarySkillType.EXCAVATION, blockState.getType()); int xp = mcMMO.getConfigManager().getExperienceMapManager().getExcavationXp(blockState.getType());
/*if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
}*/
return xp; return xp;
} }

View File

@ -148,7 +148,7 @@ public class HerbalismManager extends SkillManager {
// } // }
// } // }
// else { // else {
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getType()); xp = mcMMO.getConfigManager().getExperienceMapManager().getHerbalismXp(blockState.getType());
if (!oneBlockPlant) { if (!oneBlockPlant) {
//Kelp is actually two blocks mixed together //Kelp is actually two blocks mixed together

View File

@ -34,11 +34,7 @@ public class Mining {
* @param blockState The {@link BlockState} to check ability activation for * @param blockState The {@link BlockState} to check ability activation for
*/ */
public static int getBlockXp(BlockState blockState) { public static int getBlockXp(BlockState blockState) {
int xp = ExperienceConfig.getInstance().getXp(PrimarySkillType.MINING, blockState.getType()); int xp = mcMMO.getConfigManager().getExperienceMapManager().getMiningXp(blockState.getType());
/*if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
}*/
return xp; return xp;
} }

View File

@ -45,7 +45,7 @@ public final class Woodcutting {
return mcMMO.getModManager().getBlock(blockState).getXpGain(); return mcMMO.getModManager().getBlock(blockState).getXpGain();
}*/ }*/
return ExperienceConfig.getInstance().getXp(PrimarySkillType.WOODCUTTING, blockState.getType()); return mcMMO.getConfigManager().getExperienceMapManager().getWoodcuttingXp(blockState.getType());
} }
/** /**

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.util.experience; package com.gmail.nossr50.util.experience;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.Unload; import com.gmail.nossr50.config.Unload;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -155,13 +156,37 @@ public class ExperienceMapManager implements Unload {
return globalXpMult; 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 * Gets the taming XP for this entity
* @param entityType target entity * @param entityType target entity
* @return value of XP for this entity * @return value of XP for this entity
*/ */
public float getTamingXp(EntityType entityType) public float getTamingXp(EntityType entityType) {
{
return tamingExperienceMap.get(entityType); return tamingExperienceMap.get(entityType);
} }