aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-05-28 20:06:50 +0300
committerRime <81419447+Emirlol@users.noreply.github.com>2024-06-08 04:13:47 +0300
commit4015ba2f5d79ece643a97c457d2c663f8ef519e7 (patch)
tree0b0fd73dd9d4bb3595882267a80d3ffcb44f1a18 /src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
parenta0bc7dc00f47cf1986120b47ccb23f6116660dda (diff)
downloadSkyblocker-4015ba2f5d79ece643a97c457d2c663f8ef519e7.tar.gz
Skyblocker-4015ba2f5d79ece643a97c457d2c663f8ef519e7.tar.bz2
Skyblocker-4015ba2f5d79ece643a97c457d2c663f8ef519e7.zip
Refactor obtained date tooltip
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/ItemUtils.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/ItemUtils.java41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
index 13b28808..fbc9bddc 100644
--- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
+++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java
@@ -20,7 +20,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
-import net.minecraft.nbt.NbtElement;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.text.Text;
@@ -29,13 +28,7 @@ import net.minecraft.util.dynamic.Codecs;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.time.Instant;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAccessor;
-import java.util.Iterator;
import java.util.List;
-import java.util.Locale;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.regex.Matcher;
@@ -46,8 +39,6 @@ import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.lit
public class ItemUtils {
public static final String ID = "id";
public static final String UUID = "uuid";
- private static final DateTimeFormatter OBTAINED_DATE_FORMATTER = DateTimeFormatter.ofPattern("MMMM d, yyyy").withZone(ZoneId.systemDefault()).localizedBy(Locale.ENGLISH);
- private static final DateTimeFormatter OLD_OBTAINED_DATE_FORMAT = DateTimeFormatter.ofPattern("M/d/yy h:m a").withZone(ZoneId.of("UTC")).localizedBy(Locale.ENGLISH);
public static final Pattern NOT_DURABILITY = Pattern.compile("[^0-9 /]");
public static final Predicate<String> FUEL_PREDICATE = line -> line.contains("Fuel: ");
private static final Codec<RegistryEntry<Item>> EMPTY_ALLOWING_ITEM_CODEC = Registries.ITEM.getEntryCodec();
@@ -111,38 +102,6 @@ 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
- */
- public static String getTimestamp(ItemStack stack) {
- NbtCompound customData = getCustomData(stack);
-
- if (customData != null && customData.contains("timestamp", NbtElement.LONG_TYPE)) {
- Instant date = Instant.ofEpochMilli(customData.getLong("timestamp"));
- return OBTAINED_DATE_FORMATTER.format(date);
- }
-
- if (customData != null && customData.contains("timestamp", NbtElement.STRING_TYPE)) {
- TemporalAccessor date = OLD_OBTAINED_DATE_FORMAT.parse(customData.getString("timestamp"));
- return OBTAINED_DATE_FORMATTER.format(date);
- }
-
- return "";
- }
-
public static boolean hasCustomDurability(@NotNull ItemStack stack) {
NbtCompound customData = getCustomData(stack);
return customData != null && (customData.contains("drill_fuel") || customData.getString(ID).equals("PICKONIMBUS"));