diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2023-05-31 13:04:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-31 13:04:41 +0200 |
commit | f4a9e4011b09be043ec086abd365d0e8c443bbec (patch) | |
tree | 763a8dc14d8b1e4a4af59f5f649a465a3c721c37 /src/main/java | |
parent | 3740ac08399d4c16802729511b5032e8f8ac6e14 (diff) | |
download | NotEnoughUpdates-f4a9e4011b09be043ec086abd365d0e8c443bbec.tar.gz NotEnoughUpdates-f4a9e4011b09be043ec086abd365d0e8c443bbec.tar.bz2 NotEnoughUpdates-f4a9e4011b09be043ec086abd365d0e8c443bbec.zip |
Add NPC Sell price to tooltip (#702)
Diffstat (limited to 'src/main/java')
5 files changed, 41 insertions, 25 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index 7d408e0f..6e7f83e4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -26,6 +26,7 @@ import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; +import io.github.moulberry.notenoughupdates.util.hypixelapi.HypixelItemAPI; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import org.lwjgl.input.Keyboard; @@ -123,22 +124,18 @@ public class ItemPriceInformation { } } + int shiftStackMultiplier = useStackSize && stack.stackSize > 1 ? stack.stackSize : stack.getItem().getItemStackLimit(stack); + if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(STACKSIZE_OVERRIDE)) { + shiftStackMultiplier = stack.getTagCompound().getInteger(STACKSIZE_OVERRIDE); + } + int stackMultiplier = 1; + boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); + if (shiftPressed) { + stackMultiplier = shiftStackMultiplier; + } + boolean added = false; if (bazaarItem) { List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoBaz; - - boolean added = false; - - boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); - - int stackMultiplier = 1; - int shiftStackMultiplier = useStackSize && stack.stackSize > 1 ? stack.stackSize : 64; - if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(STACKSIZE_OVERRIDE)) { - shiftStackMultiplier = stack.getTagCompound().getInteger(STACKSIZE_OVERRIDE); - } - if (shiftPressed) { - stackMultiplier = shiftStackMultiplier; - } - //values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost", "Instabuys (Hourly)", "Instasells (Hourly)", "Instabuys (Daily)", "Instasells (Daily)", "Instabuys (Weekly)", "Instasells (Weekly)"} for (int lineId : lines) { switch (lineId) { @@ -288,7 +285,6 @@ public class ItemPriceInformation { } else if (auctionItem && !auctionInfoErrored) { List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoAuc; - boolean added = false; for (int lineId : lines) { switch (lineId) { @@ -444,14 +440,13 @@ public class ItemPriceInformation { } } else if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.rawCraft && craftCost != null && craftCost.fromRecipe) { - - if (craftCost.craftCost == 0) return; - double cost = craftCost.craftCost; - int shiftStackMultiplier = useStackSize && stack.stackSize > 1 ? stack.stackSize : 64; - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) cost = cost * shiftStackMultiplier; - tooltip.add(""); - tooltip.add(formatPrice("Raw Craft Cost: ", cost)); - + if (craftCost.craftCost != 0) { + double cost = craftCost.craftCost; + cost = cost * stackMultiplier; + added = true; + tooltip.add(""); + tooltip.add(formatPrice("Raw Craft Cost: ", cost)); + } } else if (auctionInfoErrored && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { String message = EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "[NEU] API is down"; if (auctionableItems != null && !auctionableItems.isEmpty()) { @@ -462,6 +457,12 @@ public class ItemPriceInformation { tooltip.add(message + " and no item data is cached"); } } + Double npcSellPrice = HypixelItemAPI.getNPCSellPrice(internalname); + if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.npcSellPrice && npcSellPrice != null) { + if (!added) + tooltip.add(""); + tooltip.add(formatPrice("NPC Sell Price: ", npcSellPrice * stackMultiplier)); + } } private static String formatPrice(String label, double price) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 794df0f4..c6a0c04f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -54,6 +54,7 @@ import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.recipes.RecipeGenerator; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.brigadier.BrigadierRoot; +import io.github.moulberry.notenoughupdates.util.hypixelapi.HypixelItemAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -301,6 +302,7 @@ public class NotEnoughUpdates { manager.loadItemInformation(); overlay = new NEUOverlay(manager); profileViewer = new ProfileViewer(manager); + HypixelItemAPI.INSTANCE.loadItemData(); for (KeyBinding kb : manager.keybinds) { ClientRegistry.registerKeyBinding(kb); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/loader/KotlinLoadingTweaker.java b/src/main/java/io/github/moulberry/notenoughupdates/loader/KotlinLoadingTweaker.java index bf4e746f..720dd540 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/loader/KotlinLoadingTweaker.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/loader/KotlinLoadingTweaker.java @@ -82,7 +82,7 @@ public class KotlinLoadingTweaker implements ITweaker { * Full version format: [1, 7, 20] (1.7.20) * RC version format: [1, 7, 20, 1] (1.7.20-rc1) */ - public static final int[] BUNDLED_KOTLIN_VERSION = new int[]{1, 8, 0}; + public static final int[] BUNDLED_KOTLIN_VERSION = new int[]{1, 8, 21}; @Override public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java index cd6ecb26..2957015b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java @@ -95,6 +95,15 @@ public class TooltipTweaks { @Expose @ConfigOption( + name = "Show NPC Sell price on Items", + desc = "Display for how much items can be sold to NPC Shops" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean npcSellPrice = false; + + @Expose + @ConfigOption( name = "Use Short Number Format", desc = "Use Short Numbers (5.1m) instead of 5,130,302" ) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java index 0cda91fd..4cb1abc8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java @@ -20,9 +20,11 @@ package io.github.moulberry.notenoughupdates.util; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent; +import io.github.moulberry.notenoughupdates.util.kotlin.KotlinTypeAdapterFactory; import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import org.apache.commons.io.IOUtils; @@ -63,7 +65,9 @@ import java.util.concurrent.Executors; import java.util.zip.GZIPInputStream; public class ApiUtil { - private static final Gson gson = new Gson(); + private static final Gson gson = new GsonBuilder() + .registerTypeAdapterFactory(KotlinTypeAdapterFactory.INSTANCE) + .create(); private static final Comparator<NameValuePair> nameValuePairComparator = Comparator .comparing(NameValuePair::getName) |