From 7c00af18febf6c0b833c7633b4fb60a9a1bb93af Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:50:41 -0400 Subject: Code Clean Up (#2) * intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues --- .../profileviewer/ProfileViewer.java | 550 ++++++++++----------- 1 file changed, 271 insertions(+), 279 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index 371e9ef3..1de24257 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -1,6 +1,5 @@ package io.github.moulberry.notenoughupdates.profileviewer; -import com.google.common.base.Splitter; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -35,8 +34,8 @@ public class ProfileViewer { this.manager = manager; } + private static final HashMap petRarityToNumMap = new HashMap<>(); - private static HashMap petRarityToNumMap = new HashMap<>(); static { petRarityToNumMap.put("COMMON", "0"); petRarityToNumMap.put("UNCOMMON", "1"); @@ -47,31 +46,33 @@ public class ProfileViewer { } private static final LinkedHashMap skillToSkillDisplayMap = new LinkedHashMap<>(); + static { - skillToSkillDisplayMap.put("skill_taming", Utils.createItemStack(Items.spawn_egg, EnumChatFormatting.LIGHT_PURPLE+"Taming")); - skillToSkillDisplayMap.put("skill_mining", Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY+"Mining")); - skillToSkillDisplayMap.put("skill_foraging", Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN+"Foraging")); - skillToSkillDisplayMap.put("skill_enchanting", Utils.createItemStack(Item.getItemFromBlock(Blocks.enchanting_table), EnumChatFormatting.GREEN+"Enchanting")); - skillToSkillDisplayMap.put("skill_carpentry", Utils.createItemStack(Item.getItemFromBlock(Blocks.crafting_table), EnumChatFormatting.DARK_RED+"Carpentry")); - skillToSkillDisplayMap.put("skill_farming", Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW+"Farming")); - skillToSkillDisplayMap.put("skill_combat", Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED+"Combat")); - skillToSkillDisplayMap.put("skill_fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA+"Fishing")); - skillToSkillDisplayMap.put("skill_alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE+"Alchemy")); - skillToSkillDisplayMap.put("skill_runecrafting", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE+"Runecrafting")); + skillToSkillDisplayMap.put("skill_taming", Utils.createItemStack(Items.spawn_egg, EnumChatFormatting.LIGHT_PURPLE + "Taming")); + skillToSkillDisplayMap.put("skill_mining", Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining")); + skillToSkillDisplayMap.put("skill_foraging", Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN + "Foraging")); + skillToSkillDisplayMap.put("skill_enchanting", Utils.createItemStack(Item.getItemFromBlock(Blocks.enchanting_table), EnumChatFormatting.GREEN + "Enchanting")); + skillToSkillDisplayMap.put("skill_carpentry", Utils.createItemStack(Item.getItemFromBlock(Blocks.crafting_table), EnumChatFormatting.DARK_RED + "Carpentry")); + skillToSkillDisplayMap.put("skill_farming", Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming")); + skillToSkillDisplayMap.put("skill_combat", Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat")); + skillToSkillDisplayMap.put("skill_fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing")); + skillToSkillDisplayMap.put("skill_alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE + "Alchemy")); + skillToSkillDisplayMap.put("skill_runecrafting", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE + "Runecrafting")); //skillToSkillDisplayMap.put("skill_catacombs", Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush), EnumChatFormatting.GOLD+"Catacombs")); - skillToSkillDisplayMap.put("slayer_zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD+"Rev Slayer")); - skillToSkillDisplayMap.put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD+"Tara Slayer")); - skillToSkillDisplayMap.put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD+"Sven Slayer")); - skillToSkillDisplayMap.put("slayer_enderman", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.GOLD+"Ender Slayer")); + skillToSkillDisplayMap.put("slayer_zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD + "Rev Slayer")); + skillToSkillDisplayMap.put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD + "Tara Slayer")); + skillToSkillDisplayMap.put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD + "Sven Slayer")); + skillToSkillDisplayMap.put("slayer_enderman", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.GOLD + "Ender Slayer")); } - private static final ItemStack CAT_FARMING = Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW+"Farming"); - private static final ItemStack CAT_MINING = Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY+"Mining"); - private static final ItemStack CAT_COMBAT = Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED+"Combat"); - private static final ItemStack CAT_FORAGING = Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN+"Foraging"); - private static final ItemStack CAT_FISHING = Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA+"Fishing"); + private static final ItemStack CAT_FARMING = Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming"); + private static final ItemStack CAT_MINING = Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining"); + private static final ItemStack CAT_COMBAT = Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat"); + private static final ItemStack CAT_FORAGING = Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN + "Foraging"); + private static final ItemStack CAT_FISHING = Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing"); private static final LinkedHashMap> collectionCatToCollectionMap = new LinkedHashMap<>(); + static { collectionCatToCollectionMap.put(CAT_FARMING, Utils.createList("WHEAT", "CARROT_ITEM", "POTATO_ITEM", "PUMPKIN", "MELON", "SEEDS", "MUSHROOM_COLLECTION", @@ -80,7 +81,7 @@ public class ProfileViewer { collectionCatToCollectionMap.put(CAT_MINING, Utils.createList("COBBLESTONE", "COAL", "IRON_INGOT", "GOLD_INGOT", "DIAMOND", "INK_SACK:4", "EMERALD", "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE_DUST", "GRAVEL", "ICE", "NETHERRACK", - "SAND", "ENDER_STONE", null ,"MITHRIL_ORE", "HARD_STONE", "GEMSTONE_COLLECTION")); + "SAND", "ENDER_STONE", null, "MITHRIL_ORE", "HARD_STONE", "GEMSTONE_COLLECTION")); collectionCatToCollectionMap.put(CAT_COMBAT, Utils.createList("ROTTEN_FLESH", "BONE", "STRING", "SPIDER_EYE", "SULPHUR", "ENDER_PEARL", "GHAST_TEAR", "SLIME_BALL", "BLAZE_ROD", "MAGMA_CREAM", null, null, null)); @@ -92,6 +93,7 @@ public class ProfileViewer { } private static final LinkedHashMap> collectionCatToMinionMap = new LinkedHashMap<>(); + static { collectionCatToMinionMap.put(CAT_FARMING, Utils.createList("WHEAT", "CARROT", "POTATO", "PUMPKIN", "MELON", null, "MUSHROOM", @@ -112,144 +114,145 @@ public class ProfileViewer { } private static final LinkedHashMap collectionToCollectionDisplayMap = new LinkedHashMap<>(); + static { /* FARMING COLLECTIONS **/ collectionToCollectionDisplayMap.put("WHEAT", Utils.createItemStack(Items.wheat, - EnumChatFormatting.YELLOW+"Wheat")); + EnumChatFormatting.YELLOW + "Wheat")); collectionToCollectionDisplayMap.put("CARROT_ITEM", Utils.createItemStack(Items.carrot, - EnumChatFormatting.YELLOW+"Carrot")); + EnumChatFormatting.YELLOW + "Carrot")); collectionToCollectionDisplayMap.put("POTATO_ITEM", Utils.createItemStack(Items.potato, - EnumChatFormatting.YELLOW+"Potato")); + EnumChatFormatting.YELLOW + "Potato")); collectionToCollectionDisplayMap.put("PUMPKIN", Utils.createItemStack(Item.getItemFromBlock(Blocks.pumpkin), - EnumChatFormatting.YELLOW+"Pumpkin")); + EnumChatFormatting.YELLOW + "Pumpkin")); collectionToCollectionDisplayMap.put("MELON", Utils.createItemStack(Items.melon, - EnumChatFormatting.YELLOW+"Melon")); + EnumChatFormatting.YELLOW + "Melon")); collectionToCollectionDisplayMap.put("SEEDS", Utils.createItemStack(Items.wheat_seeds, - EnumChatFormatting.YELLOW+"Seeds")); + EnumChatFormatting.YELLOW + "Seeds")); collectionToCollectionDisplayMap.put("MUSHROOM_COLLECTION", Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom) - , EnumChatFormatting.YELLOW+"Mushroom")); + , EnumChatFormatting.YELLOW + "Mushroom")); collectionToCollectionDisplayMap.put("INK_SACK:3", Utils.createItemStack(Items.dye, - EnumChatFormatting.YELLOW+"Cocoa Beans", 3)); + EnumChatFormatting.YELLOW + "Cocoa Beans", 3)); collectionToCollectionDisplayMap.put("CACTUS", Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus), - EnumChatFormatting.YELLOW+"Cactus")); + EnumChatFormatting.YELLOW + "Cactus")); collectionToCollectionDisplayMap.put("SUGAR_CANE", Utils.createItemStack(Items.reeds, - EnumChatFormatting.YELLOW+"Sugar Cane")); + EnumChatFormatting.YELLOW + "Sugar Cane")); collectionToCollectionDisplayMap.put("FEATHER", Utils.createItemStack(Items.feather, - EnumChatFormatting.YELLOW+"Feather")); + EnumChatFormatting.YELLOW + "Feather")); collectionToCollectionDisplayMap.put("LEATHER", Utils.createItemStack(Items.leather, - EnumChatFormatting.YELLOW+"Leather")); + EnumChatFormatting.YELLOW + "Leather")); collectionToCollectionDisplayMap.put("PORK", Utils.createItemStack(Items.porkchop, - EnumChatFormatting.YELLOW+"Porkchop")); + EnumChatFormatting.YELLOW + "Porkchop")); collectionToCollectionDisplayMap.put("RAW_CHICKEN", Utils.createItemStack(Items.chicken, - EnumChatFormatting.YELLOW+"Chicken")); + EnumChatFormatting.YELLOW + "Chicken")); collectionToCollectionDisplayMap.put("MUTTON", Utils.createItemStack(Items.mutton, - EnumChatFormatting.YELLOW+"Mutton")); + EnumChatFormatting.YELLOW + "Mutton")); collectionToCollectionDisplayMap.put("RABBIT", Utils.createItemStack(Items.rabbit, - EnumChatFormatting.YELLOW+"Rabbit")); + EnumChatFormatting.YELLOW + "Rabbit")); collectionToCollectionDisplayMap.put("NETHER_STALK", Utils.createItemStack(Items.nether_wart, - EnumChatFormatting.YELLOW+"Nether Wart")); + EnumChatFormatting.YELLOW + "Nether Wart")); /* MINING COLLECTIONS **/ collectionToCollectionDisplayMap.put("COBBLESTONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.cobblestone), - EnumChatFormatting.GRAY+"Cobblestone")); + EnumChatFormatting.GRAY + "Cobblestone")); collectionToCollectionDisplayMap.put("COAL", Utils.createItemStack(Items.coal, - EnumChatFormatting.GRAY+"Coal")); + EnumChatFormatting.GRAY + "Coal")); collectionToCollectionDisplayMap.put("IRON_INGOT", Utils.createItemStack(Items.iron_ingot, - EnumChatFormatting.GRAY+"Iron Ingot")); + EnumChatFormatting.GRAY + "Iron Ingot")); collectionToCollectionDisplayMap.put("GOLD_INGOT", Utils.createItemStack(Items.gold_ingot, - EnumChatFormatting.GRAY+"Gold Ingot")); + EnumChatFormatting.GRAY + "Gold Ingot")); collectionToCollectionDisplayMap.put("DIAMOND", Utils.createItemStack(Items.diamond, - EnumChatFormatting.GRAY+"Diamond")); + EnumChatFormatting.GRAY + "Diamond")); collectionToCollectionDisplayMap.put("INK_SACK:4", Utils.createItemStack(Items.dye, - EnumChatFormatting.GRAY+"Lapis Lazuli", 4)); + EnumChatFormatting.GRAY + "Lapis Lazuli", 4)); collectionToCollectionDisplayMap.put("EMERALD", Utils.createItemStack(Items.emerald, - EnumChatFormatting.GRAY+"Emerald")); + EnumChatFormatting.GRAY + "Emerald")); collectionToCollectionDisplayMap.put("REDSTONE", Utils.createItemStack(Items.redstone, - EnumChatFormatting.GRAY+"Redstone")); + EnumChatFormatting.GRAY + "Redstone")); collectionToCollectionDisplayMap.put("QUARTZ", Utils.createItemStack(Items.quartz, - EnumChatFormatting.GRAY+"Nether Quartz")); + EnumChatFormatting.GRAY + "Nether Quartz")); collectionToCollectionDisplayMap.put("OBSIDIAN", Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian), - EnumChatFormatting.GRAY+"Obsidian")); + EnumChatFormatting.GRAY + "Obsidian")); collectionToCollectionDisplayMap.put("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust, - EnumChatFormatting.GRAY+"Glowstone")); + EnumChatFormatting.GRAY + "Glowstone")); collectionToCollectionDisplayMap.put("GRAVEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.gravel), - EnumChatFormatting.GRAY+"Gravel")); + EnumChatFormatting.GRAY + "Gravel")); collectionToCollectionDisplayMap.put("ICE", Utils.createItemStack(Item.getItemFromBlock(Blocks.ice), - EnumChatFormatting.GRAY+"Ice")); + EnumChatFormatting.GRAY + "Ice")); collectionToCollectionDisplayMap.put("NETHERRACK", Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack), - EnumChatFormatting.GRAY+"Netherrack")); + EnumChatFormatting.GRAY + "Netherrack")); collectionToCollectionDisplayMap.put("SAND", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand), - EnumChatFormatting.GRAY+"Sand")); + EnumChatFormatting.GRAY + "Sand")); collectionToCollectionDisplayMap.put("ENDER_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.end_stone), - EnumChatFormatting.GRAY+"End Stone")); + EnumChatFormatting.GRAY + "End Stone")); collectionToCollectionDisplayMap.put("MITHRIL_ORE", Utils.createItemStack(Items.prismarine_crystals, - EnumChatFormatting.GRAY+"Mithril")); + EnumChatFormatting.GRAY + "Mithril")); collectionToCollectionDisplayMap.put("HARD_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.stone), - EnumChatFormatting.GRAY+"Hard Stone")); + EnumChatFormatting.GRAY + "Hard Stone")); ItemStack gemstone = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass), - EnumChatFormatting.GRAY+"Gem Stones"); + EnumChatFormatting.GRAY + "Gem Stones"); gemstone.setItemDamage(14); collectionToCollectionDisplayMap.put("GEMSTONE_COLLECTION", gemstone); /* COMBAT COLLECTIONS **/ collectionToCollectionDisplayMap.put("ROTTEN_FLESH", Utils.createItemStack(Items.rotten_flesh, - EnumChatFormatting.RED+"Rotten Flesh")); + EnumChatFormatting.RED + "Rotten Flesh")); collectionToCollectionDisplayMap.put("BONE", Utils.createItemStack(Items.bone, - EnumChatFormatting.RED+"Bone")); + EnumChatFormatting.RED + "Bone")); collectionToCollectionDisplayMap.put("STRING", Utils.createItemStack(Items.string, - EnumChatFormatting.RED+"String")); + EnumChatFormatting.RED + "String")); collectionToCollectionDisplayMap.put("SPIDER_EYE", Utils.createItemStack(Items.spider_eye, - EnumChatFormatting.RED+"Spider Eye")); + EnumChatFormatting.RED + "Spider Eye")); collectionToCollectionDisplayMap.put("SULPHUR", Utils.createItemStack(Items.gunpowder, - EnumChatFormatting.RED+"Gunpowder")); + EnumChatFormatting.RED + "Gunpowder")); collectionToCollectionDisplayMap.put("ENDER_PEARL", Utils.createItemStack(Items.ender_pearl, - EnumChatFormatting.RED+"Ender Pearl")); + EnumChatFormatting.RED + "Ender Pearl")); collectionToCollectionDisplayMap.put("GHAST_TEAR", Utils.createItemStack(Items.ghast_tear, - EnumChatFormatting.RED+"Ghast Tear")); + EnumChatFormatting.RED + "Ghast Tear")); collectionToCollectionDisplayMap.put("SLIME_BALL", Utils.createItemStack(Items.slime_ball, - EnumChatFormatting.RED+"Slimeball")); + EnumChatFormatting.RED + "Slimeball")); collectionToCollectionDisplayMap.put("BLAZE_ROD", Utils.createItemStack(Items.blaze_rod, - EnumChatFormatting.RED+"Blaze Rod")); + EnumChatFormatting.RED + "Blaze Rod")); collectionToCollectionDisplayMap.put("MAGMA_CREAM", Utils.createItemStack(Items.magma_cream, - EnumChatFormatting.RED+"Magma Cream")); + EnumChatFormatting.RED + "Magma Cream")); /* FORAGING COLLECTIONS **/ collectionToCollectionDisplayMap.put("LOG", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), - EnumChatFormatting.DARK_GREEN+"Oak")); + EnumChatFormatting.DARK_GREEN + "Oak")); collectionToCollectionDisplayMap.put("LOG:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), - EnumChatFormatting.DARK_GREEN+"Spruce", 1)); + EnumChatFormatting.DARK_GREEN + "Spruce", 1)); collectionToCollectionDisplayMap.put("LOG:2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), - EnumChatFormatting.DARK_GREEN+"Birch", 2)); + EnumChatFormatting.DARK_GREEN + "Birch", 2)); collectionToCollectionDisplayMap.put("LOG_2:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), - EnumChatFormatting.DARK_GREEN+"Dark Oak", 1)); + EnumChatFormatting.DARK_GREEN + "Dark Oak", 1)); collectionToCollectionDisplayMap.put("LOG_2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), - EnumChatFormatting.DARK_GREEN+"Acacia")); + EnumChatFormatting.DARK_GREEN + "Acacia")); collectionToCollectionDisplayMap.put("LOG:3", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), - EnumChatFormatting.DARK_GREEN+"Jungle", 3)); + EnumChatFormatting.DARK_GREEN + "Jungle", 3)); /* FISHING COLLECTIONS **/ collectionToCollectionDisplayMap.put("RAW_FISH", Utils.createItemStack(Items.fish, - EnumChatFormatting.AQUA+"Fish")); + EnumChatFormatting.AQUA + "Fish")); collectionToCollectionDisplayMap.put("RAW_FISH:1", Utils.createItemStack(Items.fish, - EnumChatFormatting.AQUA+"Salmon", 1)); + EnumChatFormatting.AQUA + "Salmon", 1)); collectionToCollectionDisplayMap.put("RAW_FISH:2", Utils.createItemStack(Items.fish, - EnumChatFormatting.AQUA+"Clownfish", 2)); + EnumChatFormatting.AQUA + "Clownfish", 2)); collectionToCollectionDisplayMap.put("RAW_FISH:3", Utils.createItemStack(Items.fish, - EnumChatFormatting.AQUA+"Pufferfish", 3)); + EnumChatFormatting.AQUA + "Pufferfish", 3)); collectionToCollectionDisplayMap.put("PRISMARINE_SHARD", Utils.createItemStack(Items.prismarine_shard, - EnumChatFormatting.AQUA+"Prismarine Shard")); + EnumChatFormatting.AQUA + "Prismarine Shard")); collectionToCollectionDisplayMap.put("PRISMARINE_CRYSTALS", Utils.createItemStack(Items.prismarine_crystals, - EnumChatFormatting.AQUA+"Prismarine Crystals")); + EnumChatFormatting.AQUA + "Prismarine Crystals")); collectionToCollectionDisplayMap.put("CLAY_BALL", Utils.createItemStack(Items.clay_ball, - EnumChatFormatting.AQUA+"Clay")); + EnumChatFormatting.AQUA + "Clay")); collectionToCollectionDisplayMap.put("WATER_LILY", Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily), - EnumChatFormatting.AQUA+"Lilypad")); + EnumChatFormatting.AQUA + "Lilypad")); collectionToCollectionDisplayMap.put("INK_SACK", Utils.createItemStack(Items.dye, - EnumChatFormatting.AQUA+"Ink Sack")); + EnumChatFormatting.AQUA + "Ink Sack")); collectionToCollectionDisplayMap.put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge), - EnumChatFormatting.AQUA+"Sponge")); + EnumChatFormatting.AQUA + "Sponge")); } public static LinkedHashMap> getCollectionCatToMinionMap() { @@ -276,29 +279,29 @@ public class ProfileViewer { public static Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) { Level levelObj = new Level(); - for(int level=0; level xp) { - if(cumulative) { + if (levelXp > xp) { + if (cumulative) { float previous = 0; - if(level > 0) previous = levelingArray.get(level-1).getAsFloat(); - levelObj.maxXpForLevel = (levelXp-previous); - levelObj.level = 1 + level + (xp-levelXp)/levelObj.maxXpForLevel; + if (level > 0) previous = levelingArray.get(level - 1).getAsFloat(); + levelObj.maxXpForLevel = (levelXp - previous); + levelObj.level = 1 + level + (xp - levelXp) / levelObj.maxXpForLevel; } else { levelObj.maxXpForLevel = levelXp; - levelObj.level = level + xp/levelXp; + levelObj.level = level + xp / levelXp; } - if(levelObj.level > levelCap) { + if (levelObj.level > levelCap) { levelObj.level = levelCap; levelObj.maxed = true; } return levelObj; } else { - if(!cumulative) xp -= levelXp; + if (!cumulative) xp -= levelXp; } } levelObj.level = levelingArray.size(); - if(levelObj.level > levelCap) { + if (levelObj.level > levelCap) { levelObj.level = levelCap; } levelObj.maxed = true; @@ -319,37 +322,37 @@ public class ProfileViewer { private final HashMap skillInfoMap = new HashMap<>(); private final HashMap inventoryInfoMap = new HashMap<>(); private final HashMap collectionInfoMap = new HashMap<>(); - private List profileIds = new ArrayList<>(); + private final List profileIds = new ArrayList<>(); private JsonObject playerStatus = null; - private HashMap stats = new HashMap<>(); - private HashMap passiveStats = new HashMap<>(); - private HashMap networth = new HashMap<>(); + private final HashMap stats = new HashMap<>(); + private final HashMap passiveStats = new HashMap<>(); + private final HashMap networth = new HashMap<>(); public Profile(String uuid) { this.uuid = uuid; } - private AtomicBoolean updatingPlayerInfoState = new AtomicBoolean(false); + private final AtomicBoolean updatingPlayerInfoState = new AtomicBoolean(false); private long lastPlayerInfoState = 0; - private AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false); - private AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false); + private final AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false); + private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false); private long lastGuildInfoState = 0; - private AtomicBoolean updatingGuildStatusState = new AtomicBoolean(false); + private final AtomicBoolean updatingGuildStatusState = new AtomicBoolean(false); public JsonObject getPlayerStatus() { - if(playerStatus != null) return playerStatus; - if(updatingPlayerStatusState.get()) return null; + if (playerStatus != null) return playerStatus; + if (updatingPlayerStatusState.get()) return null; updatingPlayerStatusState.set(true); HashMap args = new HashMap<>(); - args.put("uuid", ""+uuid); + args.put("uuid", "" + uuid); manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "status", args, jsonObject -> { - if(jsonObject == null) return; + if (jsonObject == null) return; updatingPlayerStatusState.set(false); - if(jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) { + if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) { playerStatus = jsonObject.get("session").getAsJsonObject(); } }, () -> updatingPlayerStatusState.set(false) @@ -358,12 +361,11 @@ public class ProfileViewer { return null; } - public long getNetWorth(String profileId) { - if(profileId == null) profileId = latestProfile; - if(networth.get(profileId) != null) return networth.get(profileId); - if(getProfileInformation(profileId) == null) return -1; - if(getInventoryInfo(profileId) == null) return -1; + if (profileId == null) profileId = latestProfile; + if (networth.get(profileId) != null) return networth.get(profileId); + if (getProfileInformation(profileId) == null) return -1; + if (getInventoryInfo(profileId) == null) return -1; JsonObject inventoryInfo = getInventoryInfo(profileId); JsonObject profileInfo = getProfileInformation(profileId); @@ -371,29 +373,29 @@ public class ProfileViewer { HashMap mostExpensiveInternal = new HashMap<>(); long networth = 0; - for(Map.Entry entry : inventoryInfo.entrySet()) { - if(entry.getValue().isJsonArray()) { - for(JsonElement element : entry.getValue().getAsJsonArray()) { - if(element != null && element.isJsonObject()) { + for (Map.Entry entry : inventoryInfo.entrySet()) { + if (entry.getValue().isJsonArray()) { + for (JsonElement element : entry.getValue().getAsJsonArray()) { + if (element != null && element.isJsonObject()) { JsonObject item = element.getAsJsonObject(); String internalname = item.get("internalname").getAsString(); - if(manager.auctionManager.isVanillaItem(internalname)) continue; + if (manager.auctionManager.isVanillaItem(internalname)) continue; JsonObject bzInfo = manager.auctionManager.getBazaarInfo(internalname); int auctionPrice; - if(bzInfo != null && bzInfo.has("curr_sell")) { - auctionPrice = (int)bzInfo.get("curr_sell").getAsFloat(); + if (bzInfo != null && bzInfo.has("curr_sell")) { + auctionPrice = (int) bzInfo.get("curr_sell").getAsFloat(); } else { - auctionPrice = (int)manager.auctionManager.getItemAvgBin(internalname); - if(auctionPrice <= 0) { + auctionPrice = (int) manager.auctionManager.getItemAvgBin(internalname); + if (auctionPrice <= 0) { auctionPrice = manager.auctionManager.getLowestBin(internalname); } } try { - if(item.has("item_contents")) { + if (item.has("item_contents")) { JsonArray bytesArr = item.get("item_contents").getAsJsonArray(); byte[] bytes = new byte[bytesArr.size()]; for (int bytesArrI = 0; bytesArrI < bytesArr.size(); bytesArrI++) { @@ -401,21 +403,21 @@ public class ProfileViewer { } NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); NBTTagList items = contents_nbt.getTagList("i", 10); - for(int j=0; j 0) { + for (int j = 0; j < items.tagCount(); j++) { + if (items.getCompoundTagAt(j).getKeySet().size() > 0) { NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag"); String internalname2 = manager.getInternalnameFromNBT(nbt); - if(internalname2 != null) { - if(manager.auctionManager.isVanillaItem(internalname2)) continue; + if (internalname2 != null) { + if (manager.auctionManager.isVanillaItem(internalname2)) continue; JsonObject bzInfo2 = manager.auctionManager.getBazaarInfo(internalname2); int auctionPrice2; - if(bzInfo2 != null && bzInfo2.has("curr_sell")) { - auctionPrice2 = (int)bzInfo2.get("curr_sell").getAsFloat(); + if (bzInfo2 != null && bzInfo2.has("curr_sell")) { + auctionPrice2 = (int) bzInfo2.get("curr_sell").getAsFloat(); } else { - auctionPrice2 = (int)manager.auctionManager.getItemAvgBin(internalname2); - if(auctionPrice2 <= 0) { + auctionPrice2 = (int) manager.auctionManager.getItemAvgBin(internalname2); + if (auctionPrice2 <= 0) { auctionPrice2 = manager.auctionManager.getLowestBin(internalname2); } } @@ -428,10 +430,10 @@ public class ProfileViewer { } } } - } catch(IOException ignored) {} + } catch (IOException ignored) {} int count = 1; - if(element.getAsJsonObject().has("count")) { + if (element.getAsJsonObject().has("count")) { count = element.getAsJsonObject().get("count").getAsInt(); } mostExpensiveInternal.put(internalname, auctionPrice * count + mostExpensiveInternal.getOrDefault(internalname, 0L)); @@ -440,31 +442,31 @@ public class ProfileViewer { } } } - if(networth == 0) return -1; + if (networth == 0) return -1; //System.out.println(profileId); - for(Map.Entry entry : mostExpensiveInternal.entrySet()) { + for (Map.Entry entry : mostExpensiveInternal.entrySet()) { //System.out.println(entry.getKey() + ":" + entry.getValue()); } - networth = (int)(networth*1.3f); + networth = (int) (networth * 1.3f); JsonObject petsInfo = getPetsInfo(profileId); - if(petsInfo != null && petsInfo.has("pets")) { - if(petsInfo.get("pets").isJsonArray()) { + if (petsInfo != null && petsInfo.has("pets")) { + if (petsInfo.get("pets").isJsonArray()) { JsonArray pets = petsInfo.get("pets").getAsJsonArray(); - for(JsonElement element : pets) { - if(element.isJsonObject()) { + for (JsonElement element : pets) { + if (element.isJsonObject()) { JsonObject pet = element.getAsJsonObject(); String petname = pet.get("type").getAsString(); String tier = pet.get("tier").getAsString(); String tierNum = petRarityToNumMap.get(tier); - if(tierNum != null) { - String internalname2 = petname+";"+tierNum; + if (tierNum != null) { + String internalname2 = petname + ";" + tierNum; JsonObject info2 = manager.auctionManager.getItemAuctionInfo(internalname2); - if(info2 == null || !info2.has("price") || !info2.has("count")) continue; - int auctionPrice2 = (int)(info2.get("price").getAsFloat() / info2.get("count").getAsFloat()); + if (info2 == null || !info2.has("price") || !info2.has("count")) continue; + int auctionPrice2 = (int) (info2.get("price").getAsFloat() / info2.get("count").getAsFloat()); networth += auctionPrice2; } @@ -476,7 +478,7 @@ public class ProfileViewer { float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0); float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0); - networth += bankBalance+purseBalance; + networth += bankBalance + purseBalance; this.networth.put(profileId, networth); return networth; @@ -491,7 +493,7 @@ public class ProfileViewer { long currentTime = System.currentTimeMillis(); - if (currentTime - lastPlayerInfoState < 15*1000 && updatingPlayerInfoState.get()) return null; + if (currentTime - lastPlayerInfoState < 15 * 1000 && updatingPlayerInfoState.get()) return null; lastPlayerInfoState = currentTime; updatingPlayerInfoState.set(true); @@ -520,14 +522,13 @@ public class ProfileViewer { if (members.has(uuid)) { JsonObject member = members.get(uuid).getAsJsonObject(); - if(member.has("coop_invitation")) { + if (member.has("coop_invitation")) { JsonObject coop_invitation = member.get("coop_invitation").getAsJsonObject(); - if(!coop_invitation.get("confirmed").getAsBoolean()) { + if (!coop_invitation.get("confirmed").getAsBoolean()) { continue; } } - String cute_name = profile.get("cute_name").getAsString(); if (backup == null) backup = cute_name; profileIds.add(cute_name); @@ -544,19 +545,18 @@ public class ProfileViewer { latestProfile = backup; if (runnable != null) runnable.run(); } - }, () -> { - updatingPlayerInfoState.set(false); - } + }, () -> updatingPlayerInfoState.set(false) ); - return null; + return null; } + public JsonObject getGuildInfo(Runnable runnable) { if (guildInformation != null) return guildInformation; long currentTime = System.currentTimeMillis(); - if (currentTime - lastGuildInfoState < 15*1000 && updatingGuildInfoState.get()) return null; + if (currentTime - lastGuildInfoState < 15 * 1000 && updatingGuildInfoState.get()) return null; lastGuildInfoState = currentTime; updatingGuildInfoState.set(true); @@ -573,9 +573,7 @@ public class ProfileViewer { if (guildInformation == null) return; if (runnable != null) runnable.run(); } - }, () -> { - updatingGuildInfoState.set(false); - } + }, () -> updatingGuildInfoState.set(false) ); return null; @@ -587,25 +585,25 @@ public class ProfileViewer { public JsonObject getProfileInformation(String profileId) { JsonArray playerInfo = getPlayerInformation(() -> {}); - if(playerInfo == null) return null; - if(profileId == null) profileId = latestProfile; - if(profileMap.containsKey(profileId)) return profileMap.get(profileId); + if (playerInfo == null) return null; + if (profileId == null) profileId = latestProfile; + if (profileMap.containsKey(profileId)) return profileMap.get(profileId); - for(int i=0; i getCoopProfileInformation(String profileId) { JsonArray playerInfo = getPlayerInformation(() -> {}); - if(playerInfo == null) return null; - if(profileId == null) profileId = latestProfile; - if(coopProfileMap.containsKey(profileId)) return coopProfileMap.get(profileId); + if (playerInfo == null) return null; + if (profileId == null) profileId = latestProfile; + if (coopProfileMap.containsKey(profileId)) return coopProfileMap.get(profileId); - for(int i=0; i coopList = new ArrayList<>(); - for(Map.Entry islandMember : members.entrySet()) { - if(!islandMember.getKey().equals(uuid)) { + for (Map.Entry islandMember : members.entrySet()) { + if (!islandMember.getKey().equals(uuid)) { JsonObject coopProfileInfo = islandMember.getValue().getAsJsonObject(); coopList.add(coopProfileInfo); } @@ -666,11 +664,11 @@ public class ProfileViewer { public int getCap(JsonObject leveling, String skillName) { JsonElement capsElement = Utils.getElement(leveling, "leveling_caps"); - if(capsElement == null || !capsElement.isJsonObject()) { + if (capsElement == null || !capsElement.isJsonObject()) { return 50; } JsonObject caps = capsElement.getAsJsonObject(); - if(caps.has(skillName)) { + if (caps.has(skillName)) { return caps.get(skillName).getAsInt(); } return 50; @@ -678,11 +676,11 @@ public class ProfileViewer { public JsonObject getSkillInfo(String profileId) { JsonObject profileInfo = getProfileInformation(profileId); - if(profileInfo == null) return null; - if(profileId == null) profileId = latestProfile; - if(skillInfoMap.containsKey(profileId)) return skillInfoMap.get(profileId); + if (profileInfo == null) return null; + if (profileId == null) profileId = latestProfile; + if (skillInfoMap.containsKey(profileId)) return skillInfoMap.get(profileId); JsonObject leveling = Constants.LEVELING; - if(leveling == null) return null; + if (leveling == null) return null; float experience_skill_taming = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_taming"), 0); float experience_skill_mining = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_mining"), 0); @@ -702,13 +700,12 @@ public class ProfileViewer { float experience_slayer_wolf = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.xp"), 0); float experience_slayer_enderman = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.xp"), 0); - float totalSkillXP = experience_skill_taming + experience_skill_mining + experience_skill_foraging + experience_skill_enchanting + experience_skill_carpentry + experience_skill_farming + experience_skill_combat + experience_skill_fishing + experience_skill_alchemy + experience_skill_runecrafting; - if(totalSkillXP <= 0) { + if (totalSkillXP <= 0) { return null; } @@ -733,13 +730,13 @@ public class ProfileViewer { skillInfo.addProperty("experience_slayer_enderman", experience_slayer_enderman); JsonArray levelingArray = Utils.getElement(leveling, "leveling_xp").getAsJsonArray(); - int farmingCap = getCap(leveling, "farming") + (int)Utils.getElementAsFloat( + int farmingCap = getCap(leveling, "farming") + (int) Utils.getElementAsFloat( Utils.getElement(profileInfo, "jacob2.perks.farming_level_cap"), 0); Level level_skill_taming = getLevel(levelingArray, experience_skill_taming, getCap(leveling, "taming"), false); Level level_skill_mining = getLevel(levelingArray, experience_skill_mining, getCap(leveling, "mining"), false); Level level_skill_foraging = getLevel(levelingArray, experience_skill_foraging, getCap(leveling, "foraging"), false); - Level level_skill_enchanting = getLevel(levelingArray, experience_skill_enchanting, getCap(leveling, "enchanting"), false); - Level level_skill_carpentry = getLevel(levelingArray, experience_skill_carpentry,getCap(leveling, "carpentry"), false); + Level level_skill_enchanting = getLevel(levelingArray, experience_skill_enchanting, getCap(leveling, "enchanting"), false); + Level level_skill_carpentry = getLevel(levelingArray, experience_skill_carpentry, getCap(leveling, "carpentry"), false); Level level_skill_farming = getLevel(levelingArray, experience_skill_farming, farmingCap, false); Level level_skill_combat = getLevel(levelingArray, experience_skill_combat, getCap(leveling, "combat"), false); Level level_skill_fishing = getLevel(levelingArray, experience_skill_fishing, getCap(leveling, "fishing"), false); @@ -751,13 +748,13 @@ public class ProfileViewer { experience_skill_catacombs, getCap(leveling, "catacombs"), false); Level level_slayer_zombie = getLevel(Utils.getElement(leveling, "slayer_xp.zombie").getAsJsonArray(), - experience_slayer_zombie, 9,true); + experience_slayer_zombie, 9, true); Level level_slayer_spider = getLevel(Utils.getElement(leveling, "slayer_xp.spider").getAsJsonArray(), - experience_slayer_spider, 9,true); + experience_slayer_spider, 9, true); Level level_slayer_wolf = getLevel(Utils.getElement(leveling, "slayer_xp.wolf").getAsJsonArray(), - experience_slayer_wolf, 9,true); + experience_slayer_wolf, 9, true); Level level_slayer_enderman = getLevel(Utils.getElement(leveling, "slayer_xp.enderman").getAsJsonArray(), - experience_slayer_enderman, 9,true); + experience_slayer_enderman, 9, true); skillInfo.addProperty("level_skill_taming", level_skill_taming.level); skillInfo.addProperty("level_skill_mining", level_skill_mining.level); @@ -818,9 +815,9 @@ public class ProfileViewer { public JsonObject getInventoryInfo(String profileId) { JsonObject profileInfo = getProfileInformation(profileId); - if(profileInfo == null) return null; - if(profileId == null) profileId = latestProfile; - if(inventoryInfoMap.containsKey(profileId)) return inventoryInfoMap.get(profileId); + if (profileInfo == null) return null; + if (profileId == null) profileId = latestProfile; + if (inventoryInfoMap.containsKey(profileId)) return inventoryInfoMap.get(profileId); String inv_armor_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "inv_armor.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="); String fishing_bag_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "fishing_bag.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="); @@ -838,20 +835,19 @@ public class ProfileViewer { String talisman_bag_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "talisman_bag.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="); String candy_inventory_contents_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "candy_inventory_contents.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="); - JsonObject inventoryInfo = new JsonObject(); String[] inv_names = new String[]{"inv_armor", "fishing_bag", "quiver", "ender_chest_contents", "backpack_contents", "personal_vault_contents", "wardrobe_contents", "potion_bag", "inv_contents", "talisman_bag", "candy_inventory_contents"}; String[] inv_bytes = new String[]{inv_armor_bytes, fishing_bag_bytes, quiver_bytes, ender_chest_contents_bytes, backpack_contents_json_fake, personal_vault_contents_bytes, wardrobe_contents_bytes, potion_bag_bytes, inv_contents_bytes, talisman_bag_bytes, candy_inventory_contents_bytes}; - for(int i=0; i backpackIcon : backpack_icons.entrySet()) { - if(backpackIcon.getValue() instanceof JsonObject){ - JsonObject backpackData = (JsonObject)backpack_contents_json.get(backpackIcon.getKey()); + for (Map.Entry backpackIcon : backpack_icons.entrySet()) { + if (backpackIcon.getValue() instanceof JsonObject) { + JsonObject backpackData = (JsonObject) backpack_contents_json.get(backpackIcon.getKey()); String bytes = Utils.getElementAsString(backpackData.get("data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="); backpackArray = growArray(bytes, Integer.parseInt(backpackIcon.getKey()), backpackArray); } } - //reduce backpack array to filter out not existent backpacks { int backpackCount = 0; @@ -932,11 +927,9 @@ public class ProfileViewer { JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j)); contents.add(item); } - } catch (IOException ignored) { - } + } catch (IOException ignored) {} } - JsonObject bundledReturn = new JsonObject(); bundledReturn.add("contents", contents); bundledReturn.add("backpack_sizes", backpackSizes); @@ -944,8 +937,8 @@ public class ProfileViewer { return bundledReturn; } - public String[] growArray(String bytes, int index, String[] oldArray){ - int newSize = Math.max(index+1, oldArray.length); + public String[] growArray(String bytes, int index, String[] oldArray) { + int newSize = Math.max(index + 1, oldArray.length); String[] newArray = new String[newSize]; for (int i = 0; i < oldArray.length; i++) { @@ -956,21 +949,19 @@ public class ProfileViewer { return newArray; } - - public JsonObject getPetsInfo(String profileId) { JsonObject profileInfo = getProfileInformation(profileId); - if(profileInfo == null) return null; - if(petsInfoMap.containsKey(profileId)) return petsInfoMap.get(profileId); + if (profileInfo == null) return null; + if (petsInfoMap.containsKey(profileId)) return petsInfoMap.get(profileId); JsonObject petsInfo = new JsonObject(); JsonElement petsElement = profileInfo.get("pets"); - if(petsElement != null && petsElement.isJsonArray()) { + if (petsElement != null && petsElement.isJsonArray()) { JsonObject activePet = null; JsonArray pets = petsElement.getAsJsonArray(); - for(int i=0; i entry : personalAmounts.entrySet()) { + for (Map.Entry entry : personalAmounts.entrySet()) { totalAmounts.addProperty(entry.getKey(), entry.getValue().getAsInt()); } List coopProfiles = getCoopProfileInformation(profileId); - if(coopProfiles != null) { - for(JsonObject coopProfile : coopProfiles) { + if (coopProfiles != null) { + for (JsonObject coopProfile : coopProfiles) { JsonElement coopCollectionInfoElement = Utils.getElement(coopProfile, "collection"); - if(coopCollectionInfoElement != null && coopCollectionInfoElement.isJsonObject()) { - for(Map.Entry entry : coopCollectionInfoElement.getAsJsonObject().entrySet()) { + if (coopCollectionInfoElement != null && coopCollectionInfoElement.isJsonObject()) { + for (Map.Entry entry : coopCollectionInfoElement.getAsJsonObject().entrySet()) { float existing = Utils.getElementAsFloat(totalAmounts.get(entry.getKey()), 0); - totalAmounts.addProperty(entry.getKey(), existing+entry.getValue().getAsInt()); + totalAmounts.addProperty(entry.getKey(), existing + entry.getValue().getAsInt()); } } } } - if(unlocked_coll_tiers_element.isJsonArray()) { + if (unlocked_coll_tiers_element.isJsonArray()) { JsonArray unlocked_coll_tiers = unlocked_coll_tiers_element.getAsJsonArray(); - for(int i=0; i totalAmountsEntry : totalAmounts.entrySet()) { + for (Map.Entry totalAmountsEntry : totalAmounts.entrySet()) { String collName = totalAmountsEntry.getKey(); - int collTier = (int)Utils.getElementAsFloat(collectionTiers.get(collName), 0); + int collTier = (int) Utils.getElementAsFloat(collectionTiers.get(collName), 0); - int currentAmount = (int)Utils.getElementAsFloat(totalAmounts.get(collName), 0); - if(currentAmount > 0) { - for(Map.Entry resourceEntry : resourceCollectionInfo.entrySet()) { - JsonElement tiersElement = Utils.getElement(resourceEntry.getValue(), "items."+collName+".tiers"); - if(tiersElement != null && tiersElement.isJsonArray()) { + int currentAmount = (int) Utils.getElementAsFloat(totalAmounts.get(collName), 0); + if (currentAmount > 0) { + for (Map.Entry resourceEntry : resourceCollectionInfo.entrySet()) { + JsonElement tiersElement = Utils.getElement(resourceEntry.getValue(), "items." + collName + ".tiers"); + if (tiersElement != null && tiersElement.isJsonArray()) { JsonArray tiers = tiersElement.getAsJsonArray(); int maxTierAcquired = -1; int maxAmountRequired = -1; - for(int i=0; i