Skip to content

Commit

Permalink
added thousands seperation commas to the final results and the item s…
Browse files Browse the repository at this point in the history
…tack price (simply times 64)
  • Loading branch information
BuildTools committed Nov 22, 2019
1 parent b195fe8 commit 383db04
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
Binary file modified bin/main/Main.class
Binary file not shown.
Binary file modified bin/main/MainWindow.class
Binary file not shown.
35 changes: 22 additions & 13 deletions src/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,16 @@ public static void filterData(boolean filterCT, String CT, boolean matchCaseCT,
consoleOut("No results!\n");
consoleOut("Sell Price [analyzed " + count_sold + " sold auctions]\n");
if (count_sold > 0) {
consoleOut("Minimum: "
+ (filterStream(data.stream(), filterCT, CT, matchCaseCT, filterCTL, CTL, matchCaseCTL, true, 0,
filterTT, TT, true, Math.max(1, HB))
.mapToLong(a -> a.getHighest_bid_amount() / a.getItem_count()).min().getAsLong())
+ " coins\n");
consoleOut("Average: " + (sum_sold / count_sold) + " coins\n");
consoleOut("Maximum: "
+ (filterStream(data.stream(), filterCT, CT, matchCaseCT, filterCTL, CTL, matchCaseCTL, true, 0,
filterTT, TT, true, Math.max(1, HB))
.mapToLong(a -> a.getHighest_bid_amount() / a.getItem_count()).max().getAsLong())
+ " coins\n");
long min = (filterStream(data.stream(), filterCT, CT, matchCaseCT, filterCTL, CTL, matchCaseCTL, true, 0,
filterTT, TT, true, Math.max(1, HB)).mapToLong(a -> a.getHighest_bid_amount() / a.getItem_count())
.min().getAsLong());
consoleOut("Minimum: " + addCommas(min) + " coins (x 64 = " + addCommas(min * 64) + " coins)\n");
long average = (sum_sold / count_sold);
consoleOut("Average: " + addCommas(average) + " coins (x 64 = " + addCommas(average * 64) + " coins)\n");
long max = (filterStream(data.stream(), filterCT, CT, matchCaseCT, filterCTL, CTL, matchCaseCTL, true, 0,
filterTT, TT, true, Math.max(1, HB)).mapToLong(a -> a.getHighest_bid_amount() / a.getItem_count())
.max().getAsLong());
consoleOut("Maximum: " + addCommas(max) + " coins (x 64 = " + addCommas(max * 64) + " coins)\n");
} else
consoleOut("No results!\n");
updateConsoleOut();
Expand All @@ -133,7 +132,7 @@ private static void printCheapest(int topX, boolean filterCT, String CT, boolean
filterSL, SL, filterTT, TT, false, HB).sorted(new CompHighestNextBidAsc()))
.filter(a -> a.getSeconds_left() > buy_time).skip(i).findFirst().get();
String cheapestAuctioneer = getPlayerFromUUID(min.getAuctioneer());
consoleOut("Minimum " + (i + 1) + ": " + (long) (min.getNextBidAmount()) + " coins for "
consoleOut("Minimum " + (i + 1) + ": " + addCommas(min.getNextBidAmount()) + " coins for "
+ min.getItem_count() + "x " + min.getItem_name() + " by " + cheapestAuctioneer + " "
+ min.getSeconds_left() + "sec left" + "\n");
}
Expand All @@ -144,7 +143,7 @@ private static Stream<Auction> filterStream(Stream<Auction> s, boolean filterCT,
boolean filterHB, int HB) {
return s.filter(a -> !filterCT || (matchCaseCT ? a.getItem_name().equalsIgnoreCase(CT)
: a.getItem_name().toLowerCase().contains(CT.toLowerCase())))
.filter(a -> !filterCTL || (matchCaseCTL ? a.getItem_lore().equalsIgnoreCase(CTL)
.filter(a -> !filterCTL || (matchCaseCTL ? a.getItem_lore().contains(CTL)
: a.getItem_lore().toLowerCase().contains(CTL.toLowerCase())))
.filter(a -> !filterSL || a.getSeconds_left() < SL)
.filter(a -> !filterTT || a.getSeconds_on() < 5 * 60 || a.getSeconds_on() > TT)
Expand All @@ -153,7 +152,17 @@ private static Stream<Auction> filterStream(Stream<Auction> s, boolean filterCT,

private static void consoleOut(String s) {
mw.getConsoleOut().append(s);
}

private static String addCommas(long l) {
String tmp = "" + l;
String res = "";
for (int i = 0; i < tmp.length(); i++)
if (i % 3 == 0 && i != 0)
res = (tmp.charAt(tmp.length() - 1 - i) + ",").concat(res);
else
res = (tmp.charAt(tmp.length() - 1 - i) + "").concat(res);
return res;
}

private static void updateConsoleOut() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public void keyPressed(KeyEvent e) {
textField_CTL.setColumns(10);
panel_1.add(textField_CTL, "cell 6 4 6 1,growx");

chckbxMatchCase_CTL = new JCheckBox("Match Case");
chckbxMatchCase_CTL.setEnabled(false);
chckbxMatchCase_CTL = new JCheckBox("Case Sensitive");
chckbxMatchCase_CTL.setSelected(true);
chckbxMatchCase_CTL.setToolTipText("");
panel_1.add(chckbxMatchCase_CTL, "cell 12 4 5 1");

Expand Down

0 comments on commit 383db04

Please sign in to comment.