aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index d39b37c8a..1198ed7ae 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -1,6 +1,8 @@
package at.hannibal2.skyhanni.utils
+import at.hannibal2.skyhanni.data.NotificationManager
import at.hannibal2.skyhanni.data.PetAPI
+import at.hannibal2.skyhanni.data.SkyHanniNotification
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator.getAttributeName
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
@@ -19,8 +21,6 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import com.google.common.collect.Lists
-import io.github.moulberry.notenoughupdates.util.NotificationHandler
import net.minecraft.client.Minecraft
import net.minecraft.init.Items
import net.minecraft.item.Item
@@ -32,6 +32,8 @@ import net.minecraftforge.common.util.Constants
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.LinkedList
import java.util.regex.Matcher
+import kotlin.time.Duration.Companion.INFINITE
+import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
@SkyHanniModule
@@ -40,6 +42,7 @@ object ItemUtils {
private val itemNameCache = mutableMapOf<NEUInternalName, String>() // internal name -> item name
private val missingRepoItems = mutableSetOf<String>()
+ private var lastRepoWarning = SimpleTimeMark.farPast()
fun ItemStack.cleanName() = this.displayName.removeColor()
@@ -544,20 +547,19 @@ object ItemUtils {
fun addMissingRepoItem(name: String, message: String) {
if (!missingRepoItems.add(name)) return
ChatUtils.debug(message)
-// showRepoWarning()
+
+ if (lastRepoWarning.passedSince() < 3.minutes) return
+ lastRepoWarning = SimpleTimeMark.now()
+ showRepoWarning(name)
}
- // Running NEU's function `Utils.showOutdatedRepoNotification()` caused a NoSuchMethodError in dev env.
- // Therefore we run NotificationHandler.displayNotification directly
- private fun showRepoWarning() {
- NotificationHandler.displayNotification(
- Lists.newArrayList(
- "§c§lMissing repo data",
- "§cData used for some SkyHanni features is not up to date, this should normally not be the case.",
- "§cYou can try §l/neuresetrepo§r§c and restart your game to see if that fixes the issue.",
- "§cIf the problem persists please join the SkyHanni Discord and message in §l#support§r§c to get support.",
- ),
- true, true,
+ private fun showRepoWarning(item: String) {
+ val text = listOf(
+ "§c§lMissing repo data for item: $item",
+ "§cData used for some SkyHanni features is not up to date, this should normally not be the case.",
+ "§cYou can try §l/neuresetrepo§r§c and restart your game to see if that fixes the issue.",
+ "§cIf the problem persists please join the SkyHanni Discord and message in §l#support§r§c to get support.",
)
+ NotificationManager.queueNotification(SkyHanniNotification(text, INFINITE, true))
}
}