aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-08 16:12:55 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-08 16:12:55 +0200
commit4463c7fa78f886a8abc09e867dd17cde2a685ad4 (patch)
tree9245b4eed7f410f1c168688a77eeda6bfd55c994 /src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java
parent9e08dbf2baa9819abd281ad285df7462c99491e2 (diff)
downloadskyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.tar.gz
skyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.tar.bz2
skyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.zip
code cleanup
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java86
1 files changed, 0 insertions, 86 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java
deleted file mode 100644
index 7520eaf3f..000000000
--- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.thatgravyboat.skyblockhud.handlers;
-
-import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent;
-import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent;
-import com.thatgravyboat.skyblockhud.utils.Utils;
-import java.math.RoundingMode;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.regex.Pattern;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-
-public class CurrencyHandler {
-
- private static int bits = 0;
- private static double coins = 0;
-
- public static void setBits(int amount) {
- bits = amount;
- }
-
- public static void setCoins(double amount) {
- coins = amount;
- }
-
- public static int getBits() {
- return bits;
- }
-
- public static double getCoins() {
- return coins;
- }
-
- @SubscribeEvent
- public void onSidebarLineUpdate(SidebarLineUpdateEvent event) {
- if (Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("purse:") || Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("piggy:")) {
- CurrencyHandler.checkCoins(event.formattedLine);
- }
- if (Utils.removeColor(event.formattedLine.toLowerCase().trim()).contains("bits:") && !event.formattedLine.toLowerCase().contains("(")) {
- CurrencyHandler.checkBits(event.formattedLine);
- }
- }
-
- @SubscribeEvent
- public void onSidebarPost(SidebarPostEvent event) {
- if (!Arrays.toString(event.arrayScores).toLowerCase().contains("bits:")) {
- CurrencyHandler.setBits(0);
- }
- }
-
- public static String getCoinsFormatted() {
- DecimalFormat formatter = new DecimalFormat("#,###.0", DecimalFormatSymbols.getInstance(Locale.CANADA));
- String output = formatter.format(getCoins());
- if (output.equals(".0")) output = "0.0"; else if (output.equals(",0")) output = "0,0";
- return output;
- }
-
- public static String getBitsFormatted() {
- DecimalFormat formatter = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.CANADA));
- formatter.setRoundingMode(RoundingMode.FLOOR);
- return getBits() > 999 ? formatter.format((double) getBits() / 1000) + "k" : String.valueOf(getBits());
- }
-
- public static void checkCoins(String formatedScoreboardLine) {
- String purse = Utils.removeWhiteSpaceAndRemoveWord(Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()).contains("purse:") ? "purse:" : "piggy:").replace(",", "");
- if (!purse.contains("(") && !purse.contains("+")) {
- try {
- double coins = Double.parseDouble(Pattern.compile("[^0-9.]").matcher(purse).replaceAll(""));
- CurrencyHandler.setCoins(coins);
- } catch (IllegalArgumentException ex) {
- System.out.println("Failed to parse purse, please report to hannibal2. Purse Text: " + purse);
- }
- }
- }
-
- public static void checkBits(String formatedScoreboardLine) {
- String bits = Utils.removeWhiteSpaceAndRemoveWord(Utils.removeColor(formatedScoreboardLine.toLowerCase().trim()), "bits:").replace(",", "");
- try {
- int bit = Integer.parseInt(Pattern.compile("[^0-9]").matcher(bits).replaceAll(""));
- CurrencyHandler.setBits(bit);
- } catch (IllegalArgumentException ex) {
- System.out.println("Failed to parse bits, please report to hannibal2. Bits Text: " + bits);
- }
- }
-}