diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-24 16:48:20 -0400 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-26 16:23:22 -0400 |
commit | 36cf0be6a305fd5c6eae9f5948230bce56f553a6 (patch) | |
tree | 51d6c857477d716db882e7bce859f76fa62d6085 /src/main/java/de/hysky/skyblocker/utils/ItemUtils.java | |
parent | 86e8f24272ada7d38006e09650ebe77c8cf6a532 (diff) | |
download | Skyblocker-36cf0be6a305fd5c6eae9f5948230bce56f553a6.tar.gz Skyblocker-36cf0be6a305fd5c6eae9f5948230bce56f553a6.tar.bz2 Skyblocker-36cf0be6a305fd5c6eae9f5948230bce56f553a6.zip |
Cleanup references to ExtraAttributes and fix a bug relating to it
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/ItemUtils.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/ItemUtils.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index bf7a277f..f7556e4f 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -133,21 +133,21 @@ public class ItemUtils { * @return if the item have a "Timestamp" it will be shown formated on the tooltip */ public static String getTimestamp(ItemStack stack) { - NbtCompound ea = getCustomData(stack); + NbtCompound customData = getCustomData(stack); - if (ea != null && ea.contains("timestamp", NbtElement.LONG_TYPE)) { - Instant date = Instant.ofEpochMilli(ea.getLong("timestamp")); + if (customData != null && customData.contains("timestamp", NbtElement.LONG_TYPE)) { + Instant date = Instant.ofEpochMilli(customData.getLong("timestamp")); return OBTAINED_DATE_FORMATTER.format(date); } - if (ea != null && ea.contains("timestamp", NbtElement.STRING_TYPE)) { + if (customData != null && customData.contains("timestamp", NbtElement.STRING_TYPE)) { try { - Instant date = OLD_OBTAINED_DATE_FORMAT.parse(ea.getString("timestamp")).toInstant(); + Instant date = OLD_OBTAINED_DATE_FORMAT.parse(customData.getString("timestamp")).toInstant(); return OBTAINED_DATE_FORMATTER.format(date); } catch (ParseException e) { - LOGGER.warn("[Skyblocker Item Utils] Encountered an unknown exception while parsing time stamp of item {} with extra attributes {}", stack, ea, e); + LOGGER.warn("[Skyblocker Item Utils] Encountered an unknown exception while parsing time stamp of item {} with extra attributes {}", stack, customData, e); } } @@ -155,19 +155,19 @@ public class ItemUtils { } public static boolean hasCustomDurability(@NotNull ItemStack stack) { - NbtCompound extraAttributes = getCustomData(stack); - return extraAttributes != null && (extraAttributes.contains("drill_fuel") || extraAttributes.getString(ID).equals("PICKONIMBUS")); + NbtCompound customData = getCustomData(stack); + return customData != null && (customData.contains("drill_fuel") || customData.getString(ID).equals("PICKONIMBUS")); } @Nullable public static IntIntPair getDurability(@NotNull ItemStack stack) { - NbtCompound extraAttributes = getCustomData(stack); - if (extraAttributes == null) return null; + NbtCompound customData = getCustomData(stack); + if (customData == null) return null; // TODO Calculate drill durability based on the drill_fuel flag, fuel_tank flag, and hotm level // TODO Cache the max durability and only update the current durability on inventory tick - int pickonimbusDurability = extraAttributes.getInt("pickonimbus_durability"); + int pickonimbusDurability = customData.getInt("pickonimbus_durability"); if (pickonimbusDurability > 0) { return IntIntPair.of(pickonimbusDurability, 5000); } |