aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/repo
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-10-21 22:56:53 +1100
committerGitHub <noreply@github.com>2023-10-21 13:56:53 +0200
commit526365859a27d54b7ea5c07c08b301650c15ea0e (patch)
treeddf772f564d85caf3dbe73c66c032affdf69281f /src/main/java/at/hannibal2/skyhanni/data/repo
parenta98927303854058ad2d7a0d8bb88265c54139614 (diff)
downloadskyhanni-526365859a27d54b7ea5c07c08b301650c15ea0e.tar.gz
skyhanni-526365859a27d54b7ea5c07c08b301650c15ea0e.tar.bz2
skyhanni-526365859a27d54b7ea5c07c08b301650c15ea0e.zip
Backend: Serialise all constants and add repo error messages and status (#605)
Backend: Serialise all constants and add repo error messages and status #605
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/repo')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt62
1 files changed, 58 insertions, 4 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 363cbfd7c..593d9a652 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
@@ -27,6 +27,20 @@ class RepoManager(private val configLocation: File) {
private val repoLocation: File = File(configLocation, "repo")
private var error = false
+ companion object {
+ val successfulConstants = mutableListOf<String>()
+ val unsuccessfulConstants = mutableListOf<String>()
+
+ private var lastConstant: String? = null
+
+ fun setlastConstant(constant: String) {
+ lastConstant?.let {
+ successfulConstants.add(it)
+ }
+ lastConstant = constant
+ }
+ }
+
fun loadRepoInformation() {
atomicShouldManuallyReload.set(true)
if (SkyHanniMod.feature.dev.repoAutoUpdate) {
@@ -66,11 +80,14 @@ class RepoManager(private val configLocation: File) {
val file = File(configLocation, "repo")
if (file.exists() && currentCommitJSON != null && currentCommitJSON["sha"].asString == latestRepoCommit
) {
- if (command) {
- LorenzUtils.chat("§e[SkyHanni] §7The repo is already up to date!")
- atomicShouldManuallyReload.set(false)
+ if (unsuccessfulConstants.isEmpty()) {
+
+ if (command) {
+ LorenzUtils.chat("§e[SkyHanni] §7The repo is already up to date!")
+ atomicShouldManuallyReload.set(false)
+ }
+ return@supplyAsync false
}
- return@supplyAsync false
}
RepoUtils.recursiveDelete(repoLocation)
repoLocation.mkdirs()
@@ -126,8 +143,16 @@ class RepoManager(private val configLocation: File) {
ErrorManager.resetCache()
Minecraft.getMinecraft().addScheduledTask {
error = false
+ successfulConstants.clear()
+ unsuccessfulConstants.clear()
+ lastConstant = null
+
RepositoryReloadEvent(repoLocation, gson).postAndCatchAndBlock(ignoreErrorCache = true) {
error = true
+ lastConstant?.let {
+ unsuccessfulConstants.add(it)
+ }
+ lastConstant = null
}
comp.complete(null)
if (answerMessage.isNotEmpty() && !error) {
@@ -138,11 +163,40 @@ class RepoManager(private val configLocation: File) {
"§e[SkyHanni] Error with the repo detected, try /shupdaterepo to fix it!",
"shupdaterepo"
)
+ if (unsuccessfulConstants.isEmpty()) {
+ unsuccessfulConstants.add("All Constants")
+ }
}
}
return comp
}
+ fun displayRepoStatus(joinEvent: Boolean) {
+ if (joinEvent) {
+ if (unsuccessfulConstants.isNotEmpty()) {
+ LorenzUtils.chat("§c[SkyHanni] §7Repo Issue! Some features may not work. Please report this error on the Discord!")
+ LorenzUtils.chat("§7Repo Auto Update Value: §c${SkyHanniMod.feature.dev.repoAutoUpdate}")
+ LorenzUtils.chat("§7If you have Repo Auto Update turned off, please try turning that on.\n§cUnsuccessful Constants §7(${unsuccessfulConstants.size}):")
+ for (constant in unsuccessfulConstants) {
+ LorenzUtils.chat(" §e- §7$constant")
+ }
+ }
+ return
+ }
+ if (unsuccessfulConstants.isEmpty() && successfulConstants.isNotEmpty()) {
+ LorenzUtils.chat("§a[SkyHanni] Repo working fine!")
+ return
+ }
+ if (successfulConstants.isNotEmpty()) LorenzUtils.chat("§a[SkyHanni] Successful Constants §7(${successfulConstants.size}):")
+ for (constant in successfulConstants) {
+ LorenzUtils.chat(" §a- §7$constant")
+ }
+ LorenzUtils.chat("§c[SkyHanni] Unsuccessful Constants §7(${unsuccessfulConstants.size}):")
+ for (constant in unsuccessfulConstants) {
+ LorenzUtils.chat(" §e- §7$constant")
+ }
+ }
+
/**
* Parses a file in to a JsonObject.
*/