diff options
3 files changed, 15 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java index a3c2f85de..5dfde6d70 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java @@ -17,7 +17,7 @@ import java.util.List; public class MixinItemStack implements ItemStackCachedData { @Unique - public CachedItemData skyhanni_cachedData = new CachedItemData(); + public CachedItemData skyhanni_cachedData = new CachedItemData((Void) null); public CachedItemData getSkyhanni_cachedData() { return skyhanni_cachedData; diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt b/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt index ca9f11cc6..663281ed1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt @@ -16,8 +16,7 @@ data class CachedItemData( // null = not loaded var riftExportable: Boolean? = null, - // null = not loaded - var itemRarityLastCheck: Long = 0L, // Can't use SimpleTimeMark here + var itemRarityLastCheck: SimpleTimeMark = SimpleTimeMark.farPast(), // null = not loaded var itemRarity: LorenzRarity? = null, @@ -26,5 +25,12 @@ data class CachedItemData( var lastInternalName: NEUInternalName? = null, - var lastInternalNameFetchTime: Long = 0L, // Still can't use SimpleTimeMark here -) + var lastInternalNameFetchTime: SimpleTimeMark = SimpleTimeMark.farPast(), +) { + /** + * Delegate constructor to avoid calling a function with default arguments from java. + * We can't call the generated no args constructors (or rather we cannot generate that constructor), because inline + * classes are not part of the java-kotlin ABI that is super well supported (especially with default arguments). + */ + constructor(void: Void?) : this() +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index cf5cc266e..d093dcfaf 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -98,12 +98,12 @@ object ItemUtils { fun ItemStack.getInternalNameOrNull(): NEUInternalName? { val data = cachedData - if (data.lastInternalNameFetchTime.asTimeMark().passedSince() < 1.seconds) { + if (data.lastInternalNameFetchTime.passedSince() < 1.seconds) { return data.lastInternalName } val internalName = grabInternalNameOrNull() data.lastInternalName = internalName - data.lastInternalNameFetchTime = SimpleTimeMark.now().toMillis() + data.lastInternalNameFetchTime = SimpleTimeMark.now() return internalName } @@ -238,7 +238,7 @@ object ItemUtils { private fun ItemStack.updateCategoryAndRarity() { val data = cachedData - data.itemRarityLastCheck = SimpleTimeMark.now().toMillis() + data.itemRarityLastCheck = SimpleTimeMark.now() val internalName = getInternalName() if (internalName == NEUInternalName.NONE) { data.itemRarity = null @@ -267,7 +267,7 @@ object ItemUtils { } private fun itemRarityLastCheck(data: CachedItemData) = - data.itemRarityLastCheck.asTimeMark().passedSince() > 10.seconds + data.itemRarityLastCheck.passedSince() > 10.seconds /** * Use when comparing the name (e.g. regex), not for showing to the user |