aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/utils
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-06-10 12:09:05 +0800
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-06-10 12:09:05 +0800
commit48430e36a87c09e033c0bd43e65b70bbac0e2664 (patch)
tree9b9e336cd456def6ddc41bec1dcaf6980ea68022 /src/main/java/de/hysky/skyblocker/utils
parent2ce943b4278b7d89898acdde6046fb347e2447b1 (diff)
downloadSkyblocker-48430e36a87c09e033c0bd43e65b70bbac0e2664.tar.gz
Skyblocker-48430e36a87c09e033c0bd43e65b70bbac0e2664.tar.bz2
Skyblocker-48430e36a87c09e033c0bd43e65b70bbac0e2664.zip
Fix merge conflicts
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/ItemUtils.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
index fbc9bddc..1ac40d29 100644
--- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
+++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
@@ -8,6 +8,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.serialization.Codec;
import com.mojang.serialization.JsonOps;
import com.mojang.serialization.codecs.RecordCodecBuilder;
+import de.hysky.skyblocker.skyblock.item.tooltip.adders.ObtainedDateTooltip;
import de.hysky.skyblocker.SkyblockerMod;
import it.unimi.dsi.fastutil.ints.IntIntPair;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
@@ -102,6 +103,29 @@ public class ItemUtils {
return getCustomData(stack).getString(UUID);
}
+ /**
+ * This method converts the "timestamp" variable into the same date format as Hypixel represents it in the museum.
+ * Currently, there are two types of string timestamps the legacy which is built like this
+ * "dd/MM/yy hh:mm" ("25/04/20 16:38") and the current which is built like this
+ * "MM/dd/yy hh:mm aa" ("12/24/20 11:08 PM"). Since Hypixel transforms the two formats into one format without
+ * taking into account of their formats, we do the same. The final result looks like this
+ * "MMMM dd, yyyy" (December 24, 2020).
+ * Since the legacy format has a 25 as "month" SimpleDateFormat converts the 25 into 2 years and 1 month and makes
+ * "25/04/20 16:38" -> "January 04, 2022" instead of "April 25, 2020".
+ * This causes the museum rank to be much worse than it should be.
+ * <p>
+ * This also handles the long timestamp format introduced in January 2024 where the timestamp is in epoch milliseconds.
+ *
+ * @param stack the item under the pointer
+ * @return if the item have a "Timestamp" it will be shown formated on the tooltip
+ * @deprecated use {@link ObtainedDateTooltip#getTimestamp(ItemStack)} instead
+ */
+ public static String getTimestamp(ItemStack stack) {
+ NbtCompound customData = getCustomData(stack);
+
+ return ObtainedDateTooltip.getTimestamp(stack);
+ }
+
public static boolean hasCustomDurability(@NotNull ItemStack stack) {
NbtCompound customData = getCustomData(stack);
return customData != null && (customData.contains("drill_fuel") || customData.getString(ID).equals("PICKONIMBUS"));