aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/cowtipper/cowlection
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection')
-rw-r--r--src/main/java/de/cowtipper/cowlection/config/MooConfig.java6
-rw-r--r--src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java47
2 files changed, 52 insertions, 1 deletions
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())