Skip to content

Commit

Permalink
Fix daily city project reminder triggering for released projects (han…
Browse files Browse the repository at this point in the history
…nibal002#928)

Fixed Daily City Project Reminder still working on already released projects. hannibal002#928
  • Loading branch information
qtlunya authored and RayDeeUx committed Jan 20, 2024
1 parent 617381d commit 0cab608
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.gui.inventory.GuiEditSign
Expand All @@ -35,8 +37,15 @@ class CityProjectFeatures {
private var inInventory = false
private var lastReminderSend = 0L

// TODO USE SH-REPO
private val contributeAgainPattern = "§7Contribute again: §e(?<time>.*)".toPattern()
private val patternGroup = RepoPattern.group("fame.projects")
private val contributeAgainPattern by patternGroup.pattern(
"contribute",
"§7Contribute again: §e(?<time>.*)"
)
private val completedPattern by patternGroup.pattern(
"completed",
"§aProject is (?:being built|released)!"
)

companion object {
private val config get() = SkyHanniMod.feature.event.cityProject
Expand Down Expand Up @@ -104,7 +113,8 @@ class CityProjectFeatures {
val itemName = item.name ?: continue

val lore = item.getLore()
if (lore.lastOrNull() == "§aProject is being built!") continue
val completed = lore.lastOrNull()?.let { completedPattern.matches(it) } ?: false
if (completed) continue
for (line in lore) {
contributeAgainPattern.matchMatcher(line) {
val rawTime = group("time")
Expand Down Expand Up @@ -163,7 +173,8 @@ class CityProjectFeatures {
private fun fetchMaterials(item: ItemStack, materials: MutableMap<String, Int>) {
var next = false
val lore = item.getLore()
if (lore.lastOrNull() == "§aProject is being built!") return
val completed = lore.lastOrNull()?.let { completedPattern.matches(it) } ?: false
if (completed) return
for (line in lore) {
if (line == "§7Cost") {
next = true
Expand Down

0 comments on commit 0cab608

Please sign in to comment.