diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2023-05-31 13:06:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-31 13:06:27 +0200 |
| commit | 744e7692843c65049e45f666973e1e37adcc7e9a (patch) | |
| tree | ba31e4ff5a685f74455102209e1b127ed520cc9f /src/main/java/io | |
| parent | b40c37b653ba43d9603c578c440092c9f464935f (diff) | |
| download | NotEnoughUpdates-744e7692843c65049e45f666973e1e37adcc7e9a.tar.gz NotEnoughUpdates-744e7692843c65049e45f666973e1e37adcc7e9a.tar.bz2 NotEnoughUpdates-744e7692843c65049e45f666973e1e37adcc7e9a.zip | |
Removing the neu AH (#627)
* Removed the neu ah.
* make compile
* make command say its removed
* just what i wanted, an empty file
---------
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main/java/io')
10 files changed, 29 insertions, 2977 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 000158a4..c6f0785d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -23,7 +23,6 @@ import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; @@ -1567,9 +1566,6 @@ public class NEUOverlay extends Gui { public float getWidthMult() { float scaleFMult = 1; if (Utils.peekGuiScale().getScaleFactor() == 4) scaleFMult *= 0.9f; - if (manager.auctionManager.customAH.isRenderOverAuctionView() || - Minecraft.getMinecraft().currentScreen instanceof CustomAHGui) - scaleFMult *= 0.8f; return (float) Math.max(0.5, Math.min(1.5, NotEnoughUpdates.INSTANCE.config.itemlist.paneWidthMult)) * scaleFMult; } 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 1faac488..58d8c23b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -19,59 +19,29 @@ package io.github.moulberry.notenoughupdates.auction; -import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.ItemPriceInformation; import io.github.moulberry.notenoughupdates.NEUManager; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.pricegraph.LocalGraphDataProvider; import io.github.moulberry.notenoughupdates.recipes.Ingredient; import io.github.moulberry.notenoughupdates.recipes.ItemShopRecipe; import io.github.moulberry.notenoughupdates.recipes.NeuRecipe; -import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.event.ClickEvent; -import net.minecraft.event.HoverEvent; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.Base64; -import java.util.ConcurrentModificationException; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; public class APIManager { private final NEUManager manager; - public final CustomAH customAH; - private final TreeMap<String, Auction> auctionMap = new TreeMap<>(); - public HashMap<String, HashSet<String>> internalnameToAucIdMap = new HashMap<>(); - private final HashSet<String> playerBids = new HashSet<>(); - private final HashSet<String> playerBidsNotified = new HashSet<>(); - private final HashSet<String> playerBidsFinishedNotified = new HashSet<>(); private final int LOWEST_BIN_UPDATE_INTERVAL = 2 * 60 * 1000; // 2 minutes private final int AUCTION_AVG_UPDATE_INTERVAL = 5 * 60 * 1000; // 5 minutes private final int BAZAAR_UPDATE_INTERVAL = 5 * 60 * 1000; // 5 minutes @@ -79,165 +49,21 @@ public class APIManager { private JsonObject lowestBins = null; private JsonObject auctionPricesAvgLowestBinJson = null; - private LinkedList<Integer> pagesToDownload = null; - private JsonObject bazaarJson = null; private JsonObject auctionPricesJson = null; private final HashMap<String, CraftInfo> craftCost = new HashMap<>(); - public TreeMap<String, HashMap<Integer, HashSet<String>>> extrasToAucIdMap = new TreeMap<>(); - private boolean didFirstUpdate = false; - private long lastAuctionUpdate = 0; - private long lastShortAuctionUpdate = 0; - private long lastCustomAHSearch = 0; - private long lastCleanup = 0; private long lastAuctionAvgUpdate = 0; private long lastBazaarUpdate = 0; private long lastLowestBinUpdate = 0; - private long lastApiUpdate = 0; - private long firstHypixelApiUpdate = 0; - - public int activeAuctions = 0; - public int uniqueItems = 0; - public int totalTags = 0; - public int internalnameTaggedAuctions = 0; - public int taggedAuctions = 0; - public int processMillis = 0; - public APIManager(NEUManager manager) { this.manager = manager; - customAH = new CustomAH(manager); - } - - public TreeMap<String, Auction> getAuctionItems() { - return auctionMap; - } - - public HashSet<String> getPlayerBids() { - return playerBids; - } - - public HashSet<String> getAuctionsForInternalname(String internalname) { - return internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()); - } - - public class Auction { - public String auctioneerUuid; - public long end; - public long starting_bid; - public int highest_bid_amount; - public int bid_count; - public boolean bin; - public String category; - public String rarity; - public int dungeonTier; - public String item_tag_str; - public NBTTagCompound item_tag = null; - private ItemStack stack; - - public int enchLevel = 0; //0 = clean, 1 = ench, 2 = ench/hpb - - public Auction( - String auctioneerUuid, long end, long starting_bid, int highest_bid_amount, int bid_count, - boolean bin, String category, String rarity, int dungeonTier, String item_tag_str - ) { - this.auctioneerUuid = auctioneerUuid; - this.end = end; - this.starting_bid = starting_bid; - this.highest_bid_amount = highest_bid_amount; - this.bid_count = bid_count; - this.bin = bin; - this.category = category; - this.dungeonTier = dungeonTier; - this.rarity = rarity; - this.item_tag_str = item_tag_str; - } - - public ItemStack getStack() { - if (item_tag == null && item_tag_str != null) { - try { - item_tag = CompressedStreamTools.readCompressed( - new ByteArrayInputStream(Base64.getDecoder().decode(item_tag_str))); - item_tag_str = null; - } catch (IOException e) { - return null; - } - } - if (stack != null) { - return stack; - } else { - JsonObject item = manager.getJsonFromNBT(item_tag); - if (item == null) return null; - ItemStack stack = manager.jsonToStack(item, false); - - JsonObject itemDefault = manager.getItemInformation().get(item.get("internalname").getAsString()); - - if (stack != null && itemDefault != null) { - ItemStack stackDefault = manager.jsonToStack(itemDefault, true); - if (stack.isItemEqual(stackDefault)) { - //Item types are the same, compare lore - - String[] stackLore = manager.getLoreFromNBT(stack.getTagCompound()); - String[] defaultLore = manager.getLoreFromNBT(stackDefault.getTagCompound()); - - boolean loreMatches = stackLore != null && defaultLore != null && stackLore.length == defaultLore.length; - if (loreMatches) { - for (int i = 0; i < stackLore.length; i++) { - if (!stackLore[i].equals(defaultLore[i])) { - loreMatches = false; - break; - } - } - } - if (loreMatches) { - stack = stackDefault; - } - } - } - this.stack = stack; - return stack; - } - } - } - - public void markNeedsUpdate() { - firstHypixelApiUpdate = 0; - pagesToDownload = null; - - auctionMap.clear(); - internalnameToAucIdMap.clear(); - extrasToAucIdMap.clear(); } public void tick() { - customAH.tick(); long currentTime = System.currentTimeMillis(); - if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse && - NotEnoughUpdates.INSTANCE.config.apiData.apiKey != null && - !NotEnoughUpdates.INSTANCE.config.apiData.apiKey.isEmpty()) { - if (currentTime - lastAuctionUpdate > 60 * 1000) { - lastAuctionUpdate = currentTime; - updatePageTick(); - } - if (currentTime - lastShortAuctionUpdate > 10 * 1000) { - lastShortAuctionUpdate = currentTime; - updatePageTickShort(); - ahNotification(); - } - if (currentTime - lastCleanup > 60 * 1000) { - lastCleanup = currentTime; - cleanup(); - } - if (currentTime - lastCustomAHSearch > 60 * 1000) { - lastCustomAHSearch = currentTime; - if (Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) { - customAH.updateSearch(); - calculateStats(); - } - } - } if (currentTime - lastAuctionAvgUpdate > AUCTION_AVG_UPDATE_INTERVAL) { lastAuctionAvgUpdate = currentTime - AUCTION_AVG_UPDATE_INTERVAL + 60 * 1000; // Try again in 1 minute on failure updateAvgPrices(); @@ -252,22 +78,6 @@ public class APIManager { } } - private String niceAucId(String aucId) { - if (aucId.length() != 32) return aucId; - - StringBuilder niceAucId = new StringBuilder(); - niceAucId.append(aucId, 0, 8); - niceAucId.append("-"); - niceAucId.append(aucId, 8, 12); - niceAucId.append("-"); - niceAucId.append(aucId, 12, 16); - niceAucId.append("-"); - niceAucId.append(aucId, 16, 20); - niceAucId.append("-"); - niceAucId.append(aucId, 20, 32); - return niceAucId.toString(); - } - public Set<String> getLowestBinKeySet() { if (lowestBins == null) return new HashSet<>(); HashSet<String> keys = new HashSet<>(); @@ -310,415 +120,10 @@ public class APIManager { }); } - private void ahNotification() { - playerBidsNotified.retainAll(playerBids); - playerBidsFinishedNotified.retainAll(playerBids); - if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification <= 0) { - return; - } - for (String aucid : playerBids) { - Auction auc = auctionMap.get(aucid); - if (!playerBidsNotified.contains(aucid)) { - if (auc != null && - auc.end - System.currentTimeMillis() < - 1000 * 60 * NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification) { - ChatComponentText message = new ChatComponentText( - EnumChatFormatting.YELLOW + - "The " + - auc.getStack().getDisplayName() + - EnumChatFormatting.YELLOW + - " you have bid on is ending soon! Click here to view."); - ChatStyle clickEvent = new ChatStyle().setChatClickEvent( - new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/viewauction " + niceAucId(aucid))); - clickEvent.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText( - EnumChatFormatting.YELLOW + - "View auction"))); - message.setChatStyle(clickEvent); - Minecraft.getMinecraft().thePlayer.addChatMessage(message); - - playerBidsNotified.add(aucid); - } - } - if (!playerBidsFinishedNotified.contains(aucid)) { - if (auc != null && auc.end < System.currentTimeMillis()) { - ChatComponentText message = new ChatComponentText( - EnumChatFormatting.YELLOW + - "The " + - auc.getStack().getDisplayName() + - EnumChatFormatting.YELLOW + - " you have bid on (might) have ended! Click here to view."); - ChatStyle clickEvent = new ChatStyle().setChatClickEvent( - new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/viewauction " + niceAucId(aucid))); - clickEvent.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText( - EnumChatFormatting.YELLOW + - "View auction"))); - message.setChatStyle(clickEvent); - Minecraft.getMinecraft().thePlayer.addChatMessage(message); - - playerBidsFinishedNotified.add(aucid); - } - } - } - } - public long getLastLowestBinUpdateTime() { return lastLowestBinUpdate; } - private final ExecutorService es = Executors.newSingleThreadExecutor(); - - private void cleanup() { - es.submit(() -> { - try { - long currTime = System.currentTimeMillis(); - Set<String> toRemove = new HashSet<>(); - for (Map.Entry<String, Auction> entry : auctionMap.entrySet()) { - long timeToEnd = entry.getValue().end - currTime; - if (timeToEnd < -120 * 1000) { //2 minutes - toRemove.add(entry.getKey()); - } - } - toRemove.removeAll(playerBids); - remove(toRemove); - } catch (ConcurrentModificationException e) { - lastCleanup = System.currentTimeMillis() - 110 * 1000; - } - }); - } - - private void remove(Set<String> toRemove) { - for (String aucid : toRemove) { - auctionMap.remove(aucid); - } - for (HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) { - for (HashSet<String> aucids : extrasMap.values()) { - for (String aucid : toRemove) { - aucids.remove(aucid); - } - } - } - for (HashSet<String> aucids : internalnameToAucIdMap.values()) { - aucids.removeAll(toRemove); - } - } - - private void updatePageTickShort() { - if (pagesToDownload == null || pagesToDownload.isEmpty()) return; - - if (firstHypixelApiUpdate == 0 || (System.currentTimeMillis() - firstHypixelApiUpdate) % (60 * 1000) > 15 * 1000) - return; - - JsonObject disable = Constants.DISABLE; - if (disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return; - - while (!pagesToDownload.isEmpty()) { - try { - int page = pagesToDownload.pop(); - getPageFromAPI(page); - } catch (NoSuchElementException ignored) { - return; - } //Weird race condition? - } - } - - private void updatePageTick() { - JsonObject disable = Constants.DISABLE; - if (disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return; - - if (pagesToDownload == null) { - getPageFromAPI(0); - } - - Consumer<JsonObject> process = jsonObject -> { - if (jsonObject.get("success").getAsBoolean()) { - JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray(); - for (JsonElement auctionElement : new_auctions) { - JsonObject auction = auctionElement.getAsJsonObject(); - //System.out.println("New auction " + auction); - processAuction(auction); - } - JsonArray new_bids = jsonObject.get("new_bids").getAsJsonArray(); - for (JsonElement newBidElement : new_bids) { - JsonObject newBid = newBidElement.getAsJsonObject(); - String newBidUUID = newBid.get("uuid").getAsString(); - //System.out.println("new bid" + newBidUUID); - int newBidAmount = newBid.get("highest_bid_amount").getAsInt(); - int end = newBid.get("end").getAsInt(); - int bid_count = newBid.get("bid_count").getAsInt(); - - Auction auc = auctionMap.get(newBidUUID); - if (auc != null) { - //System.out.println("Setting auction " + newBidUUID + " price to " + newBidAmount); - auc.highest_bid_amount = newBidAmount; - auc.end = end; - auc.bid_count = bid_count; - } - } - Set<String> toRemove = new HashSet<>(); - JsonArray removed_auctions = jsonObject.get("removed_auctions").getAsJsonArray(); - for (JsonElement removedAuctionsElement : removed_auctions) { - String removed = removedAuctionsElement.getAsString(); - toRemove.add(removed); - } - remove(toRemove); - } - }; - - manager.apiUtils.newMoulberryRequest("auctionLast.json.gz") - .gunzip().requestJson().thenAcceptAsync(process); - - manager.apiUtils - .newMoulberryRequest("auction.json.gz") - .gunzip().requestJson() - .thenAcceptAsync(jsonObject -> { - if (jsonObject.get("success").getAsBoolean()) { - long apiUpdate = (long) jsonObject.get("time").getAsFloat(); - if (lastApiUpdate == apiUpdate) { - lastAuctionUpdate -= 30 * 1000; - } - lastApiUpdate = apiUpdate; - - process.accept(jsonObject); - } - }); - - } - - public void calculateStats() { - try { - uniqueItems = internalnameToAucIdMap.size(); - Set<String> aucs = new HashSet<>(); - for (HashSet<String> aucids : internalnameToAucIdMap.values()) { - aucs.addAll(aucids); - } - internalnameTaggedAuctions = aucs.size(); - totalTags = extrasToAucIdMap.size(); - aucs = new HashSet<>(); - for (HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) { - for (HashSet<String> aucids : extrasMap.values()) { - aucs.addAll(aucids); - } - } - taggedAuctions = aucs.size(); - } catch (Exception ignored) { - } - } - - //String[] rarityArr = new String[] { - // "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME", - //}; - - public int checkItemType(String lore, boolean contains, String... typeMatches) { - String[] split = lore.split("\n"); - for (int i = split.length - 1; i >= 0; i--) { - String line = split[i]; - for (String rarity : Utils.rarityArr) { - for (int j = 0; j < typeMatches.length; j++) { - if (contains) { - if (line.trim().contains(rarity + " " + typeMatches[j])) { - return j; - } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) { - return j; - } - } else { - if (line.trim().endsWith(rarity + " " + typeMatches[j])) { - return j; - } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) { - return j; - } - } - } - } - } - return -1; - } - - private final String[] romans = new String[]{ - "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", - "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XIX", "XX" - }; - - String[] categoryItemType = new String[]{ - "sword", "fishingrod", "pickaxe", "axe", - "shovel", "petitem", "travelscroll", "reforgestone", "bow" - }; - String playerUUID = null; - - private void processAuction(JsonObject auction) { - if (playerUUID == null) - playerUUID = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replaceAll("-", ""); - - String auctionUuid = auction.get("uuid").getAsString(); - String auctioneerUuid = auction.get("auctioneer").getAsString(); - long end = auction.get("end").getAsLong(); - long starting_bid = auction.get("starting_bid").getAsLong(); - int highest_bid_amount = auction.get("highest_bid_amount").getAsInt(); - int bid_count = auction.get("bids").getAsJsonArray().size(); - boolean bin = false; - if (auction.has("bin")) { - bin = auction.get("bin").getAsBoolean(); - } - String sbCategory = auction.get("category").getAsString(); - String extras = auction.get("extra").getAsString().toLowerCase(); - String item_name = auction.get("item_name").getAsString(); - String item_lore = Utils.fixBrokenAPIColour(auction.get("item_lore").getAsString()); - String item_bytes = auction.get("item_bytes").getAsString(); - String rarity = auction.get("tier").getAsString(); - JsonArray bids = auction.get("bids").getAsJsonArray(); - - try { - NBTTagCompound item_tag; - try { - item_tag = CompressedStreamTools.readCompressed( - new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes))); - } catch (IOException e) { - return; - } - - NBTTagCompound tag = item_tag.getTagList("i", 10).getCompoundTagAt(0).getCompoundTag("tag"); - String internalname = manager.getInternalnameFromNBT(tag); - - NBTTagCompound display = tag.getCompoundTag("display"); - if (display.hasKey("Lore", 9)) { - NBTTagList loreList = new NBTTagList(); - for (String line : item_lore.split("\n")) { - loreList.appendTag(new NBTTagString(line)); - } - display.setTag("Lore", loreList); - } - tag.setTag("display", display); - item_tag.getTagList("i", 10).getCompoundTagAt(0).setTag("tag", tag); - - if (tag.hasKey("ExtraAttributes", 10)) { - NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - - if (ea.hasKey("enchantments", 10)) { - NBTTagCompound enchantments = ea.getCompoundTag("enchantments"); - for (String key : enchantments.getKeySet()) { - String enchantname = key.toLowerCase().replace("ultimate_", "").replace("_", " "); - int enchantlevel = enchantments.getInteger(key); - String enchantLevelStr; - if (enchantlevel >= 1 && enchantlevel <= 20) { - enchantLevelStr = romans[enchantlevel - 1]; - } else { - enchantLevelStr = String.valueOf(enchantlevel); - } - extras = extras.replace(enchantname, enchantname + " " + enchantLevelStr); - } - } - } - - int index = 0; - for (String str : extras.split(" ")) { - str = Utils.cleanColour(str).toLowerCase(); - if (str.length() > 0) { - HashMap<Integer, HashSet<String>> extrasMap = extrasToAucIdMap.computeIfAbsent(str, k -> new HashMap<>()); - HashSet<String> aucids = extrasMap.computeIfAbsent(index, k -> new HashSet<>()); - aucids.add(auctionUuid); - } - index++; - } - - for (int j = 0; j < bids.size(); j++) { - JsonObject bid = bids.get(j).getAsJsonObject(); - if (bid.get("bidder").getAsString().equalsIgnoreCase(playerUUID)) { - playerBids.add(auctionUuid); - } - } - - int dungeonTier = -1; - if (checkItemType(item_lore, true, "DUNGEON") >= 0) { - dungeonTier = 0; - for (int i = 0; i < item_name.length(); i++) { - char c = item_name.charAt(i); - if (c == 0x272A) { - dungeonTier++; - } - } - } - - //Categories - String category = sbCategory; - int itemType = checkItemType(item_lore, true, "SWORD", "FISHING ROD", "PICKAXE", - "AXE", "SHOVEL", "PET ITEM", "TRAVEL SCROLL", "REFORGE STONE", "BOW" - ); - if (itemType >= 0 && itemType < categoryItemType.length) { - category = categoryItemType[itemType]; - } - if (category.equals("consumables") && extras.contains("enchanted book")) category = "ebook"; - if (category.equals("consumables") && extras.endsWith("potion")) category = "potion"; - if (category.equals("misc") && extras.contains("rune")) category = "rune"; - if (category.equals("misc") && item_lore.split("\n")[0].endsWith("Furniture")) category = "furniture"; - if (item_lore.split("\n")[0].endsWith("Pet") || - item_lore.split("\n")[0].endsWith("Mount")) category = "pet"; - - Auction auction1 = new Auction(auctioneerUuid, end, starting_bid, highest_bid_amount, - bid_count, bin, category, rarity, dungeonTier, item_bytes - ); - - if (tag.hasKey("ench")) { - auction1.enchLevel = 1; - if (tag.hasKey("ExtraAttributes", 10)) { - NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - - int hotpotatocount = ea.getInteger("hot_potato_count"); - if (hotpotatocount == 10) { - auction1.enchLevel = 2; - } - } - } - - auctionMap.put(auctionUuid, auction1); - internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()).add(auctionUuid); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void getPageFromAPI(int page) { - //System.out.println("downloading page:"+page); - //System.out.println("Trying to update page: " + page); - HashMap<String, String> args = new HashMap<>(); - args.put("page", "" + page); - manager.apiUtils - .newAnonymousHypixelApiRequest("skyblock/auctions") - .requestJson() - .thenAcceptAsync(jsonObject -> { - if (jsonObject == null) return; - - if (jsonObject.get("success").getAsBoolean()) { - if (pagesToDownload == null) { - int totalPages = jsonObject.get("totalPages").getAsInt(); - pagesToDownload = new LinkedList<>(); - for (int i = 0; i < totalPages + 2; i++) { - pagesToDownload.add(i); - } - } - if (firstHypixelApiUpdate == 0) { - firstHypixelApiUpdate = jsonObject.get("lastUpdated").getAsLong(); - } - activeAuctions = jsonObject.get("totalAuctions").getAsInt(); - - long startProcess = System.currentTimeMillis(); - JsonArray auctions = jsonObject.get("auctions").getAsJsonArray(); - for (int i = 0; i < auctions.size(); i++) { - JsonObject auction = auctions.get(i).getAsJsonObject(); - - processAuction(auction); - } - processMillis = (int) (System.currentTimeMillis() - startProcess); - } else { - pagesToDownload.addLast(page); - } - }) - .handle((ignored, ex) -> { - if (ex != null) { - pagesToDownload.addLast(page); - } - return null; - }); - } - private static final Pattern BAZAAR_ENCHANTMENT_PATTERN = Pattern.compile("ENCHANTMENT_(\\D*)_(\\d+)"); public String transformHypixelBazaarToNEUItemId(String hypixelId) { @@ -872,11 +277,11 @@ public class APIManager { "ROOKIE_HOE" ); - public boolean isVanillaItem(String internalname) { - if (hardcodedVanillaItems.contains(internalname)) return true; + public boolean isVanillaItem(String internalName) { + if (hardcodedVanillaItems.contains(internalName)) return true; //Removes trailing numbers and underscores, eg. LEAVES_2-3 -> LEAVES - String vanillaName = internalname.split("-")[0]; + String vanillaName = internalName.split("-")[0]; if (manager.getItemInformation().containsKey(vanillaName)) { JsonObject json = manager.getItemInformation().get(vanillaName); if (json != null && json.has("vanilla") && json.get("vanilla").getAsBoolean()) return true; @@ -890,24 +295,24 @@ public class APIManager { public double craftCost = -1; } - public CraftInfo getCraftCost(String internalname) { - return getCraftCost(internalname, new HashSet<>()); + public CraftInfo getCraftCost(String internalName) { + return getCraftCost(internalName, new HashSet<>()); } /** * Recursively calculates the cost of crafting an item from raw materials. */ - private CraftInfo getCraftCost(String internalname, Set<String> visited) { - if (craftCost.containsKey(internalname)) return craftCost.get(internalname); - if (visited.contains(internalname)) return null; - visited.add(internalname); + private CraftInfo getCraftCost(String internalName, Set<String> visited) { + if (craftCost.containsKey(internalName)) return craftCost.get(internalName); + if (visited.contains(internalName)) return null; + visited.add(internalName); - boolean vanillaItem = isVanillaItem(internalname); + boolean vanillaItem = isVanillaItem(internalName); double craftCost = Double.POSITIVE_INFINITY; - JsonObject auctionInfo = getItemAuctionInfo(internalname); - double lowestBin = getLowestBin(internalname); - JsonObject bazaarInfo = getBazaarInfo(internalname); + JsonObject auctionInfo = getItemAuctionInfo(internalName); + double lowestBin = getLowestBin(internalName); + JsonObject bazaarInfo = getBazaarInfo(internalName); if (bazaarInfo != null && bazaarInfo.get("curr_buy") != null) { craftCost = bazaarInfo.get("curr_buy").getAsFloat(); @@ -922,7 +327,7 @@ public class APIManager { } } - Set<NeuRecipe> recipes = manager.getRecipesFor(internalname); + Set<NeuRecipe> recipes = manager.getRecipesFor(internalName); boolean fromRecipe = false; if (recipes != null) RECIPE_ITER: @@ -946,7 +351,7 @@ public class APIManager { } int resultCount = 0; for (Ingredient item : recipe.getOutputs()) - if (item.getInternalItemId().equals(internalname)) + if (item.getInternalItemId().equals(internalName)) resultCount += item.getCount(); if (resultCount == 0) @@ -957,7 +362,7 @@ public class APIManager { craftCost = craftPricePer; } } - visited.remove(internalname); + visited.remove(internalName); if (Double.isInfinite(craftCost)) { return null; } @@ -965,168 +370,7 @@ public class APIManager { craftInfo.vanillaItem = vanillaItem; craftInfo.craftCost = craftCost; craftInfo.fromRecipe = fromRecipe; - this.craftCost.put(internalname, craftInfo); + this.craftCost.put(internalName, craftInfo); return craftInfo; } - - /** - * Calculates the cost of enchants + other price modifiers such as pet xp, midas price, etc. - */ - public float getCostOfEnchants(String internalname, NBTTagCompound tag) { - float costOfEnchants = 0; - if (true) return 0; - - JsonObject info = getItemAuctionInfo(internalname); - if (info == null || !info.has("price")) { - return 0; - } - if (auctionPricesJson == null || !auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) { - return 0; - } - JsonObject ench_prices = auctionPricesJson.getAsJsonObject("ench_prices"); - JsonObject ench_maximums = auctionPricesJson.getAsJsonObject("ench_maximums"); - if (!ench_prices.has(internalname) || !ench_maximums.has(internalname)) { - return 0; - } - JsonObject iid_variables = ench_prices.getAsJsonObject(internalname); - float ench_max |
