aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-02-06 03:42:18 +1100
committerGitHub <noreply@github.com>2024-02-05 17:42:18 +0100
commit8e882724c15c0b1981afda587313ff449a6a7814 (patch)
tree85c9b89a9449ade14432a46b249659e9ff99c3dd /src/main/java
parentaae0c39df6c42333d13b4e86e96f7fa58025330d (diff)
downloadskyhanni-8e882724c15c0b1981afda587313ff449a6a7814.tar.gz
skyhanni-8e882724c15c0b1981afda587313ff449a6a7814.tar.bz2
skyhanni-8e882724c15c0b1981afda587313ff449a6a7814.zip
Fix: shupdaterepo (#976)
Made /shupdaterepo better. #976
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt14
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)
}
}