From ee02a19e9ad385462bb9f79d76aa32132653e1d3 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sat, 10 Jun 2017 13:59:49 -0400 Subject: [PATCH] Add more configuration to shake treasures --- .../config/treasure/TreasureConfig.java | 96 ++--------------- .../gmail/nossr50/skills/fishing/Fishing.java | 100 ++---------------- 2 files changed, 19 insertions(+), 177 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 4ca677ad3..f78943122 100755 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -36,33 +36,7 @@ public class TreasureConfig extends ConfigLoader { 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 shakeFromShulker = 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 shakeFromWitherSkeleton = new ArrayList(); - public List shakeFromZombie = new ArrayList(); - public List shakeFromRabbit = new ArrayList(); - public List shakeFromElderGuardian = new ArrayList(); - public List shakeFromGuardian = new ArrayList(); + public HashMap> shakeMap = new HashMap>(); public HashMap> fishingRewards = new HashMap>(); public HashMap> fishingEnchantments = new HashMap>(); @@ -174,7 +148,9 @@ public class TreasureConfig extends ConfigLoader { material = Material.COAL; } 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())); + if (!shakeMap.containsKey(EntityType.PLAYER)) + shakeMap.put(EntityType.PLAYER, new ArrayList()); + shakeMap.get(EntityType.PLAYER).add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel())); continue; } else { material = Material.matchMaterial(materialName); @@ -316,62 +292,11 @@ public class TreasureConfig extends ConfigLoader { fishingRewards.get(rarity).add(new FishingTreasure(item, xp)); } 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")) { - shakeFromCaveSpider.add(shakeTreasure); - } else if (type.equals("Shake.CHICKEN")) { - shakeFromChicken.add(shakeTreasure); - } else if (type.equals("Shake.COW")) { - shakeFromCow.add(shakeTreasure); - } else if (type.equals("Shake.CREEPER")) { - shakeFromCreeper.add(shakeTreasure); - } else if (type.equals("Shake.ENDERMAN")) { - shakeFromEnderman.add(shakeTreasure); - } else if (type.equals("Shake.GHAST")) { - shakeFromGhast.add(shakeTreasure); - } else if (type.equals("Shake.HORSE")) { - shakeFromHorse.add(shakeTreasure); - } else if (type.equals("Shake.IRON_GOLEM")) { - shakeFromIronGolem.add(shakeTreasure); - } else if (type.equals("Shake.MAGMA_CUBE")) { - shakeFromMagmaCube.add(shakeTreasure); - } else if (type.equals("Shake.MUSHROOM_COW")) { - shakeFromMushroomCow.add(shakeTreasure); - } else if (type.equals("Shake.PIG")) { - shakeFromPig.add(shakeTreasure); - } else if (type.equals("Shake.PIG_ZOMBIE")) { - shakeFromPigZombie.add(shakeTreasure); - } else if (type.equals("Shake.PLAYER")) { - shakeFromPlayer.add(shakeTreasure); - } else if (type.equals("Shake.SHEEP")) { - shakeFromSheep.add(shakeTreasure); - } else if (type.equals("Shake.SHULKER")) { - shakeFromShulker.add(shakeTreasure); - } else if (type.equals("Shake.SKELETON")) { - shakeFromSkeleton.add(shakeTreasure); - } else if (type.equals("Shake.SLIME")) { - shakeFromSlime.add(shakeTreasure); - } else if (type.equals("Shake.SPIDER")) { - shakeFromSpider.add(shakeTreasure); - } else if (type.equals("Shake.SNOWMAN")) { - shakeFromSnowman.add(shakeTreasure); - } else if (type.equals("Shake.SQUID")) { - shakeFromSquid.add(shakeTreasure); - } else if (type.equals("Shake.WITCH")) { - shakeFromWitch.add(shakeTreasure); - } else if (type.equals("Shake.WITHER_SKELETON")) { - shakeFromWitherSkeleton.add(shakeTreasure); - } 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); - } + + EntityType entityType = EntityType.valueOf(type.substring(6)); + if (!shakeMap.containsKey(entityType)) + shakeMap.put(entityType, new ArrayList()); + shakeMap.get(entityType).add(shakeTreasure); } else if (isExcavation) { ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); List dropList = config.getStringList(type + "." + treasureName + ".Drops_From"); @@ -401,9 +326,6 @@ public class TreasureConfig extends ConfigLoader { } } } - // Fallthrough if not specified - if (shakeFromElderGuardian.isEmpty()) - shakeFromElderGuardian = shakeFromGuardian; } private void loadEnchantments() { 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 a64d4c515..010ff6e51 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -18,16 +18,10 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.adapter.BiomeAdapter; public final class Fishing { + // The order of the values is extremely important, a few methods depend on it to work properly public enum Tier { - EIGHT(8), - SEVEN(7), - SIX(6), - FIVE(5), - FOUR(4), - THREE(3), - TWO(2), - ONE(1); + EIGHT(8), SEVEN(7), SIX(6), FIVE(5), FOUR(4), THREE(3), TWO(2), ONE(1); int numerical; @@ -59,103 +53,29 @@ public final class Fishing { public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; public static Set masterAnglerBiomes = BiomeAdapter.WATER_BIOMES; - public static Set iceFishingBiomes = BiomeAdapter.ICE_BIOMES; + public static Set iceFishingBiomes = BiomeAdapter.ICE_BIOMES; private Fishing() {} /** * Finds the possible drops of an entity * - * @param target Targeted entity + * @param target + * Targeted entity * @return possibleDrops List of ItemStack that can be dropped */ protected static List findPossibleDrops(LivingEntity target) { - switch (target.getType()) { - case BLAZE: - return TreasureConfig.getInstance().shakeFromBlaze; + if (TreasureConfig.getInstance().shakeMap.containsKey(target.getType())) + return TreasureConfig.getInstance().shakeMap.get(target.getType()); - case CAVE_SPIDER: - return TreasureConfig.getInstance().shakeFromCaveSpider; - - case CHICKEN: - return TreasureConfig.getInstance().shakeFromChicken; - - case COW: - return TreasureConfig.getInstance().shakeFromCow; - - case CREEPER: - return TreasureConfig.getInstance().shakeFromCreeper; - - case ENDERMAN: - return TreasureConfig.getInstance().shakeFromEnderman; - - case GHAST: - return TreasureConfig.getInstance().shakeFromGhast; - - case IRON_GOLEM: - return TreasureConfig.getInstance().shakeFromIronGolem; - - case MAGMA_CUBE: - return TreasureConfig.getInstance().shakeFromMagmaCube; - - case MUSHROOM_COW: - return TreasureConfig.getInstance().shakeFromMushroomCow; - - case PIG: - return TreasureConfig.getInstance().shakeFromPig; - - case PIG_ZOMBIE: - return TreasureConfig.getInstance().shakeFromPigZombie; - - case PLAYER: - return TreasureConfig.getInstance().shakeFromPlayer; - - case SHEEP: - return TreasureConfig.getInstance().shakeFromSheep; - - case SHULKER: - return TreasureConfig.getInstance().shakeFromShulker; - - case SKELETON: - return TreasureConfig.getInstance().shakeFromSkeleton; - - case SLIME: - return TreasureConfig.getInstance().shakeFromSlime; - - case SNOWMAN: - return TreasureConfig.getInstance().shakeFromSnowman; - - case SPIDER: - return TreasureConfig.getInstance().shakeFromSpider; - - case SQUID: - return TreasureConfig.getInstance().shakeFromSquid; - - case WITCH: - return TreasureConfig.getInstance().shakeFromWitch; - case WITHER_SKELETON: - return TreasureConfig.getInstance().shakeFromWitherSkeleton; - - 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; - } + return null; } /** * Randomly chooses a drop among the list * - * @param possibleDrops List of ItemStack that can be dropped + * @param possibleDrops + * List of ItemStack that can be dropped * @return Chosen ItemStack */ protected static ItemStack chooseDrop(List possibleDrops) {