mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Introduction of new Alchemy skill!
This commit is contained in:
@ -6,6 +6,7 @@ import java.util.List;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
||||
@ -79,6 +80,38 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
reason.add("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
|
||||
}
|
||||
|
||||
/* ALCHEMY */
|
||||
if (getCatalysisUnlockLevel() < 0) {
|
||||
reason.add("Skills.Alchemy.Catalysis.UnlockLevel should be at least 0!");
|
||||
}
|
||||
|
||||
if (getCatalysisMaxBonusLevel() <= getCatalysisUnlockLevel()) {
|
||||
reason.add("Skills.Alchemy.Catalysis.MaxBonusLevel should be greater than Skills.Alchemy.Catalysis.UnlockLevel!");
|
||||
}
|
||||
|
||||
if (getCatalysisMinSpeed() <= 0) {
|
||||
reason.add("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
|
||||
}
|
||||
|
||||
if (getCatalysisMaxSpeed() < getCatalysisMinSpeed()) {
|
||||
reason.add("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
|
||||
}
|
||||
|
||||
List<Alchemy.Tier> alchemyTierList = Arrays.asList(Alchemy.Tier.values());
|
||||
for (Alchemy.Tier tier : alchemyTierList) {
|
||||
if (getConcoctionsTierLevel(tier) < 0) {
|
||||
reason.add("Skills.Alchemy.Rank_Levels.Rank_" + tier.toNumerical() + " should be at least 0!");
|
||||
}
|
||||
|
||||
if (tier != Alchemy.Tier.fromNumerical(Alchemy.Tier.values().length)) {
|
||||
Alchemy.Tier nextTier = alchemyTierList.get(alchemyTierList.indexOf(tier) - 1);
|
||||
|
||||
if (getConcoctionsTierLevel(tier) >= getConcoctionsTierLevel(nextTier)) {
|
||||
reason.add("Skills.Alchemy.Rank_Levels.Rank_" + tier.toNumerical() + " should be less than Skills.Alchemy.Rank_Levels.Rank_" + nextTier.toNumerical() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ARCHERY */
|
||||
if (getSkillShotIncreaseLevel() < 1) {
|
||||
reason.add("Skills.Archery.SkillShot.IncreaseLevel should be at least 1!");
|
||||
@ -624,6 +657,14 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
public double getGracefulRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.GracefulRoll.DamageThreshold", 14.0D); }
|
||||
|
||||
/* ALCHEMY */
|
||||
public int getCatalysisUnlockLevel() { return config.getInt("Skills.Alchemy.Catalysis.UnlockLevel", 100); }
|
||||
public int getCatalysisMaxBonusLevel() { return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000); }
|
||||
public double getCatalysisMinSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MinSpeed", 1.0D); }
|
||||
public double getCatalysisMaxSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MaxSpeed", 4.0D); }
|
||||
|
||||
public int getConcoctionsTierLevel(Alchemy.Tier tier) { return config.getInt("Skills.Alchemy.Rank_Levels.Rank_" + tier.toNumerical()); }
|
||||
|
||||
/* ARCHERY */
|
||||
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot.IncreaseLevel", 50); }
|
||||
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot.IncreasePercentage", 0.1D); }
|
||||
|
@ -403,6 +403,10 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
public boolean getPreventXPAfterTeleport() { return config.getBoolean("Skills.Acrobatics.Prevent_XP_After_Teleport", true); }
|
||||
|
||||
/* Alchemy */
|
||||
public boolean getEnabledForHoppers() { return config.getBoolean("Skills.Alchemy.Enabled_for_Hoppers", true); }
|
||||
public boolean getPreventHopperTransfer() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer", false); }
|
||||
|
||||
/* Fishing */
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
|
||||
|
@ -76,6 +76,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* Alchemy */
|
||||
if (getPotionXP() <= 0) {
|
||||
reason.add("Experience.Alchemy.Potion should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
if (getAnimalsXP() < 0) {
|
||||
reason.add("Experience.Combat.Multiplier.Animals should be at least 0!");
|
||||
@ -199,6 +204,9 @@ 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); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
|
||||
|
188
src/main/java/com/gmail/nossr50/config/potion/PotionConfig.java
Normal file
188
src/main/java/com/gmail/nossr50/config/potion/PotionConfig.java
Normal file
@ -0,0 +1,188 @@
|
||||
package com.gmail.nossr50.config.potion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.AlchemyPotion;
|
||||
|
||||
public class PotionConfig extends ConfigLoader {
|
||||
private static PotionConfig instance;
|
||||
|
||||
public List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierThree = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierFour = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierFive = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierSix = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
||||
|
||||
public Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
|
||||
|
||||
private PotionConfig() {
|
||||
super("potions.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static PotionConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PotionConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
loadConcoctions();
|
||||
loadPotionMap();
|
||||
}
|
||||
|
||||
private void loadConcoctions() {
|
||||
ConfigurationSection concoctionSection = config.getConfigurationSection("Concoctions");
|
||||
|
||||
loadConcoctionsTier(concoctionsIngredientsTierOne, concoctionSection.getStringList("Tier_One_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierTwo, concoctionSection.getStringList("Tier_Two_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierThree, concoctionSection.getStringList("Tier_Three_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierFour, concoctionSection.getStringList("Tier_Four_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierFive, concoctionSection.getStringList("Tier_Five_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierSix, concoctionSection.getStringList("Tier_Six_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierSeven, concoctionSection.getStringList("Tier_Seven_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierEight, concoctionSection.getStringList("Tier_Eight_Ingredients"));
|
||||
|
||||
concoctionsIngredientsTierTwo.addAll(concoctionsIngredientsTierOne);
|
||||
concoctionsIngredientsTierThree.addAll(concoctionsIngredientsTierTwo);
|
||||
concoctionsIngredientsTierFour.addAll(concoctionsIngredientsTierThree);
|
||||
concoctionsIngredientsTierFive.addAll(concoctionsIngredientsTierFour);
|
||||
concoctionsIngredientsTierSix.addAll(concoctionsIngredientsTierFive);
|
||||
concoctionsIngredientsTierSeven.addAll(concoctionsIngredientsTierSix);
|
||||
concoctionsIngredientsTierEight.addAll(concoctionsIngredientsTierSeven);
|
||||
}
|
||||
|
||||
private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredientStrings) {
|
||||
if (ingredientStrings != null && ingredientStrings.size() > 0) {
|
||||
for (String ingredientString : ingredientStrings) {
|
||||
ItemStack ingredient = loadIngredient(ingredientString);
|
||||
|
||||
if (ingredient != null) {
|
||||
ingredientList.add(ingredient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the Potions configuration section and load all defined potions.
|
||||
*/
|
||||
private void loadPotionMap() {
|
||||
ConfigurationSection potionSection = config.getConfigurationSection("Potions");
|
||||
int pass = 0;
|
||||
int fail = 0;
|
||||
|
||||
for (String dataValue : potionSection.getKeys(false)) {
|
||||
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(dataValue));
|
||||
|
||||
if (potion != null) {
|
||||
potionMap.put(potion.getDataValue(), potion);
|
||||
pass++;
|
||||
}
|
||||
else {
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a ConfigurationSection representing a AlchemyPotion.
|
||||
* Returns null if input cannot be parsed.
|
||||
*
|
||||
* @param potion_section ConfigurationSection to be parsed.
|
||||
* @return Parsed AlchemyPotion.
|
||||
*/
|
||||
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
||||
try {
|
||||
short dataValue = Short.parseShort(potion_section.getName());
|
||||
|
||||
String name = potion_section.getString("Name");
|
||||
|
||||
List<String> lore = new ArrayList<String>();
|
||||
if (potion_section.contains("Lore")) {
|
||||
for (String line : potion_section.getStringList("Lore")) {
|
||||
lore.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
List<PotionEffect> effects = new ArrayList<PotionEffect>();
|
||||
if (potion_section.contains("Effects")) {
|
||||
for (String effect : potion_section.getStringList("Effects")) {
|
||||
String[] parts = effect.split(" ");
|
||||
|
||||
PotionEffectType type = parts.length > 0 ? PotionEffectType.getByName(parts[0]) : null;
|
||||
int amplifier = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;
|
||||
int duration = parts.length > 2 ? Integer.parseInt(parts[2]) : 0;
|
||||
|
||||
if (type != null) {
|
||||
effects.add(new PotionEffect(type, duration, amplifier));
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse effect for potion " + name + ": " + effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<ItemStack, Short> children = new HashMap<ItemStack, Short>();
|
||||
if (potion_section.contains("Children")) {
|
||||
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
|
||||
ItemStack ingredient = loadIngredient(child);
|
||||
if (ingredient != null) {
|
||||
children.put(ingredient, Short.parseShort(potion_section.getConfigurationSection("Children").getString(child)));
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new AlchemyPotion(dataValue, name, lore, effects, children);
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string representation of an ingredient.
|
||||
* Format: '<MATERIAL>[:data]'
|
||||
* Returns null if input cannot be parsed.
|
||||
*
|
||||
* @param ingredient String representing an ingredient.
|
||||
* @return Parsed ingredient.
|
||||
*/
|
||||
private ItemStack loadIngredient(String ingredient) {
|
||||
if (ingredient == null || ingredient.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String[] parts = ingredient.split(":");
|
||||
|
||||
Material material = parts.length > 0 ? Material.getMaterial(parts[0]) : null;
|
||||
short data = parts.length > 1 ? Short.parseShort(parts[1]) : 0;
|
||||
|
||||
if (material != null) {
|
||||
return new ItemStack(material, 1, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user