mcMMO/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java

63 lines
2.1 KiB
Java

package com.gmail.nossr50.skills.alchemy;
import java.util.List;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.StringUtils;
public class AlchemyManager extends SkillManager {
private final double LUCKY_MODIFIER = 4.0 / 3.0;
public AlchemyManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, PrimarySkillType.ALCHEMY);
}
public int getTier() {
for (Alchemy.Tier tier : Alchemy.Tier.values()) {
if (getSkillLevel() >= tier.getLevel()) {
return tier.toNumerical();
}
}
return 0;
}
public List<ItemStack> getIngredients() {
return PotionConfig.getInstance().getIngredients(getTier());
}
public String getIngredientList() {
StringBuilder list = new StringBuilder();
for (ItemStack ingredient : getIngredients()) {
String string = StringUtils.getPrettyItemString(ingredient.getType());
list.append(", ").append(string);
}
return list.substring(2);
}
public double calculateBrewSpeed(boolean isLucky) {
int skillLevel = getSkillLevel();
if (skillLevel < Alchemy.catalysisUnlockLevel) {
return Alchemy.catalysisMinSpeed;
}
return Math.min(Alchemy.catalysisMaxSpeed, Alchemy.catalysisMinSpeed + (Alchemy.catalysisMaxSpeed - Alchemy.catalysisMinSpeed) * (skillLevel - Alchemy.catalysisUnlockLevel) / (Alchemy.catalysisMaxBonusLevel - Alchemy.catalysisUnlockLevel)) * (isLucky ? LUCKY_MODIFIER : 1.0);
}
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP(potionStage) * amount), XPGainReason.PVE);
}
}