From 912cde5bf60e1ff6d887fbc4e26a153bfecc3711 Mon Sep 17 00:00:00 2001 From: Alex <8379108+Alex33856@users.noreply.github.com> Date: Mon, 7 Jul 2025 18:49:56 -0400 Subject: Add support for new shards in Search Overlay (#1427) * Add support for new shards in Search Overlay * Don't change id if not in bazaarstocks.json * Use Bazaar Stocks for enchants * Update NEU Repo, add Bazaar Stocks to ItemRepository, get ItemUtils#getNeuId() for attribute shards --- .../skyblocker/skyblock/itemlist/ItemRepository.java | 15 +++++++++++++++ .../skyblock/searchoverlay/SearchOverManager.java | 14 +++++++++++--- src/main/java/de/hysky/skyblocker/utils/ItemUtils.java | 7 ++++++- 3 files changed, 32 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java index 917db6f0..ac58cdcf 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemRepository.java @@ -6,6 +6,10 @@ import de.hysky.skyblocker.skyblock.itemlist.recipes.SkyblockForgeRecipe; import de.hysky.skyblocker.skyblock.itemlist.recipes.SkyblockRecipe; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.NEURepoManager; +import io.github.moulberry.repo.data.NEUCraftingRecipe; +import io.github.moulberry.repo.data.NEUItem; +import io.github.moulberry.repo.data.NEURecipe; +import io.github.moulberry.repo.util.NEUId; import io.github.moulberry.repo.data.*; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; @@ -21,12 +25,14 @@ public class ItemRepository { private static final List items = new ArrayList<>(); private static final Map itemsMap = new HashMap<>(); private static final List recipes = new ArrayList<>(); + private static final HashMap bazaarStocks = new HashMap<>(); private static boolean filesImported = false; @Init public static void init() { NEURepoManager.runAsyncAfterLoad(ItemStackBuilder::loadPetNums); NEURepoManager.runAsyncAfterLoad(ItemRepository::importItemFiles); + NEURepoManager.runAsyncAfterLoad(ItemRepository::loadBazaarStocks); } private static void importItemFiles() { @@ -64,6 +70,11 @@ public class ItemRepository { item.getRecipes().stream().map(ItemRepository::toSkyblockRecipe).filter(Objects::nonNull).forEach(recipes::add); } + private static void loadBazaarStocks() { + bazaarStocks.clear(); + NEURepoManager.NEU_REPO.getConstants().getBazaarStocks().getStocks().forEach((String neuId, String skyblockId) -> bazaarStocks.put(skyblockId, neuId)); + } + public static String getWikiLink(String neuId, boolean useOfficial) { NEUItem item = NEURepoManager.NEU_REPO.getItems().getItemBySkyblockId(neuId); if (item == null || item.getInfo() == null || item.getInfo().isEmpty()) { @@ -103,6 +114,10 @@ public class ItemRepository { return items.stream(); } + public static Map getBazaarStocks() { + return bazaarStocks; + } + /** * @param neuId the NEU item id gotten through {@link NEUItem#getSkyblockItemId()}, {@link ItemStack#getNeuName()}, or {@link ItemUtils#getNeuId(ItemStack) ItemTooltip#getNeuName(String, String)} */ diff --git a/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/SearchOverManager.java b/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/SearchOverManager.java index b6362691..721db667 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/SearchOverManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/searchoverlay/SearchOverManager.java @@ -7,6 +7,7 @@ import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.config.configs.UIAndVisualsConfig; import de.hysky.skyblocker.skyblock.item.tooltip.info.TooltipInfoType; +import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.utils.BazaarProduct; import de.hysky.skyblocker.utils.NEURepoManager; import de.hysky.skyblocker.utils.RomanNumerals; @@ -117,8 +118,10 @@ public class SearchOverManager { int sellVolume = product.sellVolume(); if (sellVolume == 0) continue; //do not add items that do not sell e.g. they are not actual in the bazaar + + // Format Enchantments Matcher matcher = BAZAAR_ENCHANTMENT_PATTERN.matcher(name); - if (matcher.matches()) {//format enchantments + if (matcher.matches() && ItemRepository.getBazaarStocks().containsKey(id)) { name = matcher.group(1); if (!name.contains("Ultimate Wise") && !name.contains("Ultimate Jerry")) { name = name.replace("Ultimate ", ""); @@ -132,16 +135,21 @@ public class SearchOverManager { String level = matcher.group(2); name += " " + RomanNumerals.decimalToRoman(Integer.parseInt(level)); bazaarItems.add(name); - namesToNeuId.put(name, id.substring(0, id.lastIndexOf('_')).replace("ENCHANTMENT_", "") + ";" + level); + namesToNeuId.put(name, ItemRepository.getBazaarStocks().get(id)); continue; } + + // Format Shards + if (id.startsWith("SHARD_") && ItemRepository.getBazaarStocks().containsKey(id)) { + id = ItemRepository.getBazaarStocks().get(id); + } + //look up id for name NEUItem neuItem = NEURepoManager.NEU_REPO.getItems().getItemBySkyblockId(id); if (neuItem != null) { name = Formatting.strip(neuItem.getDisplayName()); bazaarItems.add(name); namesToNeuId.put(name, id); - continue; } } } catch (Exception e) { diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index d9161332..d278ebc0 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -16,6 +16,7 @@ import de.hysky.skyblocker.skyblock.hunting.Attributes; import de.hysky.skyblocker.skyblock.item.PetInfo; import de.hysky.skyblocker.skyblock.item.tooltip.adders.ObtainedDateTooltip; import de.hysky.skyblocker.skyblock.item.tooltip.info.TooltipInfoType; +import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.utils.networth.NetworthCalculator; import it.unimi.dsi.fastutil.doubles.DoubleBooleanPair; import it.unimi.dsi.fastutil.ints.IntIntPair; @@ -242,7 +243,11 @@ public final class ItemUtils { yield rune.toUpperCase(Locale.ENGLISH) + "_RUNE;" + runes.getInt(rune, 0); } case "POTION" -> "POTION_" + customData.getString("potion", "").toUpperCase(Locale.ENGLISH) + ";" + customData.getInt("potion_level", 0); - case "ATTRIBUTE_SHARD" -> "ATTRIBUTE_SHARD"; + case "ATTRIBUTE_SHARD" -> { + Attribute attribute = Attributes.getAttributeFromItemName(stack); + if (attribute == null) yield id; + yield ItemRepository.getBazaarStocks().getOrDefault(attribute.apiId(), id); + } case "PARTY_HAT_CRAB", "BALLOON_HAT_2024", "BALLOON_HAT_2025" -> id + "_" + customData.getString("party_hat_color", "").toUpperCase(Locale.ENGLISH); case "PARTY_HAT_CRAB_ANIMATED" -> "PARTY_HAT_CRAB_" + customData.getString("party_hat_color", "").toUpperCase(Locale.ENGLISH) + "_ANIMATED"; case "PARTY_HAT_SLOTH" -> id + "_" + customData.getString("party_hat_emoji", "").toUpperCase(Locale.ENGLISH); -- cgit