From 1f94e68c0f319941395ac0940472cf1686e1d8d2 Mon Sep 17 00:00:00 2001 From: Rime <81419447+Emirlol@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:34:12 +0300 Subject: Change the bz order helper to only show one icon at a time Also adds some convenience methods to SlotText to make the `SlotTextAdder` logic more readable --- .../hysky/skyblocker/skyblock/bazaar/BazaarHelper.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/bazaar') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/bazaar/BazaarHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/bazaar/BazaarHelper.java index 032d2295..aeef9d21 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/bazaar/BazaarHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/bazaar/BazaarHelper.java @@ -4,7 +4,6 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.item.slottext.SlotText; import de.hysky.skyblocker.skyblock.item.slottext.SlotTextAdder; import de.hysky.skyblocker.utils.ItemUtils; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.item.ItemStack; import net.minecraft.screen.slot.Slot; import net.minecraft.text.MutableText; @@ -38,22 +37,21 @@ public class BazaarHelper extends SlotTextAdder { ItemStack item = slot.getStack(); if (item.isEmpty()) return List.of(); //We've skipped all invalid slots, so we can just check if it's not air here. - ObjectArrayList icons = new ObjectArrayList<>(); - if (ItemUtils.getLoreLineIf(item, str -> str.equals("Expired!")) != null) { - //Todo: Handle the case where the order is close to expiring but hasn't expired yet. - icons.add(SlotText.topRight(getExpiredIcon(true))); - } - Matcher matcher = ItemUtils.getLoreLineIfMatch(item, FILLED_PATTERN); if (matcher != null) { List lore = ItemUtils.getLore(item); - if (!lore.isEmpty() && lore.getLast().getString().equals("Click to claim!")) { + if (!lore.isEmpty() && lore.getLast().getString().equals("Click to claim!")) { //Only show the filled icon when there are items to claim int filled = NumberUtils.toInt(matcher.group(1)); - icons.add(SlotText.topLeft(getFilledIcon(filled))); + return SlotText.topLeftList(getFilledIcon(filled)); } } - return icons; + if (ItemUtils.getLoreLineIf(item, str -> str.equals("Expired!")) != null) { + //Todo: Handle the case where the order is close to expiring but hasn't expired yet. + return SlotText.topLeftList(getExpiredIcon(true)); + } + + return List.of(); } public static @NotNull MutableText getExpiredIcon(boolean expired) { -- cgit