diff options
| author | nea <nea@nea.moe> | 2023-02-06 21:07:01 +0100 |
|---|---|---|
| committer | nea <nea@nea.moe> | 2023-02-06 21:07:01 +0100 |
| commit | 62e0919fcd091338e2d15b139d88517206c435b7 (patch) | |
| tree | 2c3cb16e6e092fa9f4ecc849fcd9e7311e6408fe /src/main | |
| parent | 5a113b83d0429a712d70b3b6ef22224493d69b32 (diff) | |
| parent | 5e77a5d07faa6bfced80eef06ce34d43661fcba4 (diff) | |
| download | NotEnoughUpdates-62e0919fcd091338e2d15b139d88517206c435b7.tar.gz NotEnoughUpdates-62e0919fcd091338e2d15b139d88517206c435b7.tar.bz2 NotEnoughUpdates-62e0919fcd091338e2d15b139d88517206c435b7.zip | |
Merge remote-tracking branch 'origin/master' into brigadier
Diffstat (limited to 'src/main')
34 files changed, 2520 insertions, 898 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index 8096c2d5..5c851211 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -54,8 +54,8 @@ public class ItemPriceInformation { private static final NumberFormat format = new DecimalFormat("#,##0.#", new DecimalFormatSymbols(Locale.US)); public static String STACKSIZE_OVERRIDE = "NEU_STACKSIZE_OVERRIDE"; - public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack) { - return addToTooltip(tooltip, internalname, stack, true); + public static void addToTooltip(List<String> tooltip, String internalName, ItemStack stack) { + addToTooltip(tooltip, internalName, stack, true); } public static void init(File saveLocation, Gson neuGson) { @@ -92,16 +92,16 @@ public class ItemPriceInformation { } } - public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) { + public static void addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) { if (stack.getTagCompound().hasKey("disableNeuTooltip") && stack.getTagCompound().getBoolean("disableNeuTooltip")) { - return false; + return; } if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKey && !KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKeyKeybind)) { - return false; + return; } if (internalname.equals("SKYBLOCK_MENU")) { - return false; + return; } JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname); @@ -207,7 +207,6 @@ public class ItemPriceInformation { } } - return added; } else if (auctionItem && !auctionInfoErrored) { List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoAuc; @@ -366,21 +365,16 @@ public class ItemPriceInformation { } } - return added; } else if (auctionInfoErrored && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { String message = EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "[NEU] API is down"; if (auctionableItems != null && !auctionableItems.isEmpty()) { if (auctionableItems.contains(internalname)) { tooltip.add(message); - return true; } } else { tooltip.add(message + " and no item data is cached"); - return true; } } - - return false; } private static String formatPrice(String label, double price) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index cb0f3fc0..7159ef89 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1046,7 +1046,7 @@ public class NEUOverlay extends Gui { } } - if (!Keyboard.getEventKeyState()) { + if (Keyboard.getEventKeyState()) { if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) { searchBarHasFocus = false; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 6ae5dd80..5ec3724a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -744,7 +744,9 @@ public class APIManager { JsonObject productInfo = new JsonObject(); JsonObject product = entry.getValue().getAsJsonObject(); - JsonObject quickStatus = product.get("quick_status").getAsJsonObject(); + JsonObject quickStatus = product.getAsJsonObject("quick_status"); + if (!hasData(quickStatus)) continue; + productInfo.addProperty("avg_buy", quickStatus.get("buyPrice").getAsFloat()); productInfo.addProperty("avg_sell", quickStatus.get("sellPrice").getAsFloat()); @@ -771,6 +773,19 @@ public class APIManager { }); } + private static boolean hasData(JsonObject quickStatus) { + for (Map.Entry<String, JsonElement> e : quickStatus.entrySet()) { + String key = e.getKey(); + if (!key.equals("productId")) { + double value = e.getValue().getAsDouble(); + if (value != 0) { + return true; + } + } + } + return false; + } + public void updateAvgPrices() { manager.apiUtils .newMoulberryRequest("auction_averages/3day.json.gz") diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java index c19c4826..c7c118bb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java @@ -24,6 +24,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import java.io.UnsupportedEncodingException; +import java.math.BigInteger; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Set; @@ -71,7 +72,17 @@ public class StringUtils { return shortNumberFormat(n, 0); } - private static final char[] c = new char[] { 'k', 'm', 'b', 't' }; + private static final char[] sizeSuffix = new char[]{'k', 'm', 'b', 't'}; + + public static String shortNumberFormat(BigInteger bigInteger) { + BigInteger THOUSAND = BigInteger.valueOf(1000); + int i = -1; + while (bigInteger.compareTo(THOUSAND) > 0 && i < sizeSuffix.length) { + bigInteger = bigInteger.divide(THOUSAND); + i++; + } + return bigInteger.toString() + (i == -1 ? "" : sizeSuffix[i]); + } public static String shortNumberFormat(double n, int iteration) { if (n < 1000) { @@ -84,7 +95,7 @@ public class StringUtils { double d = ((long) n / 100) / 10.0; boolean isRound = (d * 10) % 10 == 0; - return d < 1000 ? (isRound || d > 9.99 ? (int) d * 10 / 10 : d + "") + "" + c[iteration] : shortNumberFormat(d, iteration + 1); + return d < 1000 ? (isRound || d > 9.99 ? (int) d * 10 / 10 : d + "") + "" + sizeSuffix[iteration] : shortNumberFormat(d, iteration + 1); } public static String urlEncode(String something) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java b/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java index 4fa57360..e84fce11 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Linnea Gräf + * Copyright (C) 2022-2023 Linnea Gräf * * This file is part of NotEnoughUpdates. * @@ -26,15 +26,22 @@ import javax.net.ssl.HttpsURLConnection; import java.net.HttpURLConnection; public class ThreadDownloadImageHook { + public static String hookThreadImageLink(String originalLink) { + if (!NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls || originalLink == null || !originalLink.startsWith( + "http://textures.minecraft.net")) + return originalLink; + return originalLink.replace("http://", "https://"); + } + public static void hookThreadImageConnection(HttpURLConnection connection) { if ((connection instanceof HttpsURLConnection) && NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls) { ApiUtil.patchHttpsRequest((HttpsURLConnection) connection); } } - public static String hookThreadImageLink(String originalLink) { - if (!NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls || originalLink == null) - return originalLink; - return originalLink.replace("http://", "https://"); + public interface AccessorThreadDownloadImageData { + String getOriginalUrl(); + + String getPatchedUrl(); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index e350c489..716fb37d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -447,13 +447,14 @@ public class PetInfoOverlay extends TextOverlay { if (pet.petLevel.getCurrentLevel() >= pet.petLevel.getMaxLevel()) return 0; if (validXpTypes == null) - validXpTypes = Lists.newArrayList("mining", "foraging", "enchanting", "farming", "combat", "fishing", "alchemy"); + validXpTypes = Lists.newArrayList("mining", "foraging", "enchanting", "farming", "combat", "fishing", "alchemy", "all"); if (!validXpTypes.contains(xpType.toLowerCase())) return 0; float tamingPercent = 1.0f + (config.tamingLevel / 100f); xp = xp * tamingPercent; xp = xp + (xp * config.beastMultiplier / 100f); - if (pet.petXpType != null && !pet.petXpType.equalsIgnoreCase(xpType)) { + + if (pet.petXpType != null && !pet.petXpType.equalsIgnoreCase(xpType) && !pet.petXpType.equalsIgnoreCase("all")) { xp = xp / 3f; if (xpType.equalsIgnoreCase("alchemy") || xpType.equalsIgnoreCase("enchanting")) { @@ -463,6 +464,7 @@ public class PetInfoOverlay extends TextOverlay { if (xpType.equalsIgnoreCase("mining") || xpType.equalsIgnoreCase("fishing")) { xp = xp * 1.5f; } + if (pet.petItem != null) { Matcher petItemMatcher = XP_BOOST_PATTERN.matcher(pet.petItem); if ((petItemMatcher.matches() && petItemMatcher.group(1).equalsIgnoreCase(xpType)) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java index 48d37f2f..87691631 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java @@ -298,6 +298,7 @@ public class CalendarOverlay { boolean changed = false; for (int i = 0; i < 31; i++) { ItemStack item = cc.getLowerChestInventory().getStackInSlot(1 + (i % 7) + (i / 7) * 9); + if (item == null) continue; JsonArray array = new JsonArray(); if (item.getTagCompound() != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index 8878c284..5dd8bd9c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -55,7 +55,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ClientCommandHandler; import org.lwjgl.input.Keyboard; @@ -392,6 +391,10 @@ public class StorageOverlay extends GuiElement { searchTextColour = 0xa0a0a0; } + if (NotEnoughUpdates.INSTANCE.config.storageGUI.useCustomTextColour) { + textColour = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.storageGUI.customTextColour); + } + long currentTime = System.currentTimeMillis(); if (lastMillis > 0) { long deltaTime = currentTime - lastMillis; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java index c6d25a9e..fd4ee495 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Linnea Gräf + * Copyright (C) 2022-2023 Linnea Gräf * * This file is part of NotEnoughUpdates. * @@ -30,12 +30,14 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ThreadDownloadImageData.class) -public class MixinThreadDownloadImageData { +public class MixinThreadDownloadImageData implements ThreadDownloadImageHook.AccessorThreadDownloadImageData{ @Mutable @Shadow @Final private String imageUrl; + private String originalUrl; + @Redirect( method = "<init>", at = @At( @@ -44,5 +46,16 @@ public class MixinThreadDownloadImageData { opcode = Opcodes.PUTFIELD)) public void useHttpsDownloadLinks(ThreadDownloadImageData instance, String value) { this.imageUrl = ThreadDownloadImageHook.hookThreadImageLink(value); + this.originalUrl = value; + } + + @Override + public String getOriginalUrl() { + return originalUrl; + } + + @Override + public String getPatchedUrl() { + return imageUrl; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java index 30915daa..42a52639 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java @@ -103,4 +103,12 @@ public class ProfileViewer { ) @ConfigEditorBoolean public boolean useSoopyNetworth = true; + + @Expose + @ConfigOption( + name = "Display Weight", + desc = "Display Lily and Senither Weight in the Basic PV page" + ) + @ConfigEditorBoolean + public boolean displayWeight = true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java index 08c48945..131ac669 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -155,6 +155,26 @@ public class StorageGUI { @Expose @ConfigOption( + name = "Custom Text Colour", + desc = "Use a custom default text colour.\nOverrides the colour set by the overlay style.\nCan be overridden by using colour codes in the page title.", + searchTags = "color" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean useCustomTextColour = false; + + @Expose + @ConfigOption( + name = "Custom Text Colour", + desc = "Requires the above option to be set to true", + searchTags = "color" + ) + @ConfigEditorColour + @ConfigAccordionId(id = 1) + public String customTextColour = "0:255:144:144:144"; + + @Expose + @ConfigOption( name = "Scrollable Tooltips", desc = "Support for scrolling tooltips for users with small monitors\n" + "This will prevent the menu from scrolling while holding the key, allowing you to scroll tooltips" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index 47df3c6e..8a48dd2c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -19,13 +19,13 @@ package io.github.moulberry.notenoughupdates.profileviewer; -import com.google.common.base.Splitter; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage; import io.github.moulberry.notenoughupdates.profileviewer.weight.lily.LilyWeight; import io.github.moulberry.notenoughupdates.profileviewer.weight.senither.SenitherWeight; import io.github.moulberry.notenoughupdates.util.Constants; @@ -53,11 +53,12 @@ import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; import java.awt.*; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -72,6 +73,34 @@ import static io.github.moulberry.notenoughupdates.util.Utils.roundToNearestInt; public class BasicPage extends GuiProfileViewerPage { private static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png"); + + public static final ItemStack skull = Utils.createSkull( + "egirlefe", + "152de44a-43a3-46e1-badc-66cca2793471", + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODdkODg1YjMyYjBkZDJkNmI3ZjFiNTgyYTM0MTg2ZjhhNTM3M2M0NjU4OWEyNzM0MjMxMzJiNDQ4YjgwMzQ2MiJ9fX0=" + ); + + private static final LinkedHashMap<String, ItemStack> dungeonsModeIcons = new LinkedHashMap<String, ItemStack>() { + { + put( + "first_page", + Utils.editItemStackInfo( + new ItemStack(Items.paper), + EnumChatFormatting.GRAY + "Front Page", + true + ) + ); + put( + "second_page", + Utils.editItemStackInfo( + skull, + EnumChatFormatting.GRAY + "Level Page", + true + ) + ); + } + }; + private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1); public EntityOtherPlayerMP entityPlayer = null; private ResourceLocation playerLocationSkin = null; @@ -88,9 +117,14 @@ public class BasicPage extends GuiProfileViewerPage { private int backgroundClickedX = -1; + private boolean onSecondPage; + + private final LevelPage levelPage; + public BasicPage(GuiProfileViewer instance) { super(instance); this.guiProfileViewer = instance; + this.levelPage = new LevelPage(guiProfileViewer, this); } @Override @@ -101,6 +135,11 @@ public class BasicPage extends GuiProfileViewerPage { int guiLeft = GuiProfileViewer.getGuiLeft(); int guiTop = GuiProfileViewer.getGuiTop(); + if (onSecondPage) { + levelPage.drawPage(mouseX, mouseY); + return; + } + String location = null; JsonObject status = profile.getPlayerStatus(); if (status != null && status.has("mode")) { @@ -280,7 +319,7 @@ public class BasicPage extends GuiProfileViewerPage { EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format(networth), fr, - guiLeft + 63, + guiLeft + 165, guiTop + 38, true, 0 @@ -297,11 +336,10 @@ public class BasicPage extends GuiProfileViewerPage { ); String networthIRLMoney = GuiProfileViewer.numberFormat.format(Math.round( ((networthInCookies * 325) / 675) * 4.99)); - if ( - mouseX > guiLeft + 8 && - mouseX < guiLeft + 8 + fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth)) - ) { - if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + fr.FONT_HEIGHT) { + + int fontWidth = fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth)); + if (mouseX > guiLeft + 165 - fontWidth / 2 && mouseX < guiLeft + 165 + fontWidth / 2) { + if (mouseY > guiTop + 32 && mouseY < guiTop + 38 + fr.FONT_HEIGHT) { getInstance().tooltipToDisplay = new ArrayList<>(); getInstance() |
