diff options
4 files changed, 56 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 912123e..a995110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,13 +14,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). 2) copy a single item to clipboard as JSON with <kbd>CTRL</kbd> + <kbd>SHIFT</kbd> + <kbd>C</kbd> - must be enabled in `/moo config > General > Copy inventories with CTRL + C` first - *reminder:* <kbd>CTRL</kbd> + <kbd>C</kbd> (without <kbd>SHIFT</kbd>) copies the whole inventory -- New config options: +- New config options for older features: - Output of `/moo waila` and copied inventory data can now also be saved to files, instead of being copied to clipboard - Bazaar: order 'Sell Inventory/Sacks Now' tooltips ascending or descending - MC Log file search (`/moo search`): maximum log file size to analyze - Toggle: display dungeon performance summary at the end of a dungeon - Toggle: send warning when queued and entered dungeon floors are different - Toggle: shorten item quality info for non-randomized items +- Bazaar: display items left on a buy order/sell order (toggleable) ### Changed - Disabled `M` keybinding in MC Options > Controls > Cowlection by default to avoid conflicts diff --git a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java index f636559..b26c19f 100644 --- a/src/main/java/de/cowtipper/cowlection/config/MooConfig.java +++ b/src/main/java/de/cowtipper/cowlection/config/MooConfig.java @@ -87,6 +87,7 @@ public class MooConfig { private static String auctionHouseMarkEndedAuctions; public static String bazaarSellAllOrder; public static String bazaarSellAllOrderAscDesc; + public static boolean bazaarShowItemsLeft; private static String bazaarConnectGraphsNodes; public static int bazaarConnectGraphsLineWidth; public static String bestiaryOverviewOrder; @@ -454,6 +455,9 @@ public class MooConfig { Property propBazaarSellAllOrderAscDesc = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), "bazaarSellAllOrderAscDesc", "low → high", "Bazaar: sell all order asc/desc", new String[]{"low → high", "high → low"})); + Property propBazaarShowItemsLeft = subCat.addConfigEntry(cfg.get(configCat.getConfigName(), + "bazaarShowItemsLeft", true, "Bazaar: show items left")); + MooConfigPreview bazaarGraphPreview = new MooConfigPreview(MooConfigPreview.createDemoItem("paper", "§aBuy Price §731d §77d §e24h", new String[]{ "§7The price at which buy orders have been filled.", "", "§r┌----------------------------------------------┐", "§r│§66. 1k§r+§bxxxxxx§8·································§bxx§r│", @@ -689,6 +693,7 @@ public class MooConfig { auctionHouseMarkEndedAuctions = propAuctionHouseMarkEndedAuctions.getString(); bazaarSellAllOrder = propBazaarSellAllOrder.getString(); bazaarSellAllOrderAscDesc = propBazaarSellAllOrderAscDesc.getString(); + bazaarShowItemsLeft = propBazaarShowItemsLeft.getBoolean(); bazaarConnectGraphsNodes = propBazaarConnectGraphsNodes.getString(); bazaarConnectGraphsLineWidth = propBazaarConnectGraphsLineWidth.getInt(); bestiaryOverviewOrder = propBestiaryOverviewOrder.getString(); @@ -777,6 +782,7 @@ public class MooConfig { propAuctionHouseMarkEndedAuctions.set(auctionHouseMarkEndedAuctions); propBazaarSellAllOrder.set(bazaarSellAllOrder); propBazaarSellAllOrderAscDesc.set(bazaarSellAllOrderAscDesc); + propBazaarShowItemsLeft.set(bazaarShowItemsLeft); propBazaarConnectGraphsNodes.set(bazaarConnectGraphsNodes); propBazaarConnectGraphsLineWidth.set(bazaarConnectGraphsLineWidth); propBestiaryOverviewOrder.set(bestiaryOverviewOrder); diff --git a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java index 432489b..80fe155 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java @@ -72,6 +72,8 @@ public class SkyBlockListener { private static final Pattern TIER_SUFFIX_PATTERN = Pattern.compile(" [IVX0-9]+$"); // example: " §a42§7x §fLeather §7for §6436.8 coins" private static final Pattern BAZAAR_SELL_ALL_PATTERN = Pattern.compile("^(?:§[0-9a-fl-or])* (?:§[0-9a-fl-or])+([0-9,]+)(?:§[0-9a-fl-or])+x (?:§[0-9a-fl-or])+.+ (?:§[0-9a-fl-or])+for (?:§[0-9a-fl-or])+([0-9,.]+) coins$"); + private static final Pattern BAZAAR_TARGET_AMOUNT_PATTERN = Pattern.compile("^O(?:ff|rd)er amount: ([\\d,]+)x$"); + private static final Pattern BAZAAR_FILLED_PATTERN = Pattern.compile("^Filled: ([\\d,k]+)/(?:[\\d,k]+) \\(?([\\d.]+)%[)!]$"); List<BestiaryEntry> bestiaryOverview = null; private final NumberFormat numberFormatter; private final Cowlection main; @@ -422,7 +424,7 @@ public class SkyBlockListener { List<String> toolTip = e.toolTip; int startIndex = 1337; Ordering<Double> tooltipOrdering = Ordering.natural(); - if("high → low".equals(MooConfig.bazaarSellAllOrderAscDesc)) { + if ("high → low".equals(MooConfig.bazaarSellAllOrderAscDesc)) { tooltipOrdering = tooltipOrdering.reverse(); } TreeMultimap<Double, String> sellEntries = TreeMultimap.create(tooltipOrdering, Ordering.natural()); @@ -473,6 +475,49 @@ public class SkyBlockListener { } } + // bazaar: show how many items left on offer/order + if (MooConfig.bazaarShowItemsLeft) { + String displayName = e.itemStack.getDisplayName(); + if (displayName.startsWith("" + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + "SELL" + EnumChatFormatting.GRAY + ":") + || displayName.startsWith("" + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + "BUY" + EnumChatFormatting.GRAY + ":")) { + int targetAmount = -1; // order/offer amount + List<String> toolTip = e.toolTip; + for (int lineNr = 2; lineNr < Math.min(5, toolTip.size()); lineNr++) { + String line = EnumChatFormatting.getTextWithoutFormattingCodes(toolTip.get(lineNr)); + Matcher targetAmountMatcher = BAZAAR_TARGET_AMOUNT_PATTERN.matcher(line); + Matcher filledMatcher = BAZAAR_FILLED_PATTERN.matcher(line); + try { + if (targetAmount == -1 && targetAmountMatcher.matches()) { + targetAmount = Integer.parseInt(targetAmountMatcher.group(1).replace(",", "")); + } else if (targetAmount > 0 && filledMatcher.matches()) { + double percentageFilled = Double.parseDouble(filledMatcher.group(2)) / 100; + int itemsLeft; + if (percentageFilled == 1) { + // order already filled 100% + break; + } else if (filledMatcher.group(1).contains("k")) { + // filled amount is abbreviated, use filled % to calculate remaining items + itemsLeft = (int) (targetAmount - targetAmount * percentageFilled); + } else { + int amountFilled = Integer.parseInt(filledMatcher.group(1).replace(",", "")); + itemsLeft = targetAmount - amountFilled; + } + + if (itemsLeft > 0) { + toolTip.set(lineNr, toolTip.get(lineNr) + EnumChatFormatting.YELLOW + " " + Utils.formatNumber(itemsLeft) + " left"); + break; + } + } else if (targetAmount > 0) { + // order/offer amount was found, but next line wasn't the 'filled' line, abort! + break; + } + } catch (NumberFormatException ignored) { + break; + } + } + } + } + // for auction house: show price for each item if multiple items are sold at once or if higher tier ultimate enchantment books are sold MooConfig.Setting tooltipAuctionHousePriceEachDisplay = MooConfig.getTooltipAuctionHousePriceEachDisplay(); if ((tooltipAuctionHousePriceEachDisplay == MooConfig.Setting.ALWAYS || tooltipAuctionHousePriceEachDisplay == MooConfig.Setting.SPECIAL && MooConfig.isTooltipToggleKeyBindingPressed()) diff --git a/src/main/resources/assets/cowlection/lang/en_US.lang b/src/main/resources/assets/cowlection/lang/en_US.lang index a5d03f9..9f7c5cf 100644 --- a/src/main/resources/assets/cowlection/lang/en_US.lang +++ b/src/main/resources/assets/cowlection/lang/en_US.lang @@ -72,6 +72,8 @@ cowlection.config.bazaarSellAllOrder=§7Bazaar: §rOrder 'Sell Inventory/Sacks N cowlection.config.bazaarSellAllOrder.tooltip=Order the Sell All tooltip inside the Bazaar by...\n ‣ price (sum)\n ‣ price (each)\n ‣ item amount\n ‣ or keep it unorderd cowlection.config.bazaarSellAllOrderAscDesc=§7Bazaar: §rOrder 'Sell Inventory/Sacks Now' from cowlection.config.bazaarSellAllOrderAscDesc.tooltip=Order the Sell All tooltip inside the Bazaar from low to high, or from high to low? +cowlection.config.bazaarShowItemsLeft=§7Bazaar: §rShow items left to buy/sell +cowlection.config.bazaarShowItemsLeft.tooltip=Adds the amount of items left to buy/sell, instead of only showing the %% filled cowlection.config.bazaarConnectGraphsNodes=§7Bazaar: §rconnect the graph nodes cowlection.config.bazaarConnectGraphsNodes.tooltip=Draw a line through the nodes of the bazaar graphs?\n§7§oThis also (tries to) fix the graphs when using the MC unicode font. cowlection.config.bazaarConnectGraphsLineWidth=§7Bazaar: §rline width |