diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2023-07-01 14:38:38 -0400 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2023-07-01 14:38:38 -0400 |
commit | f81e276c6fd27eac93fea03ecc6258d8d16d1cbd (patch) | |
tree | 5ccbc8094496cd8dbffcd80ff557cc44c29bb250 /src/main/java/me/xmrvizzy/skyblocker/skyblock/item | |
parent | c71c140c0a2830905870685bb7b8e83dee9276f2 (diff) | |
download | Skyblocker-f81e276c6fd27eac93fea03ecc6258d8d16d1cbd.tar.gz Skyblocker-f81e276c6fd27eac93fea03ecc6258d8d16d1cbd.tar.bz2 Skyblocker-f81e276c6fd27eac93fea03ecc6258d8d16d1cbd.zip |
Add Motes Price Tooltip
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/item')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java index e2d2d415..5237f4ec 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java @@ -40,6 +40,7 @@ public class PriceInfoTooltip { private static JsonObject threeDayAvgPricesJson; private static JsonObject lowestPricesJson; private static JsonObject isMuseumJson; + private static JsonObject motesPricesJson; private static boolean nullMsgSend = false; private final static Gson gson = new Gson(); private static final Map<String, String> apiAddresses; @@ -63,6 +64,17 @@ public class PriceInfoTooltip { .append(getCoinsMessage(npcPricesJson.get(name).getAsDouble(), count))); } } + + if (SkyblockerConfig.get().general.itemTooltip.enableMotesPrice && Utils.isInTheRift()) { + if(motesPricesJson == null) { + nullWarning(); + } + else if (motesPricesJson.has(name)) { + lines.add(Text.literal(String.format("%-20s", "Motes Price:")) + .formatted(Formatting.LIGHT_PURPLE) + .append(getMotesMessage(motesPricesJson.get(name).getAsInt(), count))); + } + } boolean bazaarExist = false; if (SkyblockerConfig.get().general.itemTooltip.enableBazaarPrice && !bazaarOpened) { @@ -289,6 +301,22 @@ public class PriceInfoTooltip { return priceTextTotal.append(priceTextEach); } } + + private static Text getMotesMessage(int price, int count) { + if (count == 1) { + String priceString = String.format(Locale.ENGLISH, "%1$,d", price); + return Text.literal(priceString + " Motes").formatted(Formatting.DARK_AQUA); + } + else { + String priceStringTotal = String.format(Locale.ENGLISH, "%1$,d", price * count); + MutableText priceTextTotal = Text.literal(priceStringTotal + " Motes ").formatted(Formatting.DARK_AQUA); + + String priceStringEach = String.format(Locale.ENGLISH, "%1$,d", price); + MutableText priceTextEach = Text.literal( "(" + priceStringEach + " each)").formatted(Formatting.GRAY); + + return priceTextTotal.append(priceTextEach); + } + } // If these options is true beforehand, the client will get first data of these options while loading. // After then, it will only fetch the data if it is on Skyblock. @@ -326,6 +354,9 @@ public class PriceInfoTooltip { if (SkyblockerConfig.get().general.itemTooltip.enableMuseumDate && isMuseumJson == null) futureList.add(CompletableFuture.runAsync(() -> isMuseumJson = downloadPrices("museum"))); + + if (SkyblockerConfig.get().general.itemTooltip.enableMotesPrice && motesPricesJson == null) + futureList.add(CompletableFuture.runAsync(() -> motesPricesJson = downloadPrices("motes"))); minute++; CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])) @@ -354,5 +385,6 @@ public class PriceInfoTooltip { apiAddresses.put("lowest bins", "https://lb.tricked.pro/lowestbins"); apiAddresses.put("npc", "https://hysky.de/api/npcprice"); apiAddresses.put("museum", "https://hysky.de/api/museum"); + apiAddresses.put("motes", "https://hysky.de/api/motesprice"); } } |