2013-03-01 00:52:01 -05:00
|
|
|
package com.gmail.nossr50.config.treasure;
|
|
|
|
|
2018-07-23 22:13:57 -04:00
|
|
|
import com.gmail.nossr50.config.ConfigLoader;
|
|
|
|
import com.gmail.nossr50.datatypes.treasure.*;
|
|
|
|
import com.gmail.nossr50.util.EnchantmentUtils;
|
|
|
|
import com.gmail.nossr50.util.StringUtils;
|
2014-12-20 02:16:23 -05:00
|
|
|
import org.bukkit.ChatColor;
|
2013-09-15 01:05:10 -04:00
|
|
|
import org.bukkit.DyeColor;
|
2013-03-01 00:52:01 -05:00
|
|
|
import org.bukkit.Material;
|
2017-06-10 14:30:06 -04:00
|
|
|
import org.bukkit.TreeSpecies;
|
2013-03-01 00:52:01 -05:00
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
2013-10-07 15:59:20 +02:00
|
|
|
import org.bukkit.enchantments.Enchantment;
|
2013-04-11 21:40:09 -04:00
|
|
|
import org.bukkit.entity.EntityType;
|
2013-03-01 00:52:01 -05:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2013-09-15 21:09:32 -04:00
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
2016-03-11 22:42:47 -05:00
|
|
|
import org.bukkit.inventory.meta.PotionMeta;
|
2013-09-15 01:05:10 -04:00
|
|
|
import org.bukkit.material.Dye;
|
2017-06-10 14:16:31 -04:00
|
|
|
import org.bukkit.material.MaterialData;
|
2016-03-11 22:42:47 -05:00
|
|
|
import org.bukkit.potion.PotionData;
|
2013-04-11 21:40:09 -04:00
|
|
|
import org.bukkit.potion.PotionType;
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2018-07-23 22:13:57 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
2013-03-01 00:52:01 -05:00
|
|
|
|
|
|
|
public class TreasureConfig extends ConfigLoader {
|
2016-06-19 17:41:18 -04:00
|
|
|
|
2013-03-01 00:52:01 -05:00
|
|
|
private static TreasureConfig instance;
|
|
|
|
|
2017-06-14 21:14:09 -04:00
|
|
|
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>();
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2017-06-10 14:16:31 -04:00
|
|
|
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
|
|
|
|
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<String, List<HylianTreasure>>();
|
2016-06-19 17:41:18 -04:00
|
|
|
|
|
|
|
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
2013-10-07 15:59:20 +02:00
|
|
|
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
2013-03-01 00:52:01 -05:00
|
|
|
|
|
|
|
private TreasureConfig() {
|
|
|
|
super("treasures.yml");
|
|
|
|
loadKeys();
|
2013-10-29 15:38:20 -04:00
|
|
|
validate();
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public static TreasureConfig getInstance() {
|
|
|
|
if (instance == null) {
|
|
|
|
instance = new TreasureConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2013-10-29 15:38:20 -04:00
|
|
|
@Override
|
|
|
|
protected boolean validateKeys() {
|
|
|
|
// Validate all the settings!
|
|
|
|
List<String> reason = new ArrayList<String>();
|
|
|
|
|
|
|
|
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
|
|
|
|
double totalEnchantDropRate = 0;
|
|
|
|
double totalItemDropRate = 0;
|
|
|
|
|
|
|
|
for (Rarity rarity : Rarity.values()) {
|
|
|
|
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
|
|
|
|
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity.toString());
|
|
|
|
|
|
|
|
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0) && rarity != Rarity.TRAP && rarity != Rarity.RECORD) {
|
|
|
|
reason.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
|
|
|
|
reason.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
|
|
|
|
}
|
|
|
|
|
|
|
|
totalEnchantDropRate += enchantDropRate;
|
|
|
|
totalItemDropRate += itemDropRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
|
|
|
|
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
|
|
|
|
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return noErrorsInConfig(reason);
|
|
|
|
}
|
|
|
|
|
2013-03-01 00:52:01 -05:00
|
|
|
@Override
|
|
|
|
protected void loadKeys() {
|
2013-09-15 15:58:40 -04:00
|
|
|
if (config.getConfigurationSection("Treasures") != null) {
|
2013-10-07 13:09:46 -04:00
|
|
|
backup();
|
2013-09-15 16:09:41 -04:00
|
|
|
return;
|
2013-09-15 15:58:40 -04:00
|
|
|
}
|
|
|
|
|
2017-01-13 14:10:55 +09:00
|
|
|
loadTreasures("Fishing");
|
|
|
|
loadTreasures("Excavation");
|
|
|
|
loadTreasures("Hylian_Luck");
|
2013-10-07 15:59:20 +02:00
|
|
|
loadEnchantments();
|
2013-09-15 01:05:10 -04:00
|
|
|
|
|
|
|
for (EntityType entity : EntityType.values()) {
|
|
|
|
if (entity.isAlive()) {
|
2017-01-13 14:10:55 +09:00
|
|
|
loadTreasures("Shake." + entity.toString());
|
2013-09-15 01:05:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-13 14:10:55 +09:00
|
|
|
private void loadTreasures(String type) {
|
2013-09-15 01:05:10 -04:00
|
|
|
boolean isFishing = type.equals("Fishing");
|
|
|
|
boolean isShake = type.contains("Shake");
|
|
|
|
boolean isExcavation = type.equals("Excavation");
|
2013-10-04 10:27:18 -04:00
|
|
|
boolean isHylian = type.equals("Hylian_Luck");
|
2013-09-15 01:05:10 -04:00
|
|
|
|
|
|
|
ConfigurationSection treasureSection = config.getConfigurationSection(type);
|
2013-03-03 19:32:00 -05:00
|
|
|
|
|
|
|
if (treasureSection == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
// Initialize fishing HashMap
|
|
|
|
for (Rarity rarity : Rarity.values()) {
|
|
|
|
if (!fishingRewards.containsKey(rarity)) {
|
|
|
|
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-20 15:51:12 -04:00
|
|
|
for (String treasureName : treasureSection.getKeys(false)) {
|
2013-03-01 00:52:01 -05:00
|
|
|
// Validate all the things!
|
|
|
|
List<String> reason = new ArrayList<String>();
|
|
|
|
|
2014-04-05 18:31:01 +02:00
|
|
|
String[] treasureInfo = treasureName.split("[|]");
|
|
|
|
String materialName = treasureInfo[0];
|
|
|
|
|
2013-03-01 00:52:01 -05:00
|
|
|
/*
|
2013-09-15 01:05:10 -04:00
|
|
|
* Material, Amount, and Data
|
2013-03-01 00:52:01 -05:00
|
|
|
*/
|
2013-09-16 12:48:08 -04:00
|
|
|
Material material;
|
|
|
|
|
2016-03-11 22:42:47 -05:00
|
|
|
if (materialName.contains("INK_SACK")) {
|
2018-07-23 22:13:57 -04:00
|
|
|
material = Material.INK_SAC;
|
2017-06-10 14:16:31 -04:00
|
|
|
} else if (materialName.contains("COAL")) {
|
|
|
|
material = Material.COAL;
|
|
|
|
} else if (materialName.contains("INVENTORY")) {
|
2018-07-23 22:13:57 -04:00
|
|
|
// Use magic material BEDROCK to know that we're grabbing something from the inventory and not a normal treasure
|
2017-06-10 13:59:49 -04:00
|
|
|
if (!shakeMap.containsKey(EntityType.PLAYER))
|
|
|
|
shakeMap.put(EntityType.PLAYER, new ArrayList<ShakeTreasure>());
|
2018-07-23 22:13:57 -04:00
|
|
|
shakeMap.get(EntityType.PLAYER).add(new ShakeTreasure(new ItemStack(Material.BEDROCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
|
2014-12-20 23:54:24 +01:00
|
|
|
continue;
|
2016-06-19 17:41:18 -04:00
|
|
|
} else {
|
2014-04-05 18:31:01 +02:00
|
|
|
material = Material.matchMaterial(materialName);
|
2013-09-16 12:48:08 -04:00
|
|
|
}
|
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
2015-03-18 15:28:57 -04:00
|
|
|
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
if (material == null) {
|
2014-04-05 18:31:01 +02:00
|
|
|
reason.add("Invalid material: " + materialName);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
2013-10-06 09:51:33 +02:00
|
|
|
if (amount <= 0) {
|
|
|
|
reason.add("Amount of " + treasureName + " must be greater than 0! " + amount);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
|
2013-10-06 09:51:33 +02:00
|
|
|
reason.add("Data of " + treasureName + " is invalid! " + data);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XP, Drop Chance, and Drop Level
|
|
|
|
*/
|
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
int xp = config.getInt(type + "." + treasureName + ".XP");
|
|
|
|
double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
|
|
|
|
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
|
2013-03-01 00:52:01 -05:00
|
|
|
|
|
|
|
if (xp < 0) {
|
2013-10-06 09:51:33 +02:00
|
|
|
reason.add(treasureName + " has an invalid XP value: " + xp);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
if (dropChance < 0.0D) {
|
2013-10-06 09:51:33 +02:00
|
|
|
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dropLevel < 0) {
|
2013-10-06 09:51:33 +02:00
|
|
|
reason.add(treasureName + " has an invalid Drop_Level: " + dropLevel);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-09-15 01:05:10 -04:00
|
|
|
* Specific Types
|
2013-03-01 00:52:01 -05:00
|
|
|
*/
|
2013-10-07 15:59:20 +02:00
|
|
|
Rarity rarity = null;
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
if (isFishing) {
|
2013-10-07 15:59:20 +02:00
|
|
|
rarity = Rarity.getRarity(config.getString(type + "." + treasureName + ".Rarity"));
|
2013-09-15 01:05:10 -04:00
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
if (rarity == null) {
|
|
|
|
reason.add("Invalid Rarity for item: " + treasureName);
|
2013-04-11 21:40:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-09-15 01:05:10 -04:00
|
|
|
* Itemstack
|
2013-04-11 21:40:09 -04:00
|
|
|
*/
|
2013-09-15 01:05:10 -04:00
|
|
|
ItemStack item = null;
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2014-04-05 18:31:01 +02:00
|
|
|
if (materialName.contains("POTION")) {
|
2016-03-11 22:42:47 -05:00
|
|
|
Material mat = Material.matchMaterial(materialName);
|
|
|
|
if (mat == null) {
|
|
|
|
reason.add("Potion format for Treasures.yml has changed");
|
|
|
|
} else {
|
|
|
|
item = new ItemStack(mat, amount, data);
|
|
|
|
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
|
2016-06-19 17:41:18 -04:00
|
|
|
|
2016-03-11 22:42:47 -05:00
|
|
|
PotionType potionType = null;
|
|
|
|
try {
|
|
|
|
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
2016-06-19 17:41:18 -04:00
|
|
|
} catch (IllegalArgumentException ex) {
|
2016-03-11 22:42:47 -05:00
|
|
|
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
|
|
|
}
|
|
|
|
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
|
|
|
|
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
|
|
|
|
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
|
2016-06-19 17:41:18 -04:00
|
|
|
|
2014-12-20 02:16:23 -05:00
|
|
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
|
|
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
|
|
|
List<String> lore = new ArrayList<String>();
|
|
|
|
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
|
|
|
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
|
|
|
}
|
|
|
|
itemMeta.setLore(lore);
|
|
|
|
}
|
2016-03-11 22:42:47 -05:00
|
|
|
item.setItemMeta(itemMeta);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
2016-06-19 17:41:18 -04:00
|
|
|
} else if (materialName.contains("INK_SACK")) {
|
2014-04-05 18:31:01 +02:00
|
|
|
String color = materialName.substring(9);
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
try {
|
|
|
|
Dye dye = new Dye();
|
|
|
|
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
item = dye.toItemStack(amount);
|
2014-12-20 02:16:23 -05:00
|
|
|
|
|
|
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
|
|
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
|
|
|
item.setItemMeta(itemMeta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
|
|
|
List<String> lore = new ArrayList<String>();
|
|
|
|
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
|
|
|
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
|
|
|
}
|
|
|
|
itemMeta.setLore(lore);
|
|
|
|
item.setItemMeta(itemMeta);
|
|
|
|
}
|
2016-06-19 17:41:18 -04:00
|
|
|
} catch (IllegalArgumentException ex) {
|
2013-09-15 01:05:10 -04:00
|
|
|
reason.add("Invalid Dye_Color: " + color);
|
2013-04-11 21:40:09 -04:00
|
|
|
}
|
2016-06-19 17:41:18 -04:00
|
|
|
} else if (material != null) {
|
2014-04-05 18:31:01 +02:00
|
|
|
item = new ItemStack(material, amount, data);
|
2013-09-15 21:09:32 -04:00
|
|
|
|
|
|
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
2014-12-20 02:16:23 -05:00
|
|
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
2013-09-15 21:09:32 -04:00
|
|
|
item.setItemMeta(itemMeta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
|
|
|
ItemMeta itemMeta = item.getItemMeta();
|
2014-12-20 02:16:23 -05:00
|
|
|
List<String> lore = new ArrayList<String>();
|
|
|
|
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
|
|
|
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
|
|
|
}
|
|
|
|
itemMeta.setLore(lore);
|
2013-09-15 21:09:32 -04:00
|
|
|
item.setItemMeta(itemMeta);
|
|
|
|
}
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
2013-07-11 14:41:23 -04:00
|
|
|
|
2013-09-15 01:05:10 -04:00
|
|
|
if (noErrorsInConfig(reason)) {
|
|
|
|
if (isFishing) {
|
2013-10-07 15:59:20 +02:00
|
|
|
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
2016-06-19 17:41:18 -04:00
|
|
|
} else if (isShake) {
|
2013-09-15 01:05:10 -04:00
|
|
|
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
2017-06-10 14:16:31 -04:00
|
|
|
|
2017-06-10 13:59:49 -04:00
|
|
|
EntityType entityType = EntityType.valueOf(type.substring(6));
|
|
|
|
if (!shakeMap.containsKey(entityType))
|
|
|
|
shakeMap.put(entityType, new ArrayList<ShakeTreasure>());
|
|
|
|
shakeMap.get(entityType).add(shakeTreasure);
|
2016-06-19 17:41:18 -04:00
|
|
|
} else if (isExcavation) {
|
2013-09-15 01:05:10 -04:00
|
|
|
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
|
|
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
|
|
|
|
2017-06-10 14:16:31 -04:00
|
|
|
for (String blockType : dropList) {
|
2017-06-14 21:14:09 -04:00
|
|
|
if (!excavationMap.containsKey(blockType))
|
|
|
|
excavationMap.put(blockType, new ArrayList<ExcavationTreasure>());
|
|
|
|
excavationMap.get(blockType).add(excavationTreasure);
|
2014-02-03 10:47:07 -05:00
|
|
|
}
|
2016-06-19 17:41:18 -04:00
|
|
|
} else if (isHylian) {
|
2013-09-15 01:05:10 -04:00
|
|
|
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
|
|
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
|
|
|
|
2017-06-10 14:16:31 -04:00
|
|
|
for (String dropper : dropList) {
|
|
|
|
if (dropper.equals("Bushes")) {
|
|
|
|
AddHylianTreasure("Small_Fern", hylianTreasure);
|
|
|
|
AddHylianTreasure("Small_Grass", hylianTreasure);
|
2017-06-10 14:30:06 -04:00
|
|
|
for (TreeSpecies species : TreeSpecies.values()) {
|
|
|
|
AddHylianTreasure(StringUtils.getPrettyTreeSpeciesString(species) + "_Sapling", hylianTreasure);
|
|
|
|
}
|
|
|
|
|
2017-06-10 14:16:31 -04:00
|
|
|
AddHylianTreasure(StringUtils.getPrettyItemString(Material.DEAD_BUSH), hylianTreasure);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (dropper.equals("Flowers")) {
|
|
|
|
for (int i = 0; i < 9; i++) {
|
2018-07-23 22:13:57 -04:00
|
|
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialDataString(new MaterialData(Material.ROSE_RED, (byte) i)), hylianTreasure);
|
2017-06-10 14:16:31 -04:00
|
|
|
}
|
2018-07-23 22:13:57 -04:00
|
|
|
AddHylianTreasure(StringUtils.getPrettyItemString(Material.DANDELION), hylianTreasure);
|
2017-06-10 14:16:31 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (dropper.equals("Pots")) {
|
|
|
|
for (int i = 0; i < 14; i++) {
|
|
|
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialDataString(new MaterialData(Material.FLOWER_POT, (byte) i)), hylianTreasure);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
AddHylianTreasure(dropper, hylianTreasure);
|
2013-09-15 01:05:10 -04:00
|
|
|
}
|
2013-07-11 14:41:23 -04:00
|
|
|
}
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-10-07 15:59:20 +02:00
|
|
|
|
2017-06-10 14:16:31 -04:00
|
|
|
private void AddHylianTreasure(String dropper, HylianTreasure treasure) {
|
|
|
|
if (!hylianMap.containsKey(dropper))
|
|
|
|
hylianMap.put(dropper, new ArrayList<HylianTreasure>());
|
|
|
|
hylianMap.get(dropper).add(treasure);
|
|
|
|
}
|
|
|
|
|
2013-10-07 15:59:20 +02:00
|
|
|
private void loadEnchantments() {
|
|
|
|
for (Rarity rarity : Rarity.values()) {
|
|
|
|
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fishingEnchantments.containsKey(rarity)) {
|
|
|
|
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString());
|
|
|
|
|
|
|
|
if (enchantmentSection == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (String enchantmentName : enchantmentSection.getKeys(false)) {
|
|
|
|
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
|
|
|
|
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
|
|
|
|
|
|
|
if (enchantment == null) {
|
|
|
|
plugin.getLogger().warning("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-19 17:41:18 -04:00
|
|
|
public boolean getInventoryStealEnabled() {
|
|
|
|
return config.contains("Shake.PLAYER.INVENTORY");
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getInventoryStealStacks() {
|
|
|
|
return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks");
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getInventoryStealDropChance() {
|
|
|
|
return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance");
|
|
|
|
}
|
2014-12-20 23:54:24 +01:00
|
|
|
|
2016-06-19 17:41:18 -04:00
|
|
|
public int getInventoryStealDropLevel() {
|
|
|
|
return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level");
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getItemDropRate(int tier, Rarity rarity) {
|
|
|
|
return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getEnchantmentDropRate(int tier, Rarity rarity) {
|
|
|
|
return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
|
|
|
}
|
2013-10-07 15:59:20 +02:00
|
|
|
}
|