From 315b713005383839162f75362854ba1b4555df00 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sun, 19 Jun 2016 17:41:18 -0400 Subject: [PATCH] These should definently not be hard coded in the future... but allow rabbits and guardians to be shaken down --- .../config/treasure/TreasureConfig.java | 201 +++++++++--------- .../gmail/nossr50/skills/fishing/Fishing.java | 9 + 2 files changed, 109 insertions(+), 101 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index 8821ed48e..33e653b65 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -28,47 +28,51 @@ import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.util.EnchantmentUtils; public class TreasureConfig extends ConfigLoader { + private static TreasureConfig instance; - public List excavationFromDirt = new ArrayList(); - public List excavationFromGrass = new ArrayList(); - public List excavationFromSand = new ArrayList(); - public List excavationFromGravel = new ArrayList(); - public List excavationFromClay = new ArrayList(); - public List excavationFromMycel = new ArrayList(); - public List excavationFromSoulSand = new ArrayList(); - public List excavationFromSnow = new ArrayList(); - public List excavationFromRedSand = new ArrayList(); - public List excavationFromPodzol = new ArrayList(); + public List excavationFromDirt = new ArrayList(); + public List excavationFromGrass = new ArrayList(); + public List excavationFromSand = new ArrayList(); + public List excavationFromGravel = new ArrayList(); + public List excavationFromClay = new ArrayList(); + public List excavationFromMycel = new ArrayList(); + public List excavationFromSoulSand = new ArrayList(); + public List excavationFromSnow = new ArrayList(); + public List excavationFromRedSand = new ArrayList(); + public List excavationFromPodzol = new ArrayList(); public List hylianFromBushes = new ArrayList(); public List hylianFromFlowers = new ArrayList(); public List hylianFromPots = new ArrayList(); - public List shakeFromBlaze = new ArrayList(); - public List shakeFromCaveSpider = new ArrayList(); - public List shakeFromSpider = new ArrayList(); - public List shakeFromChicken = new ArrayList(); - public List shakeFromCow = new ArrayList(); - public List shakeFromCreeper = new ArrayList(); - public List shakeFromEnderman = new ArrayList(); - public List shakeFromGhast = new ArrayList(); - public List shakeFromHorse = new ArrayList(); - public List shakeFromIronGolem = new ArrayList(); - public List shakeFromMagmaCube = new ArrayList(); - public List shakeFromMushroomCow = new ArrayList(); - public List shakeFromPig = new ArrayList(); - public List shakeFromPigZombie = new ArrayList(); - public List shakeFromPlayer = new ArrayList(); - public List shakeFromSheep = new ArrayList(); - public List shakeFromSkeleton = new ArrayList(); - public List shakeFromSlime = new ArrayList(); - public List shakeFromSnowman = new ArrayList(); - public List shakeFromSquid = new ArrayList(); - public List shakeFromWitch = new ArrayList(); - public List shakeFromZombie = new ArrayList(); + public List shakeFromBlaze = new ArrayList(); + public List shakeFromCaveSpider = new ArrayList(); + public List shakeFromSpider = new ArrayList(); + public List shakeFromChicken = new ArrayList(); + public List shakeFromCow = new ArrayList(); + public List shakeFromCreeper = new ArrayList(); + public List shakeFromEnderman = new ArrayList(); + public List shakeFromGhast = new ArrayList(); + public List shakeFromHorse = new ArrayList(); + public List shakeFromIronGolem = new ArrayList(); + public List shakeFromMagmaCube = new ArrayList(); + public List shakeFromMushroomCow = new ArrayList(); + public List shakeFromPig = new ArrayList(); + public List shakeFromPigZombie = new ArrayList(); + public List shakeFromPlayer = new ArrayList(); + public List shakeFromSheep = new ArrayList(); + public List shakeFromSkeleton = new ArrayList(); + public List shakeFromSlime = new ArrayList(); + public List shakeFromSnowman = new ArrayList(); + public List shakeFromSquid = new ArrayList(); + public List shakeFromWitch = new ArrayList(); + public List shakeFromZombie = new ArrayList(); + public List shakeFromRabbit = new ArrayList(); + public List shakeFromElderGuardian = new ArrayList(); + public List shakeFromGuardian = new ArrayList(); - public HashMap> fishingRewards = new HashMap>(); + public HashMap> fishingRewards = new HashMap>(); public HashMap> fishingEnchantments = new HashMap>(); private TreasureConfig() { @@ -174,13 +178,11 @@ public class TreasureConfig extends ConfigLoader { if (materialName.contains("INK_SACK")) { material = Material.INK_SACK; - } - else if (materialName.contains("INVENTORY")) { + } else if (materialName.contains("INVENTORY")) { // Use magic material BED_BLOCK to know that we're grabbing something from the inventory and not a normal treasure shakeFromPlayer.add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel())); continue; - } - else { + } else { material = Material.matchMaterial(materialName); } @@ -244,18 +246,17 @@ public class TreasureConfig extends ConfigLoader { } else { item = new ItemStack(mat, amount, data); PotionMeta itemMeta = (PotionMeta) item.getItemMeta(); - + PotionType potionType = null; try { potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER")); - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { 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)); - + if (config.contains(type + "." + treasureName + ".Custom_Name")) { itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name"))); } @@ -269,8 +270,7 @@ public class TreasureConfig extends ConfigLoader { } item.setItemMeta(itemMeta); } - } - else if (materialName.contains("INK_SACK")) { + } else if (materialName.contains("INK_SACK")) { String color = materialName.substring(9); try { @@ -294,12 +294,10 @@ public class TreasureConfig extends ConfigLoader { itemMeta.setLore(lore); item.setItemMeta(itemMeta); } - } - catch (IllegalArgumentException ex) { + } catch (IllegalArgumentException ex) { reason.add("Invalid Dye_Color: " + color); } - } - else if (material != null) { + } else if (material != null) { item = new ItemStack(material, amount, data); if (config.contains(type + "." + treasureName + ".Custom_Name")) { @@ -322,78 +320,61 @@ public class TreasureConfig extends ConfigLoader { if (noErrorsInConfig(reason)) { if (isFishing) { fishingRewards.get(rarity).add(new FishingTreasure(item, xp)); - } - else if (isShake) { + } else if (isShake) { ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel); if (type.equals("Shake.BLAZE")) { shakeFromBlaze.add(shakeTreasure); - } - else if (type.equals("Shake.CAVE_SPIDER")) { + } else if (type.equals("Shake.CAVE_SPIDER")) { shakeFromCaveSpider.add(shakeTreasure); - } - else if (type.equals("Shake.CHICKEN")) { + } else if (type.equals("Shake.CHICKEN")) { shakeFromChicken.add(shakeTreasure); - } - else if (type.equals("Shake.COW")) { + } else if (type.equals("Shake.COW")) { shakeFromCow.add(shakeTreasure); - } - else if (type.equals("Shake.CREEPER")) { + } else if (type.equals("Shake.CREEPER")) { shakeFromCreeper.add(shakeTreasure); - } - else if (type.equals("Shake.ENDERMAN")) { + } else if (type.equals("Shake.ENDERMAN")) { shakeFromEnderman.add(shakeTreasure); - } - else if (type.equals("Shake.GHAST")) { + } else if (type.equals("Shake.GHAST")) { shakeFromGhast.add(shakeTreasure); - } - else if (type.equals("Shake.HORSE")) { + } else if (type.equals("Shake.HORSE")) { shakeFromHorse.add(shakeTreasure); - } - else if (type.equals("Shake.IRON_GOLEM")) { + } else if (type.equals("Shake.IRON_GOLEM")) { shakeFromIronGolem.add(shakeTreasure); - } - else if (type.equals("Shake.MAGMA_CUBE")) { + } else if (type.equals("Shake.MAGMA_CUBE")) { shakeFromMagmaCube.add(shakeTreasure); - } - else if (type.equals("Shake.MUSHROOM_COW")) { + } else if (type.equals("Shake.MUSHROOM_COW")) { shakeFromMushroomCow.add(shakeTreasure); - } - else if (type.equals("Shake.PIG")) { + } else if (type.equals("Shake.PIG")) { shakeFromPig.add(shakeTreasure); - } - else if (type.equals("Shake.PIG_ZOMBIE")) { + } else if (type.equals("Shake.PIG_ZOMBIE")) { shakeFromPigZombie.add(shakeTreasure); - } - else if (type.equals("Shake.PLAYER")) { + } else if (type.equals("Shake.PLAYER")) { shakeFromPlayer.add(shakeTreasure); - } - else if (type.equals("Shake.SHEEP")) { + } else if (type.equals("Shake.SHEEP")) { shakeFromSheep.add(shakeTreasure); - } - else if (type.equals("Shake.SKELETON")) { + } else if (type.equals("Shake.SKELETON")) { shakeFromSkeleton.add(shakeTreasure); - } - else if (type.equals("Shake.SLIME")) { + } else if (type.equals("Shake.SLIME")) { shakeFromSlime.add(shakeTreasure); - } - else if (type.equals("Shake.SPIDER")) { + } else if (type.equals("Shake.SPIDER")) { shakeFromSpider.add(shakeTreasure); - } - else if (type.equals("Shake.SNOWMAN")) { + } else if (type.equals("Shake.SNOWMAN")) { shakeFromSnowman.add(shakeTreasure); - } - else if (type.equals("Shake.SQUID")) { + } else if (type.equals("Shake.SQUID")) { shakeFromSquid.add(shakeTreasure); - } - else if (type.equals("Shake.WITCH")) { + } else if (type.equals("Shake.WITCH")) { shakeFromWitch.add(shakeTreasure); - } - else if (type.equals("Shake.ZOMBIE")) { + } else if (type.equals("Shake.ZOMBIE")) { shakeFromZombie.add(shakeTreasure); + } else if (type.equals("Shake.RABBIT")) { + shakeFromRabbit.add(shakeTreasure); + } else if (type.equals("Shake.GUARDIAN")) { + shakeFromGuardian.add(shakeTreasure); + } else if (type.equals("Shake.ELDER_GUARDIAN")) { + shakeFromElderGuardian.add(shakeTreasure); } - } - else if (isExcavation) { + } else if (isExcavation) { ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); List dropList = config.getStringList(type + "." + treasureName + ".Drops_From"); @@ -436,8 +417,7 @@ public class TreasureConfig extends ConfigLoader { if (dropList.contains("Podzol")) { excavationFromPodzol.add(excavationTreasure); } - } - else if (isHylian) { + } else if (isHylian) { HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel); List dropList = config.getStringList(type + "." + treasureName + ".Drops_From"); @@ -455,6 +435,9 @@ public class TreasureConfig extends ConfigLoader { } } } + // Fallthrough if not specified + if (shakeFromElderGuardian.isEmpty()) + shakeFromElderGuardian = shakeFromGuardian; } private void loadEnchantments() { @@ -487,11 +470,27 @@ public class TreasureConfig extends ConfigLoader { } } - 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"); } - public int getInventoryStealDropLevel() { return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level"); } + public boolean getInventoryStealEnabled() { + return config.contains("Shake.PLAYER.INVENTORY"); + } - 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()); } + public boolean getInventoryStealStacks() { + return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks"); + } + + public double getInventoryStealDropChance() { + return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance"); + } + + 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()); + } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 0c299bc62..16c513a51 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -8,6 +8,7 @@ import java.util.Set; import org.bukkit.Material; import org.bukkit.block.Biome; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Guardian; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; @@ -133,6 +134,14 @@ public final class Fishing { case ZOMBIE: return TreasureConfig.getInstance().shakeFromZombie; + + case RABBIT: + return TreasureConfig.getInstance().shakeFromRabbit; + + case GUARDIAN: + if (((Guardian) target).isElder()) + return TreasureConfig.getInstance().shakeFromElderGuardian; + return TreasureConfig.getInstance().shakeFromGuardian; default: return null;