aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2023-06-01 18:30:36 +0200
committerGitHub <noreply@github.com>2023-06-01 18:30:36 +0200
commit68d024ef1a3791685c818e31ba51fc4956d48d59 (patch)
tree73f5d52bda2f57e59eec6d0a4f63a1a9230ff1e2 /src/main/java/io
parent20bfd7cea832136336bef221a9e41d131a7c64dd (diff)
downloadNotEnoughUpdates-68d024ef1a3791685c818e31ba51fc4956d48d59.tar.gz
NotEnoughUpdates-68d024ef1a3791685c818e31ba51fc4956d48d59.tar.bz2
NotEnoughUpdates-68d024ef1a3791685c818e31ba51fc4956d48d59.zip
Fixed Taxes in AH Overlay (#712)
Used double instead of int and fixed taxes Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java
index c761f847..c0c45db0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java
@@ -93,14 +93,14 @@ public class AuctionProfit {
if (!display.hasKey("Lore", 9)) continue;
NBTTagList lore = itemStack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8);
- int coinsToCheck = 0;
+ double coinsToCheck = 0;
for (int i = 0; i < lore.tagCount(); i++) {
String line = lore.getStringTagAt(i);
if (line.contains("§7Buy it now")) {
isBin = true;
String s = line.split("§7Buy it now: ")[1];
String coinsString = s.split("coins")[0];
- int coins = tryParse(EnumChatFormatting.getTextWithoutFormattingCodes(coinsString.trim()));
+ double coins = tryParse(EnumChatFormatting.getTextWithoutFormattingCodes(coinsString.trim()));
if (coins != 0) {
coinsToCheck += coins;
}
@@ -110,7 +110,7 @@ public class AuctionProfit {
String s = line.split("§7Top bid: ")[1];
String coinsString = s.split("coins")[0];
String textWithoutFormattingCodes = EnumChatFormatting.getTextWithoutFormattingCodes(coinsString.trim());
- int coins = tryParse(textWithoutFormattingCodes);
+ double coins = tryParse(textWithoutFormattingCodes);
if (coins != 0) {
coinsToCheck += coins;
}
@@ -119,20 +119,16 @@ public class AuctionProfit {
if (line.contains("§7Sold for: ")) {
String s = line.split("§7Sold for: ")[1];
String coinsString = s.split("coins")[0];
- int coins = tryParse(EnumChatFormatting.getTextWithoutFormattingCodes(coinsString.trim()));
+ double coins = tryParse(EnumChatFormatting.getTextWithoutFormattingCodes(coinsString.trim()));
if (coins != 0) {
- if (coins > 1000000) {
- coins /= 1.01;
- }
+ coins = removeTax(coins);
coinsToCollect += coins;
}
}
if (line.contains("§7Status: §aSold!") || line.contains("§7Status: §aEnded!")) {
if (coinsToCheck != 0) {
- if (coinsToCheck > 1000000) {
- coinsToCheck /= 1.01;
- }
+ coinsToCheck = removeTax(coinsToCheck);
coinsToCollect += coinsToCheck;
coinsToCheck = 0;
}
@@ -172,11 +168,21 @@ public class AuctionProfit {
fontRendererObj.drawString(valueIfSoldStr, a + 6, guiTop + 42, -1, false);
}
- public static Integer tryParse(String s) {
+ private double removeTax(double coins) {
+ if (coins < 10_000_000) {
+ return coins / 1.01;
+ }
+ if (coins < 100_000_000) {
+ return coins / 1.02;
+ }
+ return coins / 1.025;
+ }
+
+ public static Double tryParse(String s) {
try {
- return Integer.parseInt(s.replace(",", ""));
+ return Double.parseDouble(s.replace(",", ""));
} catch (NumberFormatException exception) {
- return 0;
+ return 0.0;
}
}