mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 10:14:43 +02:00
@ -13,6 +13,7 @@ import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
@ -80,8 +81,10 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
*/
|
||||
|
||||
/* Alchemy */
|
||||
if (getPotionXP() <= 0) {
|
||||
reason.add("Experience.Alchemy.Potion should be greater than 0!");
|
||||
for (PotionStage potionStage : PotionStage.values()) {
|
||||
if (getPotionXP(potionStage) < 0) {
|
||||
reason.add("Experience.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
|
||||
}
|
||||
}
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
@ -201,7 +204,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
|
||||
|
||||
/* Alchemy */
|
||||
public double getPotionXP() { return config.getDouble("Experience.Alchemy.Potion", 150D); }
|
||||
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishXp(MaterialData data) {
|
||||
|
@ -0,0 +1,70 @@
|
||||
package com.gmail.nossr50.datatypes.skills.alchemy;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.Potion;
|
||||
|
||||
public enum PotionStage {
|
||||
FIVE(5),
|
||||
FOUR(4),
|
||||
THREE(3),
|
||||
TWO(2),
|
||||
ONE(1);
|
||||
|
||||
int numerical;
|
||||
|
||||
private PotionStage(int numerical) {
|
||||
this.numerical = numerical;
|
||||
}
|
||||
|
||||
public int toNumerical() {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
private static PotionStage getPotionStageNumerical(int numerical) {
|
||||
for (PotionStage potionStage : values()) {
|
||||
if (numerical >= potionStage.toNumerical()) {
|
||||
return potionStage;
|
||||
}
|
||||
}
|
||||
|
||||
return ONE;
|
||||
}
|
||||
|
||||
public static PotionStage getPotionStage(AlchemyPotion input, AlchemyPotion output) {
|
||||
PotionStage potionStage = getPotionStage(output);
|
||||
if (getPotionStage(input) == potionStage) {
|
||||
potionStage = PotionStage.FIVE;
|
||||
}
|
||||
|
||||
return potionStage;
|
||||
}
|
||||
|
||||
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
|
||||
Potion potion = Potion.fromItemStack(new ItemStack(Material.POTION, 1, alchemyPotion.getDataValue()));
|
||||
|
||||
int stage = 1;
|
||||
|
||||
// Check if potion isn't awkward or mundane
|
||||
if (potion.getType() != null) {
|
||||
stage++;
|
||||
}
|
||||
|
||||
// Check if potion has a glowstone dust amplifier
|
||||
if (potion.getLevel() > 1) {
|
||||
stage++;
|
||||
}
|
||||
|
||||
// Check if potion has a redstone dust amplifier
|
||||
if (potion.hasExtendedDuration()) {
|
||||
stage++;
|
||||
}
|
||||
|
||||
// Check if potion has a gunpowder amplifier
|
||||
if (potion.isSplash()) {
|
||||
stage++;
|
||||
}
|
||||
|
||||
return PotionStage.getPotionStageNumerical(stage);
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
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;
|
||||
|
||||
@ -64,7 +65,7 @@ public class AlchemyManager extends SkillManager {
|
||||
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(int amount) {
|
||||
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP() * amount), XPGainReason.PVE);
|
||||
public void handlePotionBrewSuccesses(PotionStage potionStage, int amount) {
|
||||
applyXpGain((float) (ExperienceConfig.getInstance().getPotionXP(potionStage) * amount), XPGainReason.PVE);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||
import com.gmail.nossr50.events.fake.FakeBrewEvent;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.runnables.skills.AlchemyBrewCheckTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@ -122,7 +123,8 @@ public final class AlchemyPotionBrewer {
|
||||
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
|
||||
|
||||
if (player != null) {
|
||||
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(1);
|
||||
PotionStage potionStage = PotionStage.getPotionStage(input, output);
|
||||
UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user