diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index 5296053d1..b686602bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.SimpleTimeMark import com.google.gson.JsonObject import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -22,12 +23,14 @@ import java.net.URL import java.nio.charset.StandardCharsets import java.util.concurrent.CompletableFuture import java.util.concurrent.atomic.AtomicBoolean +import kotlin.time.Duration.Companion.minutes class RepoManager(private val configLocation: File) { private val gson get() = ConfigManager.gson private var latestRepoCommit: String? = null private val repoLocation: File = File(configLocation, "repo") private var error = false + private var lastRepoUpdate = SimpleTimeMark.farPast() companion object { val successfulConstants = mutableListOf<String>() @@ -82,8 +85,7 @@ class RepoManager(private val configLocation: File) { val file = File(configLocation, "repo") if (file.exists() && currentCommitJSON != null && currentCommitJSON["sha"].asString == latestRepoCommit ) { - if (unsuccessfulConstants.isEmpty()) { - + if (unsuccessfulConstants.isEmpty() && lastRepoUpdate.passedSince() < 1.minutes) { if (command) { LorenzUtils.chat("§7The repo is already up to date!") atomicShouldManuallyReload.set(false) @@ -91,6 +93,7 @@ class RepoManager(private val configLocation: File) { return@supplyAsync false } } + lastRepoUpdate = SimpleTimeMark.now() RepoUtils.recursiveDelete(repoLocation) repoLocation.mkdirs() val itemsZip = File(repoLocation, "sh-repo-main.zip") @@ -214,19 +217,20 @@ class RepoManager(private val configLocation: File) { return } if (unsuccessfulConstants.isEmpty() && successfulConstants.isNotEmpty()) { - LorenzUtils.chat("Repo working fine!", prefixColor = "§a") + LorenzUtils.chat("Repo working fine! Commit hash: $latestRepoCommit", prefixColor = "§a") return } + LorenzUtils.chat("Repo has errors! Commit has: ${latestRepoCommit ?: "null"}", prefixColor = "§c") if (successfulConstants.isNotEmpty()) LorenzUtils.chat( "Successful Constants §7(${successfulConstants.size}):", prefixColor = "§a" ) for (constant in successfulConstants) { - LorenzUtils.chat(" §a- §7$constant") + LorenzUtils.chat(" §a- §7$constant", false) } LorenzUtils.chat("Unsuccessful Constants §7(${unsuccessfulConstants.size}):") for (constant in unsuccessfulConstants) { - LorenzUtils.chat(" §e- §7$constant") + LorenzUtils.chat(" §e- §7$constant", false) } } |