fishing treasures pt 2

This commit is contained in:
nossr50 2019-02-25 14:08:41 -08:00
parent 3fc9f26b8b
commit 99f0e029c2
5 changed files with 104 additions and 11 deletions

View File

@ -3,15 +3,13 @@ package com.gmail.nossr50.config.treasure;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.Registers;
import com.gmail.nossr50.config.UnsafeValueValidation;
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.datatypes.treasure.*;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EnchantmentUtils;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
@ -28,16 +26,20 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
public static final String DROP_LEVEL = "Drop_Level";
public static final String TIER = "Tier_";
public static final String ENCHANTMENTS_RARITY = "Enchantments_Rarity";
public static final String ITEM_DROP_RATES = "Item_Drop_Rates";
public static final String FISHING = "Fishing";
public static final String ENCHANTMENT_DROP_RATES = "Enchantment_Drop_Rates";
public static final String SHAKE = "Shake";
public static final String AMOUNT = "Amount";
public static final String XP = "XP";
public static final String CUSTOM_NAME = "Custom_Name";
public static final String LORE = "Lore";
public static final String RARITY = "Rarity";
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
public static final String ITEM_DROP_RATES = "Item_Drop_Rates";
public static final String FISHING = "Fishing";
public static final String ENCHANTMENT_DROP_RATES1 = "Enchantment_Drop_Rates";
public static final String ENCHANTMENT_DROP_RATES = ENCHANTMENT_DROP_RATES1;
public static final String SHAKE = "Shake";
/**
* This grabs an instance of this config class from the Config Manager
* This method is deprecated and will be removed in the future
@ -81,7 +83,86 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
try {
for (String treasureName : fishingTreasureNode.getList(TypeToken.of(String.class))) {
//Treasure Material Definition
Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
if(treasureMaterial != null)
{
ConfigurationNode currentTreasure = fishingTreasureNode.getNode(treasureName);
//TODO: Rewrite the entire treasure system because it sucks
/*
* TREASURE PARAMETERS
*/
int amount = currentTreasure.getNode(AMOUNT).getInt();
int xp = currentTreasure.getNode(XP).getInt();
String customName = null;
/*
* PARAMETER INIT
*/
ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode("Drops_From").getList(TypeToken.of(String.class)));
//VALIDATE AMOUNT
if(amount <= 0)
{
mcMMO.p.getLogger().severe("Excavation Treasure named "+treasureName+" in the config has an amount of 0 or below, is this intentional?");
mcMMO.p.getLogger().severe("Skipping "+treasureName+" for being invalid");
continue;
}
//VALIDATE XP
if(xp <= 0)
{
mcMMO.p.getLogger().info("Excavation Treasure named "+treasureName+" in the config has xp set to 0 or below, is this intentional?");
xp = 0;
}
//VALIDATE DROP SOURCES
if(dropsFrom == null || dropsFrom.isEmpty())
{
mcMMO.p.getLogger().severe("Excavation Treasure named "+treasureName+" in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
mcMMO.p.getLogger().severe("Skipping "+treasureName+" for being invalid");
continue;
}
/* OPTIONAL PARAMETERS */
//Custom Name
if(currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe"))
{
customName = currentTreasure.getNode(CUSTOM_NAME).getString();
}
/*
* REGISTER TREASURE
*/
FishingTreasure fishingTreasure = TreasureFactory.makeFishingTreasure(treasureMaterial, amount, xp, customName, currentTreasure.getNode(LORE));
/*
* Add to map
*/
String configRarity = currentTreasure.getNode(RARITY).getString();
for(Rarity rarity : Rarity.values())
{
if(rarity.toString().equalsIgnoreCase(configRarity))
{
if(fishingRewards.get(rarity) == null)
fishingRewards.put(rarity, new ArrayList<>());
fishingRewards.get(rarity).add(fishingTreasure);
}
}
} else {
mcMMO.p.getLogger().severe("Excavation Treasure Config - Material named "+treasureName+" does not match any known material.");
}
}
} catch (ObjectMappingException e) {
e.printStackTrace();

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.config.treasure;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode;
@ -41,6 +42,13 @@ public class TreasureFactory {
return new ExcavationTreasure(treasure, xpReward, dropChance, dropLevel);
}
public static FishingTreasure makeFishingTreasure(Material material, int dropAmount, int xpReward, String customName, ConfigurationNode customLore)
{
ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
return new FishingTreasure(treasure, xpReward);
}
public static HylianTreasure makeHylianTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore)
{
ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);

View File

@ -1,6 +1,8 @@
package com.gmail.nossr50.datatypes.player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.experience.SkillXpGain;

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.datatypes.skills.subskills;
import com.gmail.nossr50.config.CoreSkillsConfig;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Rank;
@ -41,7 +42,7 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S
@Override @Deprecated
public boolean isEnabled() {
//TODO: This might be troublesome...
return CoreSkillConfig.getInstance().isSkillEnabled(this);
return CoreSkillsConfig.getInstance().isSkillEnabled(this);
}
/**

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util.experience;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;