Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import de.hysky.skyblocker.utils.BazaarProduct;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.FlexibleItemStack;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.NEURepoManager;
import de.hysky.skyblocker.utils.scheduler.MessageScheduler;
import io.github.moulberry.repo.data.NEUItem;
Expand Down Expand Up @@ -71,6 +72,7 @@ public class SearchOverManager {
private static HashSet<String> bazaarItems = new HashSet<>();
private static HashSet<String> auctionItems = new HashSet<>();
private static HashSet<String> auctionPets = new HashSet<>();
private static HashSet<String> level200Pets = new HashSet<>();
private static HashSet<String> starableItems = new HashSet<>();
private static HashMap<String, String> namesToNeuId = new HashMap<>();

Expand Down Expand Up @@ -124,6 +126,7 @@ private static void loadItems() {
HashSet<String> bazaarItems = new HashSet<>();
HashSet<String> auctionItems = new HashSet<>();
HashSet<String> auctionPets = new HashSet<>();
HashSet<String> level200Pets = new HashSet<>();
HashSet<String> starableItems = new HashSet<>();
HashMap<String, String> namesToNeuId = new HashMap<>();

Expand Down Expand Up @@ -176,15 +179,21 @@ private static void loadItems() {

for (Object2DoubleMap.Entry<String> entry : TooltipInfoType.THREE_DAY_AVERAGE.getData().object2DoubleEntrySet()) {
String id = entry.getKey();
id = ItemUtils.getNeuIdFromApiId(id);
//look up in NEU repo.
id = id.split("[+-]")[0];
String[] parts = id.split("[+-]");
id = parts[0];
NEUItem neuItem = NEURepoManager.getItemByNeuId(id);
if (neuItem != null) {
String name = ChatFormatting.stripFormatting(neuItem.getDisplayName());
//add names that are pets to the list of pets to work with the lvl 100 button
if (name != null && name.startsWith(PET_NAME_START)) {
name = name.replace(PET_NAME_START, "");
auctionPets.add(name.toLowerCase(Locale.ENGLISH));
String petName = name.toLowerCase(Locale.ENGLISH);
auctionPets.add(petName);
if (parts.length >= 2 && parts[1].equals("200")) {
level200Pets.add(petName);
}
}
//if it has essence cost add to starable items
if (name != null && essenceCosts.contains(neuItem.getSkyblockItemId())) {
Expand All @@ -201,6 +210,7 @@ private static void loadItems() {
SearchOverManager.bazaarItems = bazaarItems;
SearchOverManager.auctionItems = auctionItems;
SearchOverManager.auctionPets = auctionPets;
SearchOverManager.level200Pets = level200Pets;
SearchOverManager.starableItems = starableItems;
SearchOverManager.namesToNeuId = namesToNeuId;
}
Expand Down Expand Up @@ -445,11 +455,8 @@ private static void addExtras() {
if (maxPetLevel) {
String lcSearch = search.toLowerCase(Locale.ENGLISH);
if (auctionPets.contains(lcSearch)) {
if (lcSearch.endsWith("dragon") && !lcSearch.startsWith("ender")) {
search = "[Lvl 200] " + search;
} else {
search = "[Lvl 100] " + search;
}
int maxLevel = level200Pets.contains(lcSearch) ? 200 : 100;
search = "[Lvl %d] %s".formatted(maxLevel, search);
}
} else {
// still filter for only pets
Expand Down
31 changes: 28 additions & 3 deletions src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.hysky.skyblocker.skyblock.item.tooltip.info.TooltipInfoType;
import de.hysky.skyblocker.skyblock.tabhud.util.Ico;
import de.hysky.skyblocker.utils.networth.NetworthCalculator;
import io.github.moulberry.repo.util.NEUId;
import it.unimi.dsi.fastutil.doubles.DoubleBooleanPair;
import it.unimi.dsi.fastutil.ints.IntIntPair;
import it.unimi.dsi.fastutil.longs.LongBooleanPair;
Expand Down Expand Up @@ -210,9 +211,9 @@ public static String getSkyblockApiId(DataComponentGetter stack) {
}
}
case "POTION" -> {
String enhanced = customData.contains("enhanced") ? "_ENHANCED" : "";
String extended = customData.contains("extended") ? "_EXTENDED" : "";
String splash = customData.contains("splash") ? "_SPLASH" : "";
String enhanced = customData.getBooleanOr("enhanced", false) ? "_ENHANCED" : "";
String extended = customData.getBooleanOr("extended", false) ? "_EXTENDED" : "";
String splash = customData.getBooleanOr("splash", false) ? "_SPLASH" : "";
if (customData.contains("potion") && customData.contains("potion_level")) {
return (customData.getStringOr("potion", "") + "_" + id + "_" + customData.getIntOr("potion_level", 0)
+ enhanced + extended + splash).toUpperCase(Locale.ENGLISH);
Expand Down Expand Up @@ -326,6 +327,30 @@ public static String getNeuId(DataComponentGetter stack) {
};
}

public static @NEUId String getNeuIdFromApiId(String apiId) {
// Pets
if (apiId.startsWith("LVL_")) {
String[] parts = apiId.split("_", 4);
if (parts.length != 4) return apiId;
Optional<SkyblockItemRarity> rarity = SkyblockItemRarity.containsName(parts[2]);
//noinspection OptionalIsPresent
if (rarity.isEmpty()) return apiId;
return parts[3] + ";" + rarity.get().ordinal() + "+" + parts[1];
}

// Potions
if (apiId.contains("_POTION_")) {
String[] parts = apiId.split("_POTION_", 2);
if (parts.length != 2) return apiId;
String potionName = parts[0];
parts = parts[1].split("_", 2);
String potionLevel = parts[0];
return "POTION_" + potionName + ";" + potionLevel;
}

return apiId;
}

/**
* Parses the {@code petInfo} field from a pet item that has it into the {@link PetInfo} record.
*
Expand Down
Loading