Skip to content

Commit

Permalink
lbin add shiny items (#292)
Browse files Browse the repository at this point in the history
Because Neu doesnt have price for shiny items i needed to add a new variable (neuName)
  • Loading branch information
LifeIsAParadox committed Sep 10, 2023
1 parent e2c3676 commit cddd32a
Showing 1 changed file with 25 additions and 15 deletions.
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 @@ -410,4 +420,4 @@ private static JsonObject downloadPrices(String type) {
apiAddresses.put("museum", "https://hysky.de/api/museum");
apiAddresses.put("motes", "https://hysky.de/api/motesprice");
}
}
}

0 comments on commit cddd32a

Please sign in to comment.