diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java | 309 |
1 files changed, 248 insertions, 61 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java index 2b8ebf12..301acbc3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2024 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -47,70 +47,231 @@ import java.util.regex.Pattern; public class PlayerStats { + // Combat stats public static final String HEALTH = "health"; public static final String DEFENCE = "defence"; public static final String STRENGTH = "strength"; - public static final String SPEED = "speed"; + public static final String INTELLIGENCE = "intelligence"; public static final String CRIT_CHANCE = "crit_chance"; public static final String CRIT_DAMAGE = "crit_damage"; public static final String BONUS_ATTACK_SPEED = "bonus_attack_speed"; - public static final String INTELLIGENCE = "intelligence"; - public static final String SEA_CREATURE_CHANCE = "sea_creature_chance"; + public static final String ABILITY_DAMAGE = "ability_damage"; + public static final String TRUE_DEFENSE = "true_defense"; + public static final String FEROCITY = "ferocity"; + public static final String HEALTH_REGEN = "health_regen"; + public static final String VITALITY = "vitality"; + public static final String MENDING = "mending"; + public static final String SWING_RANGE = "swing_range"; + + // Gathering stats + public static final String MINING_SPEED = "mining_speed"; + public static final String MINING_FORTUNE = "mining_fortune"; + public static final String FARMING_FORTUNE = "farming_fortune"; + public static final String FORAGING_FORTUNE = "foraging_fortune"; + public static final String BREAKING_POWER = "breaking_power"; + public static final String PRISTINE = "pristine"; + public static final String WHEAT_FORTUNE = "wheat_fortune"; + public static final String CARROT_FORTUNE = "carrot_fortune"; + public static final String POTATO_FORTUNE = "potato_fortune"; + public static final String PUMPKIN_FORTUNE = "pumpkin_fortune"; + public static final String MELON_FORTUNE = "melon_fortune"; + public static final String MUSHROOM_FORTUNE = "mushroom_fortune"; + public static final String CACTUS_FORTUNE = "cactus_fortune"; + public static final String SUGAR_CANE_FORTUNE = "sugar_cane_fortune"; + public static final String NETHER_WART_FORTUNE = "nether_wart_fortune"; + public static final String COCOA_BEANS_FORTUNE = "cocoa_beans_fortune"; + + // Wisdom stats + public static final String COMBAT_WISDOM = "combat_wisdom"; + public static final String MINING_WISDOM = "mining_wisdom"; + public static final String FARMING_WISDOM = "farming_wisdom"; + public static final String FORAGING_WISDOM = "foraging_wisdom"; + public static final String FISHING_WISDOM = "fishing_wisdom"; + public static final String ENCHANTING_WISDOM = "enchanting_wisdom"; + public static final String ALCHEMY_WISDOM = "alchemy_wisdom"; + public static final String CARPENTRY_WISDOM = "carpentry_wisdom"; + public static final String RUNECRAFTING_WISDOM = "runecrafting_wisdom"; + public static final String SOCIAL_WISDOM = "social_wisdom"; + public static final String TAMING_WISDOM = "taming_wisdom"; + + // Misc stats + public static final String SPEED = "speed"; public static final String MAGIC_FIND = "magic_find"; public static final String PET_LUCK = "pet_luck"; - public static final String MINING_FORTUNE = "mining_fortune"; - public static final String MINING_SPEED = "mining_speed"; - - public static final String[] defaultStatNames = new String[] { - "health", - "defence", - "strength", - "speed", - "crit_chance", - "crit_damage", - "bonus_attack_speed", - "intelligence", - "sea_creature_chance", - "magic_find", - "pet_luck", - "ferocity", - "ability_damage", - "mining_fortune", - "mining_speed", + public static final String SEA_CREATURE_CHANCE = "sea_creature_chance"; + public static final String DOUBLE_HOOK_CHANCE = "double_hook_chance"; + public static final String FISHING_SPEED = "fishing_speed"; + public static final String COLD_RESISTANCE = "cold_resistance"; + public static final String BONUS_PEST_CHANCE = "bonus_pest_chance"; + + public static final String[] defaultStatNames = new String[]{ + HEALTH, + DEFENCE, + STRENGTH, + INTELLIGENCE, + CRIT_CHANCE, + CRIT_DAMAGE, + BONUS_ATTACK_SPEED, + ABILITY_DAMAGE, + TRUE_DEFENSE, + FEROCITY, + HEALTH_REGEN, + VITALITY, + MENDING, + SWING_RANGE, + + MINING_SPEED, + MINING_FORTUNE, + FARMING_FORTUNE, + FORAGING_FORTUNE, + BREAKING_POWER, + PRISTINE, + WHEAT_FORTUNE, + CARROT_FORTUNE, + POTATO_FORTUNE, + PUMPKIN_FORTUNE, + MELON_FORTUNE, + MUSHROOM_FORTUNE, + CACTUS_FORTUNE, + SUGAR_CANE_FORTUNE, + NETHER_WART_FORTUNE, + COCOA_BEANS_FORTUNE, + + COMBAT_WISDOM, + MINING_WISDOM, + FARMING_WISDOM, + FORAGING_WISDOM, + FISHING_WISDOM, + ENCHANTING_WISDOM, + ALCHEMY_WISDOM, + CARPENTRY_WISDOM, + RUNECRAFTING_WISDOM, + SOCIAL_WISDOM, + TAMING_WISDOM, + + SPEED, + MAGIC_FIND, + PET_LUCK, + SEA_CREATURE_CHANCE, + DOUBLE_HOOK_CHANCE, + FISHING_SPEED, + COLD_RESISTANCE, + BONUS_PEST_CHANCE, }; - public static final String[] defaultStatNamesPretty = new String[] { - EnumChatFormatting.RED + "\u2764 Health", - EnumChatFormatting.GREEN + "\u2748 Defence", - EnumChatFormatting.RED + "\u2741 Strength", - EnumChatFormatting.WHITE + "\u2726 Speed", - EnumChatFormatting.BLUE + "\u2623 Crit Chance", - EnumChatFormatting.BLUE + "\u2620 Crit Damage", - EnumChatFormatting.YELLOW + "\u2694 Attack Speed", - EnumChatFormatting.AQUA + "\u270e Intelligence", - EnumChatFormatting.DARK_AQUA + "\u03b1 SC Chance", - EnumChatFormatting.AQUA + "\u272f Magic Find", - EnumChatFormatting.LIGHT_PURPLE + "\u2663 Pet Luck", - EnumChatFormatting.RED + "\u2AFD Ferocity", - EnumChatFormatting.RED + "\u2739 Ability Damage", - EnumChatFormatting.GOLD + "\u2618 Mining Fortune", - EnumChatFormatting.GOLD + "\u2E15 Mining Speed", + public static final String[] defaultStatNamesPretty = new String[]{ + EnumChatFormatting.RED + "❤ Health", + EnumChatFormatting.GREEN + "❈ Defence", + EnumChatFormatting.RED + "❁ Strength", + EnumChatFormatting.AQUA + "✎ Intelligence", + EnumChatFormatting.BLUE + "☣ Crit Chance", + EnumChatFormatting.BLUE + "☠ Crit Damage", + EnumChatFormatting.YELLOW + "⚔ Bonus Attack Speed", + EnumChatFormatting.RED + "๑ Ability Damage", + EnumChatFormatting.WHITE + "❂ True Defense", + EnumChatFormatting.RED + "⫽ Ferocity", + EnumChatFormatting.RED + "❣ Health Regen", + EnumChatFormatting.DARK_RED + "♨ Vitality", + EnumChatFormatting.GREEN + "☄ Mending", + EnumChatFormatting.YELLOW + "Ⓢ Swing Range", + + EnumChatFormatting.GOLD + "⸕ Mining Speed", + EnumChatFormatting.GOLD + "☘ Mining Fortune", + EnumChatFormatting.GOLD + "☘ Farming Fortune", + EnumChatFormatting.GOLD + "☘ Foraging Fortune", + EnumChatFormatting.DARK_GREEN + "Ⓟ Breaking Power", + EnumChatFormatting.DARK_PURPLE + "✧ Pristine", + EnumChatFormatting.GOLD + "☘ Wheat Fortune", + EnumChatFormatting.GOLD + "☘ Carrot Fortune", + EnumChatFormatting.GOLD + "☘ Potato Fortune", + EnumChatFormatting.GOLD + "☘ Pumpkin Fortune", + EnumChatFormatting.GOLD + "☘ Melon Fortune", + EnumChatFormatting.GOLD + "☘ Mushroom Fortune", + EnumChatFormatting.GOLD + "☘ Cactus Fortune", + EnumChatFormatting.GOLD + "☘ Sugar Cane Fortune", + EnumChatFormatting.GOLD + "☘ Nether Wart Fortune", + EnumChatFormatting.GOLD + "☘ Cocoa Beans Fortune", + + EnumChatFormatting.DARK_AQUA + "☯ Combat Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Mining Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Farming Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Foraging Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Fishing Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Enchanting Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Alchemy Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Carpentry Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Runecrafting Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Social Wisdom", + EnumChatFormatting.DARK_AQUA + "☯ Taming Wisdom", + + EnumChatFormatting.WHITE + "✦ Speed", + EnumChatFormatting.AQUA + "✯ Magic Find", + EnumChatFormatting.LIGHT_PURPLE + "♣ Pet Luck", + EnumChatFormatting.DARK_AQUA + "α Sea Creature Chance", + EnumChatFormatting.BLUE + "⚓ Double Hook Chance", + EnumChatFormatting.AQUA + "☂ Fishing Speed", + EnumChatFormatting.AQUA + "❄ Cold Resistance", + EnumChatFormatting.DARK_GREEN + "ൠ Bonus Pest Chance" }; - private static final HashMap<String, Pattern> STAT_PATTERN_MAP = new HashMap<String, Pattern>() { + + public static final HashMap<String, Pattern> STAT_PATTERN_MAP = new HashMap<String, Pattern>() { { - put(HEALTH, Pattern.compile("^Health: ((?:\\+|-)[0-9]+)")); - put(DEFENCE, Pattern.compile("^Defense: ((?:\\+|-)[0-9]+)")); - put(STRENGTH, Pattern.compile("^Strength: ((?:\\+|-)[0-9]+)")); - put(SPEED, Pattern.compile("^Speed: ((?:\\+|-)[0-9]+)")); - put(CRIT_CHANCE, Pattern.compile("^Crit Chance: ((?:\\+|-)[0-9]+)")); - put(CRIT_DAMAGE, Pattern.compile("^Crit Damage: ((?:\\+|-)[0-9]+)")); - put(BONUS_ATTACK_SPEED, Pattern.compile("^Bonus Attack Speed: ((?:\\+|-)[0-9]+)")); - put(INTELLIGENCE, Pattern.compile("^Intelligence: ((?:\\+|-)[0-9]+)")); - put(SEA_CREATURE_CHANCE, Pattern.compile("^Sea Creature Chance: ((?:\\+|-)[0-9]+)")); - put("ferocity", Pattern.compile("^Ferocity: ((?:\\+|-)[0-9]+)")); - put("ability_damage", Pattern.compile("^Ability Damage: ((?:\\+|-)[0-9]+)")); + put(HEALTH, Pattern.compile("^Health" + STAT_PATTERN_END)); + put(DEFENCE, Pattern.compile("^Defence" + STAT_PATTERN_END)); + put(STRENGTH, Pattern.compile("^Strength" + STAT_PATTERN_END)); + put(INTELLIGENCE, Pattern.compile("^Intelligence" + STAT_PATTERN_END)); + put(CRIT_CHANCE, Pattern.compile("^Crit Chance" + STAT_PATTERN_END)); + put(CRIT_DAMAGE, Pattern.compile("^Crit Damage" + STAT_PATTERN_END)); + put(BONUS_ATTACK_SPEED, Pattern.compile("^Bonus Attack Speed" + STAT_PATTERN_END)); + put(ABILITY_DAMAGE, Pattern.compile("^Ability Damage" + STAT_PATTERN_END)); + put(TRUE_DEFENSE, Pattern.compile("^True Defense" + STAT_PATTERN_END)); + put(FEROCITY, Pattern.compile("^Ferocity" + STAT_PATTERN_END)); + put(HEALTH_REGEN, Pattern.compile("^Health Regen" + STAT_PATTERN_END)); + put(VITALITY, Pattern.compile("^Vitality" + STAT_PATTERN_END)); + put(MENDING, Pattern.compile("^Mending" + STAT_PATTERN_END)); + put(SWING_RANGE, Pattern.compile("^Swing Range" + STAT_PATTERN_END)); + + put(MINING_SPEED, Pattern.compile("^Mining Speed" + STAT_PATTERN_END)); + put(MINING_FORTUNE, Pattern.compile("^Mining Fortune" + STAT_PATTERN_END)); + put(FARMING_FORTUNE, Pattern.compile("^Farming Fortune" + STAT_PATTERN_END)); + put(FORAGING_FORTUNE, Pattern.compile("^Foraging Fortune" + STAT_PATTERN_END)); + put(BREAKING_POWER, Pattern.compile("^Breaking Power" + STAT_PATTERN_END)); + put(PRISTINE, Pattern.compile("^Pristine" + STAT_PATTERN_END)); + put(WHEAT_FORTUNE, Pattern.compile("^Wheat Fortune" + STAT_PATTERN_END)); + put(CARROT_FORTUNE, Pattern.compile("^Carrot Fortune" + STAT_PATTERN_END)); + put(POTATO_FORTUNE, Pattern.compile("^Potato Fortune" + STAT_PATTERN_END)); + put(PUMPKIN_FORTUNE, Pattern.compile("^Pumpkin Fortune" + STAT_PATTERN_END)); + put(MELON_FORTUNE, Pattern.compile("^Melon Fortune" + STAT_PATTERN_END)); + put(MUSHROOM_FORTUNE, Pattern.compile("^Mushroom Fortune" + STAT_PATTERN_END)); + put(CACTUS_FORTUNE, Pattern.compile("^Cactus Fortune" + STAT_PATTERN_END)); + put(SUGAR_CANE_FORTUNE, Pattern.compile("^Sugar Cane Fortune" + STAT_PATTERN_END)); + put(NETHER_WART_FORTUNE, Pattern.compile("^Nether Wart Fortune" + STAT_PATTERN_END)); + put(COCOA_BEANS_FORTUNE, Pattern.compile("^Cocoa Beans Fortune" + STAT_PATTERN_END)); + + put(COMBAT_WISDOM, Pattern.compile("^Combat Wisdom" + STAT_PATTERN_END)); + put(MINING_WISDOM, Pattern.compile("^Mining Wisdom" + STAT_PATTERN_END)); + put(FARMING_WISDOM, Pattern.compile("^Farming Wisdom" + STAT_PATTERN_END)); + put(FORAGING_WISDOM, Pattern.compile("^Foraging Wisdom" + STAT_PATTERN_END)); + put(FISHING_WISDOM, Pattern.compile("^Fishing Wisdom" + STAT_PATTERN_END)); + put(ENCHANTING_WISDOM, Pattern.compile("^Enchanting Wisdom" + STAT_PATTERN_END)); + put(ALCHEMY_WISDOM, Pattern.compile("^Alchemy Wisdom" + STAT_PATTERN_END)); + put(CARPENTRY_WISDOM, Pattern.compile("^Carpentry Wisdom" + STAT_PATTERN_END)); + put(RUNECRAFTING_WISDOM, Pattern.compile("^Runecrafting Wisdom" + STAT_PATTERN_END)); + put(SOCIAL_WISDOM, Pattern.compile("^Social Wisdom" + STAT_PATTERN_END)); + put(TAMING_WISDOM, Pattern.compile("^Taming Wisdom" + STAT_PATTERN_END)); + + put(SPEED, Pattern.compile("^Speed" + STAT_PATTERN_END)); + put(MAGIC_FIND, Pattern.compile("^Magic Find" + STAT_PATTERN_END)); + put(PET_LUCK, Pattern.compile("^Pet Luck" + STAT_PATTERN_END)); + put(SEA_CREATURE_CHANCE, Pattern.compile("^Sea Creature Chance" + STAT_PATTERN_END)); + put(DOUBLE_HOOK_CHANCE, Pattern.compile("^Double Hook Chance" + STAT_PATTERN_END)); + put(FISHING_SPEED, Pattern.compile("^Fishing Speed" + STAT_PATTERN_END)); + put(COLD_RESISTANCE, Pattern.compile("^Cold Resistance" + STAT_PATTERN_END)); + put(BONUS_PEST_CHANCE, Pattern.compile("^Bonus Pest Chance" + STAT_PATTERN_END)); } }; + public static final String STAT_PATTERN_END = ": ((?:\\+|-)([0-9]+(\\.[0-9]+)?))%?"; + public static Stats getBaseStats() { JsonObject misc = Constants.MISC; if (misc == null) return null; @@ -211,7 +372,10 @@ public class PlayerStats { } private static float harpBonus(JsonObject profile) { - String talk_to_melody = Utils.getElementAsString(Utils.getElement(profile, "objectives.talk_to_melody.status"), "INCOMPLETE"); + String talk_to_melody = Utils.getElementAsString( + Utils.getElement(profile, "objectives.talk_to_melody.status"), + "INCOMPLETE" + ); if (talk_to_melody.equalsIgnoreCase("COMPLETE")) { return 26; } else { @@ -221,21 +385,30 @@ public class PlayerStats { private static float hotmFortune(JsonObject profile, Map<String, ProfileViewer.Level> skyblockInfo) { int miningLevelFortune = (int) (4 * (float) Math.floor(skyblockInfo.get("mining").level)); - int miningFortuneStat = ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_fortune"), 0)) * 5); - int miningFortune2Stat = ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_fortune_2"), 0)) * 5); + int miningFortuneStat = ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_fortune"), 0)) * + 5); + int miningFortune2Stat = ((Utils.getElementAsInt( + Utils.getElement(profile, "mining_core.nodes.mining_fortune_2"), + 0 + )) * 5); return miningFortuneStat + miningFortune2Stat + miningLevelFortune; } private static float hotmSpeed(JsonObject profile) { - int miningSpeedStat = ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_speed"), 0)) * 20); - int miningSpeed2Stat = ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_speed_2"), 0)) * 40); + int miningSpeedStat = ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_speed"), 0)) * + 20); + int miningSpeed2Stat = ((Utils.getElementAsInt(Utils.getElement(profile, "mining_core.nodes.mining_speed_2"), 0)) * + 40); return miningSpeedStat + miningSpeed2Stat; } public static Stats getPassiveBonuses(Map<String, ProfileViewer.Level> skyblockInfo, JsonObject profile) { Stats passiveBonuses = new Stats(); - Stats fairyBonus = getFairyBonus((int) Utils.getElementAsFloat(Utils.getElement(profile, "fairy_soul.fairy_exchanges"), 0)); + Stats fairyBonus = getFairyBonus((int) Utils.getElementAsFloat(Utils.getElement( + profile, + "fairy_soul.fairy_exchanges" + ), 0)); Stats skillBonus = getSkillBonus(skyblockInfo); Stats petBonus = getTamingBonus(profile); @@ -422,7 +595,12 @@ public class PlayerStats { if (itemBonuses.containsKey(internalname)) { continue; } - if (!talismanOnly || Utils.checkItemType(item.get("lore").getAsJsonArray(), true, "ACCESSORY", "HATCESSORY") >= 0) { + if (!talismanOnly || Utils.checkItemType( + item.get("lore").getAsJsonArray(), + true, + "ACCESSORY", + "HATCESSORY" + ) >= 0) { Stats itemBonus = getStatForItem(internalname, item, item.get("lore").getAsJsonArray()); itemBonuses.put(internalname, itemBonus); @@ -535,7 +713,8 @@ public class PlayerStats { String key = entryBoost.getKey().toLowerCase(Locale.ROOT); try { stats.addStat(key, entryBoost.getValue()); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } if (petStatBootsMult != null) { @@ -543,7 +722,8 @@ public class PlayerStats { String key = entryBoost.getKey().toLowerCase(Locale.ROOT); try { stats.scale(key, entryBoost.getValue()); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } } @@ -692,7 +872,10 @@ public class PlayerStats { quiverInfo.arrows.putIfAbsent(internalName, count); } - quiverInfo.selectedArrow = Utils.getElementAsString(Utils.getElement(profileInfo, "item_data.favorite_arrow"), null); + quiverInfo.selectedArrow = Utils.getElementAsString( + Utils.getElement(profileInfo, "item_data.favorite_arrow"), + null + ); return quiverInfo; } @@ -728,6 +911,10 @@ public class PlayerStats { ); }*/ + public int size() { + return statsJson.entrySet().size(); + } + public float get(String statName) { if (statsJson.has(statName)) { return statsJson.get(statName).getAsFloat(); |
