Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Dec 27, 2024
1 parent 2a98a8c commit 9633ed9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.helpers.enableNewYearCakesHelper = newValue)
.controller(ConfigUtils::createBooleanController)
.build())

// Bits Helper
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.helpers.enableBitsHelper"))
Expand All @@ -35,6 +36,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())

// Wardrobe Helper
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.helpers.enableWardrobeHelper"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.helpers.enableWardrobeHelper.@Tooltip")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List<Text>
ObjectLongPair<String> innerMap, innerMapGreen;
if (bestSlotIndexSelling != -1) if (bestSlotIndexSelling == focusedSlot.getIndex()) isGreen = true;

BestItemsResult result = calculateBestItems(getSlots());
calculateBestItems(getSlots());
innerMap = categoryOutput.get(outerKey);
innerMapGreen = categoryOutput.get(outerKey + "GREEN");

Expand All @@ -217,12 +217,12 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List<Text>
lines.add(Text.empty()
.append(Text.literal("Bits Cost: ").formatted(Formatting.AQUA))
.append(Text.literal(DECIMAL_FORMAT.format(coinsPerBit) + " Coins per bit").formatted(Formatting.DARK_AQUA)));
lines.add(Text.literal("From " + ItemRepository.getItemStack(itemID).getName().getString()).formatted(Formatting.GREEN));
lines.add(Text.literal("From " + foundItemStack.getName().getString()).formatted(Formatting.GREEN));
} else if (foundItemStack != null) {
lines.add(Text.empty()
.append(Text.literal("Bits Cost: ").formatted(Formatting.AQUA))
.append(Text.literal(DECIMAL_FORMAT.format(coinsPerBit) + " Coins per bit").formatted(Formatting.DARK_AQUA)));
lines.add(Text.literal("From " + ItemRepository.getItemStack(itemID).getName().getString()).formatted(Formatting.DARK_AQUA));
lines.add(Text.literal("From " + foundItemStack.getName().getString()).formatted(Formatting.DARK_AQUA));
} else { // if below so it won't clog logs with that cursed enchanted book
if (!stack.getName().getString().equals("Stacking Enchants")) LOGGER.warn(LOGS_PREFIX + "ItemStack not found for {}", itemID);
lines.add(Text.empty()
Expand All @@ -238,8 +238,7 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List<Text>
*/
private Int2ObjectMap<ItemStack> getSlots() {
MinecraftClient client = MinecraftClient.getInstance();
if (client.currentScreen instanceof HandledScreen) {
HandledScreen<?> screen = (HandledScreen<?>) client.currentScreen;
if (client.currentScreen instanceof HandledScreen<?> screen) {
ScreenHandler handler = screen.getScreenHandler();

Int2ObjectMap<ItemStack> slots = new Int2ObjectOpenHashMap<>();
Expand Down Expand Up @@ -282,7 +281,6 @@ private BestItemsResult calculateBestItems(Int2ObjectMap<ItemStack> slots) {
if (stack == null || stack.isEmpty()) continue;

if (CATEGORY_PATTERN.matcher(ItemUtils.concatenateLore(ItemUtils.getLore(stack))).find()) {
String catName = stack.getName().getString();
ObjectLongImmutablePair<String> categoryResults = calculateBestInCategory(stack);

String itemID = categoryResults.left();
Expand All @@ -302,11 +300,12 @@ private BestItemsResult calculateBestItems(Int2ObjectMap<ItemStack> slots) {

for (Int2ObjectMap.Entry<ItemStack> entry : slots.int2ObjectEntrySet()) {
ItemStack stack = entry.getValue();
if (stack == null || stack.isEmpty()) continue;

String itemId = stack.getSkyblockApiId();
String lore = ItemUtils.concatenateLore(ItemUtils.getLore(stack));
Matcher bitsMatcher = BITS_PATTERN.matcher(lore);

if (stack == null || stack.isEmpty() || !bitsMatcher.find()) continue;
if (!bitsMatcher.find()) continue;

long bitsCost = Long.parseLong(bitsMatcher.group("amount").replace(",", ""));
double itemCost = ItemUtils.getItemPrice(stack).keyDouble() * stack.getCount();
Expand Down

0 comments on commit 9633ed9

Please sign in to comment.