diff options
| author | kr45732 <52721908+kr45732@users.noreply.github.com> | 2023-06-08 10:00:04 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-08 16:00:04 +0200 |
| commit | 8115922b37e375285c2a72dbdbb5d83fd942e27c (patch) | |
| tree | e0d6cb5228493e8bb032465cbb2dfd95b4946e43 /src | |
| parent | a6fb7bfb97d313b665085a52a660150f1da26065 (diff) | |
| download | NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.gz NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.bz2 NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.zip | |
PV Overhaul (#708)
Co-authored-by: Lulonaut <lulonaut@tutanota.de>
Diffstat (limited to 'src')
51 files changed, 1922 insertions, 2533 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index a5bea05d..6b68fccf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -39,7 +39,6 @@ import io.github.moulberry.notenoughupdates.util.ApiUtil; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; import io.github.moulberry.notenoughupdates.util.ItemUtils; -import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; @@ -49,7 +48,6 @@ import net.minecraft.inventory.ContainerChest; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTException; import net.minecraft.nbt.NBTTagCompound; @@ -63,7 +61,6 @@ import javax.net.ssl.HttpsURLConnection; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -143,7 +140,6 @@ public class NEUManager { public File configLocation; public File repoLocation; - public File configFile; public KatSitterOverlay katSitterOverlay; @@ -162,24 +158,6 @@ public class NEUManager { repoLocation.mkdir(); } - public String getCurrentProfile() { - return SBInfo.getInstance().currentProfile; - } - - public <T> T getJsonFromFile(File file, Class<T> clazz) { - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader( - new FileInputStream(file), - StandardCharsets.UTF_8 - )) - ) { - T obj = gson.fromJson(reader, clazz); - return obj; - } catch (Exception e) { - return null; - } - } - /** * Parses a file in to a JsonObject. */ @@ -738,17 +716,6 @@ public class NEUManager { return inputWithoutLastChar + incrementedLastChar; } - public JsonObject getJsonFromItemBytes(String item_bytes) { - try { - NBTTagCompound tag = - CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes))); - //System.out.println(tag.toString()); - return getJsonFromNBT(tag); - } catch (IOException e) { - return null; - } - } - public static String getUUIDFromNBT(NBTTagCompound tag) { String uuid = null; if (tag != null && tag.hasKey("ExtraAttributes", 10)) { @@ -778,16 +745,6 @@ public class NEUManager { return null; } - /** - * Replaced with {@link #createItemResolutionQuery()} - */ - @Deprecated - public String getInternalnameFromNBT(NBTTagCompound tag) { - return createItemResolutionQuery() - .withItemNBT(tag) - .resolveInternalName(); - } - public String[] getLoreFromNBT(NBTTagCompound tag) { return ItemUtils.getLore(tag).toArray(new String[0]); } @@ -806,7 +763,9 @@ public class NEUManager { if (id == 141) id = 391; //for some reason hypixel thinks carrots have id 141 - String internalname = getInternalnameFromNBT(tag); + String internalname = createItemResolutionQuery() + .withItemNBT(tag) + .resolveInternalName(); if (internalname == null) return null; NBTTagCompound display = tag.getCompoundTag("display"); @@ -818,8 +777,6 @@ public class NEUManager { itemid = itemMc.getRegistryName(); } String displayName = display.getString("Name"); - String[] info = new String[0]; - String clickcommand = ""; JsonObject item = new JsonObject(); item.addProperty("internalname", internalname); @@ -1232,25 +1189,6 @@ public class NEUManager { } public boolean writeItemJson( - String internalname, String itemid, String displayName, String[] lore, String crafttext, - String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag - ) { - return writeItemJson( - new JsonObject(), - internalname, - itemid, - displayName, - lore, - crafttext, - infoType, - info, - clickcommand, - damage, - nbttag - ); - } - - public boolean writeItemJson( JsonObject base, String internalname, String itemid, String displayName, String[] lore, String crafttext, String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag ) { 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 ec50633f..e59a6a14 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 @@ -19,18 +19,14 @@ package io.github.moulberry.notenoughupdates.core.util; -import com.google.common.collect.Sets; -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; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Locale; public class StringUtils { - public static final Set<String> PROTOCOLS = Sets.newHashSet("http", "https"); + private final static DecimalFormat TENTHS_DECIMAL_FORMAT = new DecimalFormat("#.#"); + public static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(Locale.US); public static String cleanColour(String in) { return in.replaceAll("(?i)\\u00A7.", ""); @@ -40,24 +36,6 @@ public class StringUtils { return in.replaceAll("(?i)\\u00A7[0-9a-f]", "\u00A7r"); } - public static String trimToWidth(String str, int len) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - String trim = fr.trimStringToWidth(str, len); - - if (str.length() != trim.length() && !trim.endsWith(" ")) { - char next = str.charAt(trim.length()); - if (next != ' ') { - String[] split = trim.split(" "); - String last = split[split.length - 1]; - if (last.length() < 8) { - trim = trim.substring(0, trim.length() - last.length()); - } - } - } - - return trim; - } - public static String substringBetween(String str, String open, String close) { return org.apache.commons.lang3.StringUtils.substringBetween(str, open, close); } @@ -99,22 +77,6 @@ public class StringUtils { return d < 1000 ? (isRound || d > 9.99 ? (int) d * 10 / 10 : d + "") + "" + sizeSuffix[iteration] : shortNumberFormat(d, iteration + 1); } - public static String urlEncode(String something) { - try { - return URLEncoder.encode(something, StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); // UTF 8 should always be present - } - } - - /** - * taken and modified from https://stackoverflow.com/a/23326014/5507634 - */ - public static String replaceLast(String string, String toReplace, String replacement) { - int start = string.lastIndexOf(toReplace); - return string.substring(0, start) + replacement + string.substring(start + toReplace.length()); - } - public static String removeLastWord(String string, String splitString) { try { String[] split = string.split(splitString); @@ -143,4 +105,12 @@ public class StringUtils { } return true; } + + public static String formatToTenths(Number num) { + return TENTHS_DECIMAL_FORMAT.format(num); + } + + public static String formatNumber(Number num) { + return NUMBER_FORMAT.format(num); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java index cacae83b..3dbd52a5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java @@ -49,11 +49,12 @@ import java.util.HashMap; import java.util.List; import java.util.Random; +import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_bg; +import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_dropdown; +import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_elements; + public class GuiCosmetics extends GuiScreen { - public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png"); - public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png"); public static final ResourceLocation cosmetics_fg = new ResourceLocation("notenoughupdates:cosmetics_fg.png"); - public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png"); private final GuiElementTextField unlockTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); @@ -301,7 +302,6 @@ public class GuiCosmetics extends GuiScreen { } } - int index = 0; int displayingCapes = 0; for (CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) { boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || @@ -315,7 +315,6 @@ public class GuiCosmetics extends GuiScreen { float totalAvail = sizeX - 20; float xOffset = scroll * (totalNeeded - totalAvail); - index = 0; int displayIndex = 0; for (CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) { boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || @@ -447,7 +446,6 @@ public class GuiCosmetics extends GuiScreen { Minecraft.getMinecraft().displayWidth * (sizeX - 6) / width, Minecraft.getMinecraft().displayHeight ); - int index = 0; int displayingCapes = 0; for (CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) { boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || @@ -461,7 +459,6 @@ public class GuiCosmetics extends GuiScreen { float totalAvail = sizeX - 20; float xOffset = scroll * (totalNeeded - totalAvail); - index = 0; int displayIndex = 0; for (CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) { boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java index 1e3dd7e0..01a173d3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipListener.java @@ -30,7 +30,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.MiscUtils; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; -import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.PetLeveling; import io.github.moulberry.notenoughupdates.util.Utils; @@ -57,7 +56,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -164,7 +162,6 @@ public class ItemTooltipListener { for (int k = 0; k < event.toolTip.size(); k++) { String line = event.toolTip.get(k); - boolean thisLineHasEnchants = false; if (line.endsWith(EnumChatFormatting.DARK_GRAY + "Reforge Stone") && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showReforgeStats) { @@ -299,7 +296,7 @@ public class ItemTooltipListener { if (reforgeCost >= 0) { String text = EnumChatFormatting.BLUE + "Apply Cost: " + EnumChatFormatting.GOLD + - NumberFormat.getNumberInstance().format(reforgeCost) + " coins"; + StringUtils.formatNumber(reforgeCost) + " coins"; newTooltip.add(""); newTooltip.add(text); } @@ -495,12 +492,11 @@ public class ItemTooltipListener { } } - NumberFormat format = NumberFormat.getInstance(Locale.US); String valueStringBIN1; String valueStringBIN2; if (totalValue >= 0) { valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): "; - valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins"; + valueStringBIN2 = EnumChatFormatting.GOLD + StringUtils.formatNumber(totalValue) + " coins"; } else { valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: "; valueStringBIN2 = missingItem; @@ -513,9 +509,9 @@ public class ItemTooltipListener { String plStringBIN; if (profitLossBIN >= 0) { - plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins"; + plStringBIN = prefix + "+" + StringUtils.formatNumber(profitLossBIN) + " coins"; } else { - plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins"; + plStringBIN = prefix + "-" + StringUtils.formatNumber(-profitLossBIN) + " coins"; } String neu = EnumChatFormatting.YELLOW + "[NEU] "; @@ -526,7 +522,7 @@ public class ItemTooltipListener { } for (Map.Entry<String, Double> entry : itemValues.entrySet()) { - newTooltip.add(neu + entry.getKey() + prefix + "+" + format.format(entry.getValue().intValue())); + newTooltip.add(neu + entry.getKey() + prefix + "+" + StringUtils.formatNumber(entry.getValue().intValue())); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java index 06d294a3..10882b9b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/ItemTooltipRngListener.java +++ b/ |
