|
@@ -1,274 +1,274 @@
|
|
-package com.gmail.nossr50.config.treasure;
|
|
|
|
-
|
|
|
|
-import com.gmail.nossr50.config.Config;
|
|
|
|
-import com.gmail.nossr50.config.ConfigConstants;
|
|
|
|
-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.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.enchantments.Enchantment;
|
|
|
|
-import org.bukkit.entity.EntityType;
|
|
|
|
-
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-public class FishingTreasureConfig extends Config implements UnsafeValueValidation {
|
|
|
|
- public static final String PLAYER = "PLAYER";
|
|
|
|
- public static final String INVENTORY = "INVENTORY";
|
|
|
|
- public static final String WHOLE_STACKS = "Whole_Stacks";
|
|
|
|
- public static final String DROP_CHANCE = "Drop_Chance";
|
|
|
|
- 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 static final String DROPS_FROM = "Drops_From";
|
|
|
|
-
|
|
|
|
- public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
|
|
|
|
- public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
|
|
|
|
- public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>();
|
|
|
|
-
|
|
|
|
- public FishingTreasureConfig() {
|
|
|
|
- super("fishing_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * This grabs an instance of this config class from the Config Manager
|
|
|
|
- * This method is deprecated and will be removed in the future
|
|
|
|
- *
|
|
|
|
- * @return the instance of this config
|
|
|
|
- * @see mcMMO#getConfigManager()
|
|
|
|
- * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
|
|
|
- */
|
|
|
|
- @Deprecated
|
|
|
|
- public static FishingTreasureConfig getInstance() {
|
|
|
|
- return pluginRef.getConfigManager().getFishingTreasureConfig();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void loadShake(EntityType entityType) {
|
|
|
|
- ConfigurationNode shakeTreasureNode = getUserRootNode().getNode(SHAKE, entityType.toString());
|
|
|
|
-
|
|
|
|
- if (shakeTreasureNode != null)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- for (ConfigurationNode treasureNode : shakeTreasureNode.getChildrenList()) {
|
|
|
|
-
|
|
|
|
- String treasureName = treasureNode.getString();
|
|
|
|
- //Treasure Material Definition
|
|
|
|
- Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
|
|
|
|
-
|
|
|
|
- if (treasureMaterial != null) {
|
|
|
|
- ConfigurationNode currentTreasure = shakeTreasureNode.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();
|
|
|
|
- double dropChance = currentTreasure.getNode(DROP_CHANCE).getDouble();
|
|
|
|
- int dropLevel = currentTreasure.getNode(DROP_LEVEL).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) {
|
|
|
|
- pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?");
|
|
|
|
- pluginRef.getLogger().severe("Skipping " + treasureName + " for being invalid");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //VALIDATE XP
|
|
|
|
- if (xp <= 0) {
|
|
|
|
- pluginRef.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?");
|
|
|
|
- xp = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //VALIDATE DROP CHANCE
|
|
|
|
- if (dropChance <= 0) {
|
|
|
|
- pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?");
|
|
|
|
- pluginRef.getLogger().severe("Skipping " + treasureName + " for being invalid");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //VALIDATE DROP LEVEL
|
|
|
|
- if (dropLevel < 0) {
|
|
|
|
- pluginRef.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?");
|
|
|
|
- dropLevel = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //VALIDATE DROP SOURCES
|
|
|
|
- if (dropsFrom == null || dropsFrom.isEmpty()) {
|
|
|
|
- pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
|
|
|
|
- pluginRef.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
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- ShakeTreasure shakeTreasure = TreasureFactory.makeShakeTreasure(treasureMaterial, amount, xp, dropChance, dropLevel, customName, currentTreasure.getNode(LORE));
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * Add to map
|
|
|
|
- */
|
|
|
|
- shakeMap.computeIfAbsent(entityType, k -> new ArrayList<>());
|
|
|
|
-
|
|
|
|
- shakeMap.get(entityType).add(shakeTreasure);
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- pluginRef.getLogger().severe("Excavation Treasure Config - Material named " + treasureName + " does not match any known material.");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } catch (ObjectMappingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void loadEnchantments() {
|
|
|
|
- for (Rarity rarity : Rarity.values()) {
|
|
|
|
- if (rarity == Rarity.RECORD) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!fishingEnchantments.containsKey(rarity)) {
|
|
|
|
- fishingEnchantments.put(rarity, (new ArrayList<>()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ConfigurationNode enchantmentSection = getUserRootNode().getNode(ENCHANTMENTS_RARITY, rarity.toString());
|
|
|
|
-
|
|
|
|
- if (enchantmentSection == null) {
|
|
|
|
- pluginRef.getLogger().info("No enchantment information for fishing treasures, is this intentional?");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (ConfigurationNode enchantmentNode : enchantmentSection.getChildrenList()) {
|
|
|
|
-
|
|
|
|
- String enchantmentName = enchantmentNode.getString();
|
|
|
|
- int level = getIntValue(ENCHANTMENTS_RARITY, rarity.toString(), enchantmentName);
|
|
|
|
- Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
|
|
|
-
|
|
|
|
- if (enchantment == null) {
|
|
|
|
- pluginRef.getLogger().severe("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<String> validateKeys() {
|
|
|
|
- // Validate all the settings!
|
|
|
|
- List<String> errorMessages = new ArrayList<>();
|
|
|
|
- try {
|
|
|
|
- for (String tier : getUserRootNode().getNode(ENCHANTMENT_DROP_RATES).getList(TypeToken.of(String.class))) {
|
|
|
|
- /*double totalEnchantDropRate = 0;
|
|
|
|
- double totalItemDropRate = 0;*/
|
|
|
|
-
|
|
|
|
- for (Rarity rarity : Rarity.values()) {
|
|
|
|
- double enchantDropRate = getDoubleValue(ENCHANTMENT_DROP_RATES, tier, rarity.toString());
|
|
|
|
- double itemDropRate = getDoubleValue(ITEM_DROP_RATES, tier, rarity.toString());
|
|
|
|
-
|
|
|
|
- if ((enchantDropRate < 0.0 || enchantDropRate > 100.0) && rarity != Rarity.RECORD) {
|
|
|
|
- errorMessages.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
|
|
|
-
|
|
|
|
- //Bound Values
|
|
|
|
- /*enchantDropRate = boundValues(enchantDropRate, 0.0D, 100.0D);*/
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (itemDropRate < 0.0 || itemDropRate > 100.0) {
|
|
|
|
- errorMessages.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
|
|
|
-
|
|
|
|
- //Bound Values
|
|
|
|
- /*itemDropRate = boundValues(itemDropRate, 0.0D, 100.0D);*/
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*totalEnchantDropRate += enchantDropRate;
|
|
|
|
- totalItemDropRate += itemDropRate;*/
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //TODO: Why does it matter what the total item/enchant drop rate is?
|
|
|
|
-
|
|
|
|
- /*if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
|
|
|
|
- errorMessages.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
|
|
|
|
- errorMessages.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
|
|
|
|
- }*/
|
|
|
|
- }
|
|
|
|
- } catch (ObjectMappingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return errorMessages;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * The version of this config
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public double getConfigVersion() {
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public boolean getInventoryStealEnabled() {
|
|
|
|
- return hasNode(SHAKE, PLAYER, INVENTORY);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public boolean getInventoryStealStacks() {
|
|
|
|
- return getBooleanValue(SHAKE, PLAYER, INVENTORY, WHOLE_STACKS);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public double getInventoryStealDropChance() {
|
|
|
|
- return getDoubleValue(SHAKE, PLAYER, INVENTORY, DROP_CHANCE);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public int getInventoryStealDropLevel() {
|
|
|
|
- return getIntValue(SHAKE, PLAYER, INVENTORY, DROP_LEVEL);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public double getItemDropRate(int tier, Rarity rarity) {
|
|
|
|
- return getDoubleValue(ITEM_DROP_RATES, TIER + tier, rarity.toString());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public double getEnchantmentDropRate(int tier, Rarity rarity) {
|
|
|
|
- return getDoubleValue(ENCHANTMENT_DROP_RATES, TIER + tier, rarity.toString());
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+//package com.gmail.nossr50.config.treasure;
|
|
|
|
+//
|
|
|
|
+//import com.gmail.nossr50.config.Config;
|
|
|
|
+//import com.gmail.nossr50.config.ConfigConstants;
|
|
|
|
+//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.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.enchantments.Enchantment;
|
|
|
|
+//import org.bukkit.entity.EntityType;
|
|
|
|
+//
|
|
|
|
+//import java.util.ArrayList;
|
|
|
|
+//import java.util.HashMap;
|
|
|
|
+//import java.util.List;
|
|
|
|
+//
|
|
|
|
+//public class FishingTreasureConfig extends Config implements UnsafeValueValidation {
|
|
|
|
+// public static final String PLAYER = "PLAYER";
|
|
|
|
+// public static final String INVENTORY = "INVENTORY";
|
|
|
|
+// public static final String WHOLE_STACKS = "Whole_Stacks";
|
|
|
|
+// public static final String DROP_CHANCE = "Drop_Chance";
|
|
|
|
+// 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 static final String DROPS_FROM = "Drops_From";
|
|
|
|
+//
|
|
|
|
+// public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<>();
|
|
|
|
+// public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<>();
|
|
|
|
+// public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<>();
|
|
|
|
+//
|
|
|
|
+// public FishingTreasureConfig() {
|
|
|
|
+// super("fishing_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// /**
|
|
|
|
+// * This grabs an instance of this config class from the Config Manager
|
|
|
|
+// * This method is deprecated and will be removed in the future
|
|
|
|
+// *
|
|
|
|
+// * @return the instance of this config
|
|
|
|
+// * @see mcMMO#getConfigManager()
|
|
|
|
+// * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
|
|
|
+// */
|
|
|
|
+// @Deprecated
|
|
|
|
+// public static FishingTreasureConfig getInstance() {
|
|
|
|
+// return pluginRef.getConfigManager().getFishingTreasureConfig();
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// private void loadShake(EntityType entityType) {
|
|
|
|
+// ConfigurationNode shakeTreasureNode = getUserRootNode().getNode(SHAKE, entityType.toString());
|
|
|
|
+//
|
|
|
|
+// if (shakeTreasureNode != null)
|
|
|
|
+// return;
|
|
|
|
+//
|
|
|
|
+// try {
|
|
|
|
+// for (ConfigurationNode treasureNode : shakeTreasureNode.getChildrenList()) {
|
|
|
|
+//
|
|
|
|
+// String treasureName = treasureNode.getString();
|
|
|
|
+// //Treasure Material Definition
|
|
|
|
+// Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
|
|
|
|
+//
|
|
|
|
+// if (treasureMaterial != null) {
|
|
|
|
+// ConfigurationNode currentTreasure = shakeTreasureNode.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();
|
|
|
|
+// double dropChance = currentTreasure.getNode(DROP_CHANCE).getDouble();
|
|
|
|
+// int dropLevel = currentTreasure.getNode(DROP_LEVEL).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) {
|
|
|
|
+// pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?");
|
|
|
|
+// pluginRef.getLogger().severe("Skipping " + treasureName + " for being invalid");
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //VALIDATE XP
|
|
|
|
+// if (xp <= 0) {
|
|
|
|
+// pluginRef.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?");
|
|
|
|
+// xp = 0;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //VALIDATE DROP CHANCE
|
|
|
|
+// if (dropChance <= 0) {
|
|
|
|
+// pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?");
|
|
|
|
+// pluginRef.getLogger().severe("Skipping " + treasureName + " for being invalid");
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //VALIDATE DROP LEVEL
|
|
|
|
+// if (dropLevel < 0) {
|
|
|
|
+// pluginRef.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?");
|
|
|
|
+// dropLevel = 0;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //VALIDATE DROP SOURCES
|
|
|
|
+// if (dropsFrom == null || dropsFrom.isEmpty()) {
|
|
|
|
+// pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
|
|
|
|
+// pluginRef.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
|
|
|
|
+// */
|
|
|
|
+//
|
|
|
|
+// ShakeTreasure shakeTreasure = TreasureFactory.makeShakeTreasure(treasureMaterial, amount, xp, dropChance, dropLevel, customName, currentTreasure.getNode(LORE));
|
|
|
|
+//
|
|
|
|
+// /*
|
|
|
|
+// * Add to map
|
|
|
|
+// */
|
|
|
|
+// shakeMap.computeIfAbsent(entityType, k -> new ArrayList<>());
|
|
|
|
+//
|
|
|
|
+// shakeMap.get(entityType).add(shakeTreasure);
|
|
|
|
+//
|
|
|
|
+// } else {
|
|
|
|
+// pluginRef.getLogger().severe("Excavation Treasure Config - Material named " + treasureName + " does not match any known material.");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// } catch (ObjectMappingException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// private void loadEnchantments() {
|
|
|
|
+// for (Rarity rarity : Rarity.values()) {
|
|
|
|
+// if (rarity == Rarity.RECORD) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (!fishingEnchantments.containsKey(rarity)) {
|
|
|
|
+// fishingEnchantments.put(rarity, (new ArrayList<>()));
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// ConfigurationNode enchantmentSection = getUserRootNode().getNode(ENCHANTMENTS_RARITY, rarity.toString());
|
|
|
|
+//
|
|
|
|
+// if (enchantmentSection == null) {
|
|
|
|
+// pluginRef.getLogger().info("No enchantment information for fishing treasures, is this intentional?");
|
|
|
|
+// return;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// for (ConfigurationNode enchantmentNode : enchantmentSection.getChildrenList()) {
|
|
|
|
+//
|
|
|
|
+// String enchantmentName = enchantmentNode.getString();
|
|
|
|
+// int level = getIntValue(ENCHANTMENTS_RARITY, rarity.toString(), enchantmentName);
|
|
|
|
+// Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
|
|
|
+//
|
|
|
|
+// if (enchantment == null) {
|
|
|
|
+// pluginRef.getLogger().severe("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// @Override
|
|
|
|
+// public List<String> validateKeys() {
|
|
|
|
+// // Validate all the settings!
|
|
|
|
+// List<String> errorMessages = new ArrayList<>();
|
|
|
|
+// try {
|
|
|
|
+// for (String tier : getUserRootNode().getNode(ENCHANTMENT_DROP_RATES).getList(TypeToken.of(String.class))) {
|
|
|
|
+// /*double totalEnchantDropRate = 0;
|
|
|
|
+// double totalItemDropRate = 0;*/
|
|
|
|
+//
|
|
|
|
+// for (Rarity rarity : Rarity.values()) {
|
|
|
|
+// double enchantDropRate = getDoubleValue(ENCHANTMENT_DROP_RATES, tier, rarity.toString());
|
|
|
|
+// double itemDropRate = getDoubleValue(ITEM_DROP_RATES, tier, rarity.toString());
|
|
|
|
+//
|
|
|
|
+// if ((enchantDropRate < 0.0 || enchantDropRate > 100.0) && rarity != Rarity.RECORD) {
|
|
|
|
+// errorMessages.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
|
|
|
+//
|
|
|
|
+// //Bound Values
|
|
|
|
+// /*enchantDropRate = boundValues(enchantDropRate, 0.0D, 100.0D);*/
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (itemDropRate < 0.0 || itemDropRate > 100.0) {
|
|
|
|
+// errorMessages.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
|
|
|
+//
|
|
|
|
+// //Bound Values
|
|
|
|
+// /*itemDropRate = boundValues(itemDropRate, 0.0D, 100.0D);*/
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// /*totalEnchantDropRate += enchantDropRate;
|
|
|
|
+// totalItemDropRate += itemDropRate;*/
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //TODO: Why does it matter what the total item/enchant drop rate is?
|
|
|
|
+//
|
|
|
|
+// /*if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
|
|
|
|
+// errorMessages.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
|
|
|
|
+// errorMessages.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
|
|
|
|
+// }*/
|
|
|
|
+// }
|
|
|
|
+// } catch (ObjectMappingException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// return errorMessages;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// /**
|
|
|
|
+// * The version of this config
|
|
|
|
+// *
|
|
|
|
+// * @return
|
|
|
|
+// */
|
|
|
|
+// @Override
|
|
|
|
+// public double getConfigVersion() {
|
|
|
|
+// return 1;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// public boolean getInventoryStealEnabled() {
|
|
|
|
+// return hasNode(SHAKE, PLAYER, INVENTORY);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// public boolean getInventoryStealStacks() {
|
|
|
|
+// return getBooleanValue(SHAKE, PLAYER, INVENTORY, WHOLE_STACKS);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// public double getInventoryStealDropChance() {
|
|
|
|
+// return getDoubleValue(SHAKE, PLAYER, INVENTORY, DROP_CHANCE);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// public int getInventoryStealDropLevel() {
|
|
|
|
+// return getIntValue(SHAKE, PLAYER, INVENTORY, DROP_LEVEL);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// public double getItemDropRate(int tier, Rarity rarity) {
|
|
|
|
+// return getDoubleValue(ITEM_DROP_RATES, TIER + tier, rarity.toString());
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// public double getEnchantmentDropRate(int tier, Rarity rarity) {
|
|
|
|
+// return getDoubleValue(ENCHANTMENT_DROP_RATES, TIER + tier, rarity.toString());
|
|
|
|
+// }
|
|
|
|
+//}
|