Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lbin add shiny items #292

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ public static void onInjectTooltip(ItemStack stack, TooltipContext context, List

String name = getInternalNameFromNBT(stack, false);
String internalID = getInternalNameFromNBT(stack, true);
String neuName = name;
if (name == null || internalID == null) return;

if(name.startsWith("ISSHINY_")){
name = "SHINY_" + internalID;
neuName = internalID;
}

int count = stack.getCount();
boolean bazaarOpened = lines.stream().anyMatch(each -> each.getString().contains("Buy price:") || each.getString().contains("Sell price:"));

Expand Down Expand Up @@ -120,47 +126,47 @@ public static void onInjectTooltip(ItemStack stack, TooltipContext context, List
*/
switch (internalID) {
case "PET" -> {
name = name.replaceAll("LVL_\\d*_", "");
String[] parts = name.split("_");
neuName = neuName.replaceAll("LVL_\\d*_", "");
String[] parts = neuName.split("_");
String type = parts[0];
name = name.replaceAll(type + "_", "");
name = name + "-" + type;
name = name.replace("UNCOMMON", "1")
neuName = neuName.replaceAll(type + "_", "");
neuName = neuName + "-" + type;
neuName = neuName.replace("UNCOMMON", "1")
.replace("COMMON", "0")
.replace("RARE", "2")
.replace("EPIC", "3")
.replace("LEGENDARY", "4")
.replace("MYTHIC", "5")
.replace("-", ";");
}
case "RUNE" -> name = name.replaceAll("_(?!.*_)", ";");
case "POTION" -> name = "";
case "RUNE" -> neuName = neuName.replaceAll("_(?!.*_)", ";");
case "POTION" -> neuName = "";
case "ATTRIBUTE_SHARD" ->
name = internalID + "+" + name.replace("SHARD-", "").replaceAll("_(?!.*_)", ";");
default -> name = name.replace(":", "-");
neuName = internalID + "+" + neuName.replace("SHARD-", "").replaceAll("_(?!.*_)", ";");
default -> neuName = neuName.replace(":", "-");
}

if (!name.isEmpty() && lbinExist) {
if (!neuName.isEmpty() && lbinExist) {
SkyblockerConfig.Average type = SkyblockerConfig.get().general.itemTooltip.avg;

// "No data" line because of API not keeping old data, it causes NullPointerException
if (type == SkyblockerConfig.Average.ONE_DAY || type == SkyblockerConfig.Average.BOTH) {
lines.add(
Text.literal(String.format("%-19s", "1 Day Avg. Price:"))
.formatted(Formatting.GOLD)
.append(oneDayAvgPricesJson.get(name) == null
.append(oneDayAvgPricesJson.get(neuName) == null
? Text.literal("No data").formatted(Formatting.RED)
: getCoinsMessage(oneDayAvgPricesJson.get(name).getAsDouble(), count)
: getCoinsMessage(oneDayAvgPricesJson.get(neuName).getAsDouble(), count)
)
);
}
if (type == SkyblockerConfig.Average.THREE_DAY || type == SkyblockerConfig.Average.BOTH) {
lines.add(
Text.literal(String.format("%-19s", "3 Day Avg. Price:"))
.formatted(Formatting.GOLD)
.append(threeDayAvgPricesJson.get(name) == null
.append(threeDayAvgPricesJson.get(neuName) == null
? Text.literal("No data").formatted(Formatting.RED)
: getCoinsMessage(threeDayAvgPricesJson.get(name).getAsDouble(), count)
: getCoinsMessage(threeDayAvgPricesJson.get(neuName).getAsDouble(), count)
)
);
}
Expand Down Expand Up @@ -258,6 +264,10 @@ public static String getInternalNameFromNBT(ItemStack stack, boolean internalIDO
}

// Transformation to API format.
if (ea.contains("is_shiny")){
return "ISSHINY_" + internalName;
}

switch (internalName) {
case "ENCHANTED_BOOK" -> {
if (ea.contains("enchantments")) {
Expand Down Expand Up @@ -411,4 +421,4 @@ private static JsonObject downloadPrices(String type) {
apiAddresses.put("museum", "https://hysky.de/api/museum");
apiAddresses.put("motes", "https://hysky.de/api/motesprice");
}
}
}