diff options
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java | 2 | ||||
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/item/PriceInfoTooltip.java | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java index 3a8a4a1f..108eab47 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/me/xmrvizzy/skyblocker/config/SkyblockerConfig.java @@ -273,6 +273,8 @@ public class SkyblockerConfig implements ConfigData { public static class ItemTooltip { public boolean enableNPCPrice = true; + @ConfigEntry.Gui.Tooltip + public boolean enableMotesPrice = true; public boolean enableAvgBIN = true; @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) @ConfigEntry.Gui.Tooltip() 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"); } } |