Wire up Alchemy XP config values

This commit is contained in:
nossr50 2019-04-10 03:01:14 -07:00
parent fb6e5e41ad
commit e156d6d5ef
4 changed files with 23 additions and 17 deletions

View File

@ -160,14 +160,6 @@ public class ExperienceConfig extends ConfigValidated {
/*
* XP SETTINGS
*/
/* Alchemy */
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add(EXPERIENCE + "." + ALCHEMY + "." + POTION_STAGE + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
reason.add(EXPERIENCE + "." + ARCHERY + "." + DISTANCE + MULTIPLIER + " should be at least 0!");
@ -387,11 +379,6 @@ public class ExperienceConfig extends ConfigValidated {
return BarStyle.SOLID;
}
/* Alchemy */
public double getPotionXP(PotionStage stage) {
return getDoubleValue(EXPERIENCE, ALCHEMY, POTION_STAGE + stage.toNumerical());
}
/* Archery */
public double getArcheryDistanceMultiplier() {
return getDoubleValue(EXPERIENCE, ARCHERY, DISTANCE + MULTIPLIER);

View File

@ -136,8 +136,8 @@ public class ConfigExperience {
return experienceAlchemy.getStageFourPotionXP();
}
public int getStageFivePotionXP() {
return experienceAlchemy.getStageFivePotionXP();
public int getPotionXPByStage(int potionStage) {
return experienceAlchemy.getPotionXPByStage(potionStage);
}
public boolean isPvpXPEnabled() {

View File

@ -46,10 +46,27 @@ public class ConfigExperienceAlchemy {
return alchemyXPMap.get("Stage-Four-Potion");
}
public int getStageFivePotionXP()
/*public int getStageFivePotionXP()
{
//This is purposely zero to prevent an exploit
return 0;
}*/
public int getPotionXPByStage(int potionStage)
{
switch(potionStage)
{
case 1:
return getStageOnePotionXP();
case 2:
return getStageTwoPotionXP();
case 3:
return getStageThreePotionXP();
case 4:
return getStageFourPotionXP();
default:
return 0; //Zero XP is intentional to prevent some infinite loop XP exploit
}
}
}

View File

@ -8,6 +8,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.RankUtils;
@ -53,6 +54,7 @@ public class AlchemyManager extends SkillManager {
}
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP(potionStage) * amount), XPGainReason.PVE, XPGainSource.PASSIVE);
//TODO: This code disturbs me
applyXpGain((float) (mcMMO.getConfigManager().getConfigExperience().getExperienceAlchemy().getPotionXPByStage(potionStage.toNumerical()) * amount), XPGainReason.PVE, XPGainSource.PASSIVE);
}
}