From 9633ed90c30a3dbd0a500b36cb236798cdaf71a4 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Thu, 26 Dec 2024 19:17:10 -0800 Subject: [PATCH] Cleanup --- .../config/categories/HelperCategory.java | 2 ++ .../skyblock/item/tooltip/adders/BitsHelper.java | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java index 686a7dfc2b..4bfbbdaef1 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/HelperCategory.java @@ -25,6 +25,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.helpers.enableNewYearCakesHelper = newValue) .controller(ConfigUtils::createBooleanController) .build()) + // Bits Helper .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.helpers.enableBitsHelper")) @@ -35,6 +36,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .controller(ConfigUtils::createBooleanController) .build()) + // Wardrobe Helper .option(Option.createBuilder() .name(Text.translatable("skyblocker.config.helpers.enableWardrobeHelper")) .description(OptionDescription.of(Text.translatable("skyblocker.config.helpers.enableWardrobeHelper.@Tooltip"))) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BitsHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BitsHelper.java index 2e0c2a0d9a..627da833e0 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BitsHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/adders/BitsHelper.java @@ -194,7 +194,7 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List ObjectLongPair 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"); @@ -217,12 +217,12 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List 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() @@ -238,8 +238,7 @@ public void addToTooltip(@Nullable Slot focusedSlot, ItemStack stack, List */ private Int2ObjectMap 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 slots = new Int2ObjectOpenHashMap<>(); @@ -282,7 +281,6 @@ private BestItemsResult calculateBestItems(Int2ObjectMap slots) { if (stack == null || stack.isEmpty()) continue; if (CATEGORY_PATTERN.matcher(ItemUtils.concatenateLore(ItemUtils.getLore(stack))).find()) { - String catName = stack.getName().getString(); ObjectLongImmutablePair categoryResults = calculateBestInCategory(stack); String itemID = categoryResults.left(); @@ -302,11 +300,12 @@ private BestItemsResult calculateBestItems(Int2ObjectMap slots) { for (Int2ObjectMap.Entry 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();