Skip to content

Commit

Permalink
Fix item lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Sep 5, 2024
1 parent 9637934 commit 91a2bb9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class BazaarHelper extends SimpleSlotTextAdder {
private static final Pattern FILLED_PATTERN = Pattern.compile("Filled: \\S+ \\(?([\\d.]+)%\\)?!?");
Expand All @@ -29,9 +28,6 @@ public BazaarHelper() {
super("(?:Co-op|Your) Bazaar Orders");
}

@Init
public static void init() {}

@Override
public boolean isEnabled() {
return SkyblockerConfigManager.get().helpers.bazaar.enableBazaarHelper;
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/de/hysky/skyblocker/skyblock/item/ItemPrice.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.hysky.skyblocker.skyblock.item.tooltip.info.DataTooltipInfoType;
import de.hysky.skyblocker.skyblock.item.tooltip.info.TooltipInfoType;
import de.hysky.skyblocker.skyblock.itemlist.ItemRepository;
import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.scheduler.MessageScheduler;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
Expand Down Expand Up @@ -31,13 +32,29 @@ public class ItemPrice {
"key.categories.skyblocker"
));

public static void init() {}

public static void itemPriceLookup(ClientPlayerEntity player, @NotNull Slot slot) {
ItemStack stack = ItemRepository.getItemStack(slot.getStack().getNeuName());
if (stack != null && !stack.isEmpty()) {
String itemName = Formatting.strip(stack.getName().getString()).replaceFirst("\\[Lvl \\d+ ➡ \\d+] ", "");
if (TooltipInfoType.BAZAAR.getData() != null) {
ItemStack stack = slot.getStack();
String skyblockApiId = stack.getSkyblockApiId();
ItemStack neuStack = ItemRepository.getItemStack(stack.getNeuName());
if (neuStack != null && !neuStack.isEmpty()) {
String itemName = Formatting.strip(neuStack.getName().getString());

// Handle Pets
if (stack.getSkyblockId().equals("PET")) {
itemName = itemName.replaceFirst("\\[Lvl \\d+ ➡ \\d+] ", "");
}

// Handle Enchanted Books
if (itemName.equals("Enchanted Book")) {
itemName = SearchOverManager.capitalizeFully(skyblockApiId.replace("ENCHANTMENT_", "").replaceAll("_\\d+", ""));
}

// Search up the item in the bazaar or auction house
if (TooltipInfoType.BAZAAR.hasOrNullWarning(skyblockApiId)) {
MessageScheduler.INSTANCE.sendMessageAfterCooldown("/bz " + itemName);
} else if (TooltipInfoType.LOWEST_BINS.getData() != null) {
} else if (TooltipInfoType.LOWEST_BINS.hasOrNullWarning(skyblockApiId)) {
MessageScheduler.INSTANCE.sendMessageAfterCooldown("/ahsearch " + itemName);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private static void loadItems() {
*
* @param str string to capitalize
*/
private static String capitalizeFully(String str) {
public static String capitalizeFully(String str) {
if (str == null || str.isEmpty()) {
return str;
}
Expand Down

0 comments on commit 91a2bb9

Please sign in to comment.