Skip to content

Commit

Permalink
Merge pull request #192 from AzureAaron/motes-price-tooltip
Browse files Browse the repository at this point in the history
Add Motes Price Tooltip
  • Loading branch information
AzureAaron authored Jul 1, 2023
2 parents c71c140 + 1ab77d6 commit 8a844aa
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ public String toString() {

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()
Expand Down Expand Up @@ -369,6 +371,9 @@ public static class Barn {

public static class Rift {
public boolean mirrorverseWaypoints = true;
@ConfigEntry.BoundedDiscrete(min = 0, max = 5)
@ConfigEntry.Gui.Tooltip
public int mcGrubberStacks = 0;
}

public static class Slayer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -63,6 +64,17 @@ else if (npcPricesJson.has(name)) {
.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) {
Expand Down Expand Up @@ -289,6 +301,23 @@ private static Text getCoinsMessage(double price, int count) {
return priceTextTotal.append(priceTextEach);
}
}

private static Text getMotesMessage(int price, int count) {
float motesMultiplier = SkyblockerConfig.get().locations.rift.mcGrubberStacks * 0.05f + 1;
if (count == 1) {
String priceString = String.format(Locale.ENGLISH, "%1$,.1f", price * motesMultiplier).replace(".0", "");
return Text.literal(priceString + " Motes").formatted(Formatting.DARK_AQUA);
}
else {
String priceStringTotal = String.format(Locale.ENGLISH, "%1$,.1f", price * count * motesMultiplier).replace(".0", "");
MutableText priceTextTotal = Text.literal(priceStringTotal + " Motes ").formatted(Formatting.DARK_AQUA);

String priceStringEach = String.format(Locale.ENGLISH, "%1$,.1f", price * motesMultiplier).replace(".0", "");
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.
Expand Down Expand Up @@ -326,6 +355,9 @@ else if (type == SkyblockerConfig.Average.THREE_DAY) {

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]))
Expand Down Expand Up @@ -354,5 +386,6 @@ private static JsonObject downloadPrices(String type) {
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");
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"text.autoconfig.skyblocker.option.general.tabHud.tabHudScale.@Tooltip": "Value in %, relative to your vanilla GUI scale",
"text.autoconfig.skyblocker.option.general.itemTooltip": "Item Tooltip",
"text.autoconfig.skyblocker.option.general.itemTooltip.enableNPCPrice": "Enable NPC Price",
"text.autoconfig.skyblocker.option.general.itemTooltip.enableMotesPrice": "Enable Motes Price",
"text.autoconfig.skyblocker.option.general.itemTooltip.enableMotesPrice.@Tooltip": "Displays the Motes sell price of an item while in The Rift.",
"text.autoconfig.skyblocker.option.general.itemTooltip.enableAvgBIN": "Enable Avg. BIN Price",
"text.autoconfig.skyblocker.option.general.itemTooltip.avg": "Average Type",
"text.autoconfig.skyblocker.option.general.itemTooltip.avg.@Tooltip": "You can choose how many days of average price to be",
Expand Down Expand Up @@ -204,6 +206,8 @@

"text.autoconfig.skyblocker.option.locations.rift": "The Rift",
"text.autoconfig.skyblocker.option.locations.rift.mirrorverseWaypoints": "Enable Mirrorverse Waypoints",
"text.autoconfig.skyblocker.option.locations.rift.mcGrubberStacks": "McGrubber Stacks",
"text.autoconfig.skyblocker.option.locations.rift.mcGrubberStacks.@Tooltip": "Used for calculating Motes sell prices.",

"text.autoconfig.skyblocker.category.messages": "Messages",
"text.autoconfig.skyblocker.option.messages.chatFilterResult.PASS": "Disabled",
Expand Down

0 comments on commit 8a844aa

Please sign in to comment.