diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-10-21 22:56:53 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-21 13:56:53 +0200 |
| commit | 526365859a27d54b7ea5c07c08b301650c15ea0e (patch) | |
| tree | ddf772f564d85caf3dbe73c66c032affdf69281f | |
| parent | a98927303854058ad2d7a0d8bb88265c54139614 (diff) | |
| download | SkyHanni-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
61 files changed, 549 insertions, 336 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c347f761a..50fb6b668 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -125,8 +125,8 @@ SkyHanni uses a repo system to easily change static variables without the need f The repo is located at https://github.com/hannibal002/SkyHanni-REPO. A copy of all json files is stored on the computer under `.minecraft\config\skyhanni\repo`. On every game start, the copy gets updated (if outdated and if not manually disabled). -When working with the repo, it is recommended to disable the manual repo update to prevent overriding your local changes -accidentally. +If you add stuff to the repo make sure it gets serialised. See the [jsonobjects](src/main/java/at/hannibal2/skyhanni/utils/jsonobjects) +folder for how to properly do this. You also may have to disable repo auto update in game. ### Discord IPC diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 174cf38fa..32bd2a252 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -398,14 +398,13 @@ class SkyHanniMod { loadModule(DungeonCleanEnd()) loadModule(DungeonBossMessages()) loadModule(DungeonBossHideDamageSplash()) - loadModule(TrophyFishManager()) + loadModule(TrophyFishManager) loadModule(TrophyFishFillet()) loadModule(TrophyFishMessages()) loadModule(BazaarBestSellMethod()) loadModule(BazaarOpenPriceWebsite()) loadModule(AnvilCombineHelper()) loadModule(SeaCreatureMessageShortener()) - // registerEvent(new GriffinBurrowFinder()); loadModule(AshfangFreezeCooldown()) loadModule(AshfangNextResetCooldown()) loadModule(SummoningSoulsName()) @@ -496,7 +495,7 @@ class SkyHanniMod { loadModule(FarmingArmorDrops()) loadModule(JoinCrystalHollows()) loadModule(CrystalHollowsNamesInCore()) - loadModule(GardenVisitorColorNames()) + loadModule(GardenVisitorColorNames) loadModule(TeleportPadCompactName()) loadModule(AnitaMedalProfit()) loadModule(AnitaExtraFarmingFortune()) @@ -513,7 +512,7 @@ class SkyHanniMod { loadModule(CropSpeedMeter()) loadModule(AshfangMinisNametagHider()) loadModule(TeleportPadInventoryNumber()) - loadModule(ComposterOverlay()) + loadModule(ComposterOverlay) loadModule(DiscordRPCManager) loadModule(GardenCropMilestoneFix()) loadModule(GardenBurrowingSporesNotifier()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 0ba46c155..6c00abb66 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper +import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder @@ -27,7 +28,6 @@ import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.LockMouseLook import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui import at.hannibal2.skyhanni.features.slayer.SlayerItemProfitTracker @@ -209,6 +209,10 @@ object Commands { "shcarrot", "Toggles receiving the 12 fortune from carrots" ) { CaptureFarmingGear.reverseCarrotFortune() } + registerCommand( + "shrepostatus", + "Shows the status of all the mods constants" + ) { SkyHanniMod.repo.displayRepoStatus(false) } } private fun developersDebugFeatures() { @@ -380,4 +384,4 @@ object Commands { function(args.asList().toTypedArray()) } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt index 857b73d3f..5b32a1d15 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.utils.jsonobjects.BingoRanks +import at.hannibal2.skyhanni.utils.jsonobjects.BingoRanksJson import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object BingoAPI { @@ -9,7 +9,7 @@ object BingoAPI { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - ranks = event.getConstant<BingoRanks>("BingoRanks").ranks + ranks = event.getConstant<BingoRanksJson>("BingoRanks").ranks } fun getRank(text: String) = ranks.entries.find { text.contains(it.key) }?.value diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index 02d003398..0b20821f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -41,7 +41,7 @@ object GardenCropMilestones { CropMilestoneUpdateEvent().postAndCatch() } - private var cropMilestoneData: Map<CropType, List<Int>>? = null + private var cropMilestoneData: Map<CropType, List<Int>> = emptyMap() val cropCounter: MutableMap<CropType, Long>? get() = GardenAPI.config?.cropCounter @@ -53,14 +53,14 @@ object GardenCropMilestones { } fun CropType.isMaxed(): Boolean { - val maxValue = cropMilestoneData?.get(this)?.sum() ?: 1_000_000_000 // 1 bil for now + val maxValue = cropMilestoneData[this]?.sum() ?: 1_000_000_000 // 1 bil for now return getCounter() >= maxValue } fun getTierForCropCount(count: Long, crop: CropType): Int { var tier = 0 var totalCrops = 0L - val cropMilestone = cropMilestoneData?.get(crop) ?: return 0 + val cropMilestone = cropMilestoneData[crop] ?: return 0 for (tierCrops in cropMilestone) { totalCrops += tierCrops if (totalCrops > count) { @@ -72,12 +72,12 @@ object GardenCropMilestones { return tier } - fun getMaxTier() = cropMilestoneData?.values?.firstOrNull()?.size ?: 0 + fun getMaxTier() = cropMilestoneData.values.firstOrNull()?.size ?: 0 fun getCropsForTier(requestedTier: Int, crop: CropType): Long { var totalCrops = 0L var tier = 0 - val cropMilestone = cropMilestoneData?.get(crop) ?: return 0 + val cropMilestone = cropMilestoneData[crop] ?: return 0 for (tierCrops in cropMilestone) { totalCrops += tierCrops tier++ @@ -99,7 +99,6 @@ object GardenCropMilestones { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<GardenJson>("Garden") - cropMilestoneData = data.crop_milestones + cropMilestoneData = event.getConstant<GardenJson>("Garden").crop_milestones } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index e8ca2ab3b..1d34b7202 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -102,6 +103,7 @@ class HypixelData { checkHypixel() if (LorenzUtils.onHypixel) { HypixelJoinEvent().postAndCatch() + SkyHanniMod.repo.displayRepoStatus(true) } } if (!LorenzUtils.onHypixel) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 3e5d5f321..35e664cd7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SackChangeEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFilletValue import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName 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. */ diff --git a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt index e0eb01b9b..3b2b426fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt @@ -1,16 +1,16 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.data.repo.RepoError +import at.hannibal2.skyhanni.data.repo.RepoManager |
