diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-21 11:16:34 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-21 11:16:34 +0200 |
commit | 830fdb7022ac173b421daeddfbc7e67c0d9f891b (patch) | |
tree | a9e4397add1cc121e9cea0a35500de5ccd66f5a9 | |
parent | 020c278b3c6cdff38449e0fe67bb36bf196ed045 (diff) | |
download | skyhanni-830fdb7022ac173b421daeddfbc7e67c0d9f891b.tar.gz skyhanni-830fdb7022ac173b421daeddfbc7e67c0d9f891b.tar.bz2 skyhanni-830fdb7022ac173b421daeddfbc7e67c0d9f891b.zip |
better repo error handling
34 files changed, 204 insertions, 239 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt index ca2557af0..857b73d3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BingoAPI.kt @@ -9,13 +9,11 @@ object BingoAPI { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant<BingoRanks>("BingoRanks")?.let { - ranks = it.ranks - } + ranks = event.getConstant<BingoRanks>("BingoRanks").ranks } fun getRank(text: String) = ranks.entries.find { text.contains(it.key) }?.value fun getIcon(searchRank: Int) = ranks.entries.find { it.value == searchRank }?.key -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index 277fdb56c..02d003398 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -99,7 +99,7 @@ object GardenCropMilestones { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<GardenJson>("Garden") ?: return + val data = event.getConstant<GardenJson>("Garden") cropMilestoneData = data.crop_milestones } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoError.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoError.kt new file mode 100644 index 000000000..60606ffa9 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoError.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.data.repo + +class RepoError : Error { + constructor(errorMessage: String) : super(errorMessage) + constructor(errorMessage: String, cause: Throwable) : super(errorMessage, cause) +} 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 ed35272cd..df19aac2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -25,6 +25,7 @@ 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 fun loadRepoInformation() { atomicShouldManuallyReload.set(true) @@ -39,12 +40,12 @@ class RepoManager(private val configLocation: File) { fun updateRepo() { atomicShouldManuallyReload.set(true) - fetchRepository(true).thenRun { this.reloadRepository("Repo updated successful :)") } + fetchRepository(true).thenRun { this.reloadRepository("Repo updated successful.") } } fun reloadLocalRepo() { atomicShouldManuallyReload.set(true) - reloadRepository("Repo loaded from local files successful :)") + reloadRepository("Repo loaded from local files successful.") } private fun fetchRepository(command: Boolean): CompletableFuture<Boolean> { @@ -62,7 +63,9 @@ class RepoManager(private val configLocation: File) { e.printStackTrace() } if (latestRepoCommit == null || latestRepoCommit!!.isEmpty()) return@supplyAsync false - if (File(configLocation, "repo").exists() && currentCommitJSON != null && currentCommitJSON["sha"].asString == latestRepoCommit) { + 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) @@ -120,15 +123,19 @@ class RepoManager(private val configLocation: File) { private fun reloadRepository(answerMessage: String = ""): CompletableFuture<Void?> { val comp = CompletableFuture<Void?>() if (!atomicShouldManuallyReload.get()) return comp + ErrorManager.resetCache() Minecraft.getMinecraft().addScheduledTask { - try { - RepositoryReloadEvent(repoLocation, gson).postAndCatch() - comp.complete(null) - if (answerMessage.isNotEmpty()) { - LorenzUtils.chat("§e[SkyHanni] §a$answerMessage") - } - } catch (e: java.lang.Exception) { - ErrorManager.logError(e, "Error reading repo data!") + error = false + RepositoryReloadEvent(repoLocation, gson).postAndCatchAndBlock(true, true) { + LorenzUtils.clickableChat( + "§e[SkyHanni] Error with the repo detected, try /shupdaterepo to fix it!", + "shupdaterepo" + ) + error = true + } + comp.complete(null) + if (answerMessage.isNotEmpty() && !error) { + LorenzUtils.chat("§e[SkyHanni] §a$answerMessage") } } return comp @@ -175,4 +182,4 @@ class RepoManager(private val configLocation: File) { ) ).use { writer -> writer.write(gson.toJson(json)) } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt index 2438a9be3..7ec70c673 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.data.repo -import at.hannibal2.skyhanni.test.command.ErrorManager import com.google.gson.Gson import java.io.BufferedReader import java.io.File @@ -8,10 +7,10 @@ import java.io.FileInputStream import java.io.FileOutputStream import java.io.IOException import java.io.InputStreamReader +import java.lang.reflect.Type import java.nio.charset.StandardCharsets import java.nio.file.Files import java.util.zip.ZipInputStream -import java.lang.reflect.Type object RepoUtils { @@ -84,23 +83,13 @@ object RepoUtils { return false } - fun <T> getConstant(repo: File, constant: String, gson: Gson, clazz: Class<T>?, type: Type? = null): T? { - if (!repo.exists()) return null - - val jsonFile = File(repo, "constants/$constant.json") + fun <T> getConstant(repoLocation: File, constant: String, gson: Gson, clazz: Class<T>?, type: Type? = null): T { + val name = "constants/$constant.json" + val jsonFile = File(repoLocation, name) if (!jsonFile.isFile) { - ErrorManager.logError( - Error("File '$jsonFile' not found!"), - "File in repo missing! ($jsonFile). Try §e/shupdaterepo" - ) - return null + throw RepoError("Repo file '$name' not found.") } - BufferedReader( - InputStreamReader( - FileInputStream(jsonFile), - StandardCharsets.UTF_8 - ) - ).use { reader -> + BufferedReader(InputStreamReader(FileInputStream(jsonFile), StandardCharsets.UTF_8)).use { reader -> if (type == null) { return gson.fromJson(reader, clazz) } else { @@ -108,4 +97,4 @@ object RepoUtils { } } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index 32c552221..e4e6f87c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -1,8 +1,10 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.mixins.transformers.AccessorEventBus import at.hannibal2.skyhanni.test.command.ErrorManager import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.Event +import net.minecraftforge.fml.common.eventhandler.IEventListener abstract class LorenzEvent : Event() { @@ -10,16 +12,35 @@ abstract class LorenzEvent : Event() { this::class.simpleName } - fun postAndCatch(): Boolean { - return runCatching { - postWithoutCatch() - }.onFailure { - ErrorManager.logError( - it, - "Caught an ${it::class.simpleName ?: "error"} at ${eventName}: '${it.message}'" - ) - }.getOrDefault(isCanceled) + fun postAndCatch() = postAndCatchAndBlock {} + + fun postAndCatchAndBlock( + printError: Boolean = true, + stopOnError: Boolean = false, + onError: (Throwable) -> Unit, + ): Boolean { + for (listener in getListeners()) { + try { + listener.invoke(this) + } catch (e: Throwable) { + if (printError) { + val callerName = listener.toString().split(" ")[1].split("@")[0].split(".").last() + ErrorManager.logError( + e, + "Caught an ${e::class.simpleName ?: "error"} at $eventName in $callerName: '${e.message}'" + ) + } + onError(e) + if (stopOnError) break + } + } + return if (isCancelable) isCanceled else false + } + + private fun getListeners(): Array<out IEventListener> { + val accessorEventBus = MinecraftForge.EVENT_BUS as AccessorEventBus + return listenerList.getListeners(accessorEventBus.busId) } fun postWithoutCatch() = MinecraftForge.EVENT_BUS.post(this) -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt index 8010564a0..e0eb01b9b 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RepositoryReloadEvent.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.data.repo.RepoError import at.hannibal2.skyhanni.data.repo.RepoUtils -import at.hannibal2.skyhanni.test.command.ErrorManager import com.google.gson.Gson import com.google.gson.JsonObject import java.io.File @@ -10,13 +10,10 @@ import java.lang.reflect.Type class RepositoryReloadEvent(val repoLocation: File, val gson: Gson) : LorenzEvent() { fun getConstant(constant: String) = getConstant<JsonObject>(constant) - inline fun <reified T : Any> getConstant(constant: String, type: Type? = null) = try { + inline fun <reified T : Any> getConstant(constant: String, type: Type? = null): T = try { + if (!repoLocation.exists()) throw RepoError("Repo folder does not exist!") RepoUtils.getConstant(repoLocation, constant, gson, T::class.java, type) } catch (e: Exception) { - ErrorManager.logError( - Exception("Repo parsing error while trying to read constant '$constant'", e), - "Error reading repo data" - ) - null + throw RepoError("Repo parsing error while trying to read constant '$constant'", e) } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt index a112616a3..318888fec 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardTips.kt @@ -20,9 +20,7 @@ class BingoCardTips { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant<BingoJson>("Bingo")?.let { - tips = it.bingo_tips - } + tips = event.getConstant<BingoJson>("Bingo").bingo_tips } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt index af0d1b805..6de251af5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt @@ -29,25 +29,18 @@ class PlayerChatFilter { var countCategories = 0 var countFilters = 0 - try { - val data = event.getConstant("PlayerChatFilter") ?: return - - for (category in data["filters"].asJsonArray) { - val jsonObject = category.asJsonObject - val description = jsonObject["description"].asString - val filter = MultiFilter() - filter.load(jsonObject) - filters[description] = filter - - countCategories++ - countFilters += filter.count() - } - - LorenzUtils.debug("Loaded $countFilters filters in $countCategories categories from repo") - - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") + val data = event.getConstant("PlayerChatFilter") + for (category in data["filters"].asJsonArray) { + val jsonObject = category.asJsonObject + val description = jsonObject["description"].asString + val filter = MultiFilter() + filter.load(jsonObject) + filters[description] = filter + + countCategories++ + countFilters += filter.count() } + + LorenzUtils.debug("Loaded $countFilters filters in $countCategories categories from repo") } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt index 62e6f9e9c..2c1c339dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt @@ -15,7 +15,7 @@ object GetFromSacksTabComplete { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - sackList = event.getConstant<SackListJson>("Sacks")?.sackList ?: return + sackList = event.getConstant<SackListJson>("Sacks").sackList } fun handleTabComplete(command: String): List<String>? { @@ -42,4 +42,4 @@ object GetFromSacksTabComplete { } fun isEnabled() = LorenzUtils.inSkyBlock && config.gfsSack -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt index 9e54fef06..c41129c5f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt @@ -35,31 +35,26 @@ class SeaCreatureManager { allFishingMobs.clear() var counter = 0 - try { - val data = event.getConstant<Map<String, SeaCreatureJson.Variant>>("SeaCreatures", SeaCreatureJson.TYPE) ?: return - val allFishingMobs = mutableMapOf<String,SeaCreature>() + val data = event.getConstant<Map<String, SeaCreatureJson.Variant>>("SeaCreatures", SeaCreatureJson.TYPE) + val allFishingMobs = mutableMapOf<String, SeaCreature>() - for (variant in data.values) { - val chatColor = variant.chat_color - for ((displayName, seaCreature) in variant.sea_creatures) { - val chatMessage = seaCreature.chat_message - val fishingExperience = seaCreature.fishing_experience - val rarity = seaCreature.rarity - val rare = seaCreature.rare ?: false + for (variant in data.values) { + val chatColor = variant.chat_color + for ((displayName, seaCreature) in variant.sea_creatures) { + val chatMessage = seaCreature.chat_message + val fishingExperience = seaCreature.fishing_experience + val rarity = seaCreature.rarity + val rare = seaCreature.rare ?: false - val creature = SeaCreature(displayName, fishingExperience, chatColor, rare, rarity) - seaCreatureMap[chatMessage] = creature - allFishingMobs[displayName] = creature - counter++ - } + val creature = SeaCreature(displayName, fishingExperience, chatColor, rare, rarity) + seaCreatureMap[chatMessage] = creature + allFishingMobs[displayName] = creature + counter++ } - SeaCreatureManager.allFishingMobs = allFishingMobs - LorenzUtils.debug("Loaded $counter sea creatures from repo") - - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") } + SeaCreatureManager.allFishingMobs = allFishingMobs + LorenzUtils.debug("Loaded $counter sea creatures from repo") + } companion object { @@ -75,4 +70,4 @@ class SeaCreatureManager { return seaCreatureMap.getOrDefault(message, null) } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt index c2f4e64fe..4d8b547a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt @@ -6,20 +6,13 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.jsonobjects.TrophyFishJson import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - class TrophyFishManager { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - try { - val json = event.getConstant<TrophyFishJson>("TrophyFish") - ?: error("Could not read repo data from TrophyFish.json") - trophyFishInfo = json.trophy_fish - LorenzUtils.debug("Loaded trophy fish from repo") - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") - } + val json = event.getConstant<TrophyFishJson>("TrophyFish") + trophyFishInfo = json.trophy_fish + LorenzUtils.debug("Loaded trophy fish from repo") } companion object { @@ -32,4 +25,4 @@ class TrophyFishManager { fun getInfoByName(name: String) = trophyFishInfo.values.find { it.displayName == name } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index e67de332f..05b78d047 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -243,10 +243,10 @@ object GardenAPI { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<GardenJson>("Garden") ?: return + val data = event.getConstant<GardenJson>("Garden") gardenExperience = data.garden_exp } private var gardenExperience = listOf<Int>() private const val gardenOverflowExp = 10000 // can be changed I guess -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index 3cd2e0a39..8b0b3d70d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI.getLevel import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.KeyboardManager @@ -332,7 +331,6 @@ class ComposterOverlay { if (currentTimeType == TimeType.COMPOST) "Compost multiplier" else "Composts per $timeText" newList.addAsSingletonList(" §7$compostPerTitle: §e${multiplier.round(2)}$compostPerTitlePreview") - val organicMatterPrice = getPrice(organicMatterItem) val organicMatterFactor = organicMatterFactors[organicMatterItem]!! @@ -360,7 +358,6 @@ class ComposterOverlay { " §7Material costs per $timeText: §6${NumberUtil.format(totalCost)}$materialCostFormatPreview" newList.addAsSingletonList(materialCostFormat) - val priceCompost = getPrice("COMPOST") val profit = ((priceCompost * multiDropFactor) - (fuelPricePer + organicMatterPricePer)) * timeMultiplier val profitPreview = @@ -463,7 +460,8 @@ class ComposterOverlay { if (sackStatus == SackStatus.MISSING || sackStatus == SackStatus.OUTDATED) { if (sackStatus == SackStatus.OUTDATED) LorenzUtils.sendCommandToServer("gfs $internalName ${itemsNeeded - having}") - val sackType = if (internalName == "VOLTA" || internalName == "OIL_BARREL") "Mining" else "Enchanted Agronomy" // TODO Add sack type repo data + val sackType = + if (internalName == "VOLTA" || internalName == "OIL_BARREL") "Mining" else "Enchanted Agronomy" // TODO Add sack type repo data LorenzUtils.clickableChat( "§e[SkyHanni] Sacks could not be loaded. Click here and open your §9$sackType Sack §eto update the data!", "sax" @@ -513,15 +511,9 @@ class ComposterOverlay { } private fun updateOrganicMatterFactors() { - try { - val garden = this.garden ?: return - organicMatterFactors = updateOrganicMatterFactors(garden.organic_matter) - fuelFactors = garden.fuel - - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") - } + val garden = this.garden ?: return + organicMatterFactors = updateOrganicMatterFactors(garden.organic_matter) + fuelFactors = garden.fuel } private fun updateOrganicMatterFactors(baseValues: Map<String, Double>): Map<String, Double> { @@ -580,4 +572,4 @@ class ComposterOverlay { event.move(3, "garden.composterOverlayFuelExtrasPos", "garden.composters.overlayFuelExtrasPos") event.move(3, "garden.composterRoundDown", "garden.composters.roundDown") } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt index 1f35e0647..fc68546e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings @@ -107,13 +106,8 @@ class FarmingArmorDrops { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - try { - val data = event.getConstant<ArmorDropsJson>("ArmorDrops") ?: error("ArmorDrops not found in repo") - armorDropInfo = data.special_crops - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") - } + val data = event.getConstant<ArmorDropsJson>("ArmorDrops") + armorDropInfo = data.special_crops } companion object { @@ -150,4 +144,4 @@ class FarmingArmorDrops { event.move(3, "garden.farmingArmorDropsHideChat", "garden.farmingArmorDrop.hideChat") event.move(3, "garden.farmingArmorDropsPos", "garden.farmingArmorDrop.pos") } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index 17a399ed9..0d9e4409f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -14,7 +14,6 @@ import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import com.google.gson.JsonObject import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -39,7 +38,6 @@ object GardenCropSpeed { var latestMelonDicer = 0.0 var latestPumpkinDicer = 0.0 - init { fixedRateTimer(name = "skyhanni-crop-milestone-speed", period = 1000L) { if (isEnabled()) { @@ -151,14 +149,9 @@ object GardenCropSpeed { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - try { - val dicerJson = event.getConstant("DicerDrops") ?: error("DicerDrops not found in repo") - calculateAverageDicer(melonDicer, dicerJson["MELON"].asJsonObject) - calculateAverageDicer(pumpkinDicer, dicerJson["PUMPKIN"].asJsonObject) - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") - } + val dicerJson = event.getConstant("DicerDrops") + calculateAverageDicer(melonDicer, dicerJson["MELON"].asJsonObject) + calculateAverageDicer(pumpkinDicer, dicerJson["PUMPKIN"].asJsonObject) } fun getRecentBPS(): Double { @@ -198,7 +191,7 @@ object GardenCropSpeed { @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(3,"garden.blocksBrokenResetTime", "garden.cropMilestones.blocksBrokenResetTime") + event.move(3, "garden.blocksBrokenResetTime", "garden.cropMilestones.blocksBrokenResetTime") } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt index 4824e9de0..0a3eabf86 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt @@ -33,7 +33,7 @@ class AnitaExtraFarmingFortune { val anitaUpgrade = GardenAPI.config?.fortune?.anitaUpgrade ?: return var contributionFactor = 1.0 - val baseAmount = levelPrice[anitaUpgrade + 1]?.jacob_tickets ?: return + val baseAmount = levelPrice[anitaUpgrade + 1]?.jacob_tickets ?: return for (line in event.toolTip) { "§5§o§aJacob's Ticket §8x(?<realAmount>.*)".toPattern().matchMatcher(line) { val realAmount = group("realAmount").formatNumber().toDouble() @@ -63,7 +63,6 @@ class AnitaExtraFarmingFortune { event.toolTip.add(index, "§7Cost to max out") event.toolTip.add(index, "") - val upgradeIndex = event.toolTip.indexOfFirst { it.contains("You have") } if (upgradeIndex != -1) { event.toolTip.add(upgradeIndex + 1, "§7Current Tier: §e$anitaUpgrade/${levelPrice.size}") @@ -72,13 +71,12 @@ class AnitaExtraFarmingFortune { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant<AnitaUpgradeCostsJson>("AnitaUpgradeCosts")?.let { - val map = mutableMapOf<Int, AnitaUpgradeCostsJson.Price>() - for ((rawNumber, price) in it.level_price) { - map[rawNumber.toInt()] = price - } - levelPrice = map + val upgradeCosts = event.getConstant<AnitaUpgradeCostsJson>("AnitaUpgradeCosts") + val map = mutableMapOf<Int, AnitaUpgradeCostsJson.Price>() + for ((rawNumber, price) in upgradeCosts.level_price) { + map[rawNumber.toInt()] = price } + levelPrice = map } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt index 49a1e8c56..84e8f17d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -10,24 +9,17 @@ class GardenVisitorColorNames { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - try { - val mapColor = mutableMapOf<String, String>() - val mapItems = mutableMapOf<String, List<String>>() - event.getConstant("Garden")?.let { garden -> - for ((name, element) in garden["visitors"].asJsonObject.entrySet()) { - val jsonObject = element.asJsonObject - val rarity = jsonObject["rarity"].asString - mapColor[name] = getColor(rarity) - mapItems[name] = jsonObject["need_items"].asJsonArray.map { it.asString } - } - } - visitorColor = mapColor - visitorItems = mapItems - - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") + val mapColor = mutableMapOf<String, String>() + val mapItems = mutableMapOf<String, List<String>>() + val garden = event.getConstant("Garden") + for ((name, element) in garden["visitors"].asJsonObject.entrySet()) { + val jsonObject = element.asJsonObject + val rarity = jsonObject["rarity"].asString + mapColor[name] = getColor(rarity) + mapItems[name] = jsonObject["need_items"].asJsonArray.map { it.asString } } + visitorColor = mapColor + visitorItems = mapItems } companion object { @@ -43,7 +35,6 @@ class GardenVisitorColorNames { } } - private fun getColor(rarity: String) = when (rarity) { "uncommon" -> "§a" "rare" -> "§9" @@ -52,4 +43,4 @@ class GardenVisitorColorNames { else -> throw RuntimeException("Unknown rarity for '$rarity'") } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 97278e9f9..0e8a9fe0b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -54,22 +54,14 @@ class HideNotClickableItems { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - try { - event.getConstant("TradeNpcs")?.let { - tradeNpcFilter.load(it) - } - - val hideNotClickableItems = event.getConstant("HideNotClickableItems") ?: return - hideNpcSellFilter.load(hideNotClickableItems["hide_npc_sell"].asJsonObject) - hideInStorageFilter.load(hideNotClickableItems["hide_in_storage"].asJsonObject) - updateSalvageList(hideNotClickableItems) - hidePlayerTradeFilter.load(hideNotClickableItems["hide_player_trade"].asJsonObject) - notAuctionableFilter.load(hideNotClickableItems["not_auctionable"].asJsonObject) - - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("Error in RepositoryReloadEvent for HideNotClickableItems") - } + tradeNpcFilter.load(event.getConstant("TradeNpcs")) + + val hideNotClickableItems = event.getConstant("HideNotClickableItems") ?: return + hideNpcSellFilter.load(hideNotClickableItems["hide_npc_sell"].asJsonObject) + hideInStorageFilter.load(hideNotClickableItems["hide_in_storage"].asJsonObject) + updateSalvageList(hideNotClickableItems) + hidePlayerTradeFilter.load(hideNotClickableItems["hide_player_trade"].asJsonObject) + notAuctionableFilter.load(hideNotClickableItems["not_auctionable"].asJsonObject) } private fun updateSalvageList(hideNotClickableItems: JsonObject) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt index 8608c8f16..1e43944f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt @@ -39,23 +39,17 @@ class ItemStars { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - try { - val items = event.getConstant("Items") ?: return - if (items.has("crimson_armors")) { - armorNames.clear() - armorNames.addAll(items.getAsJsonArray("crimson_armors").map { it.asString }) - } + val items = event.getConstant("Items") + if (items.has("crimson_armors")) { + armorNames.clear() + armorNames.addAll(items.getAsJsonArray("crimson_armors").map { it.asString }) + } - tiers.clear() - if (items.has("crimson_tiers")) { - items.getAsJsonObject("crimson_tiers").entrySet().forEach { - tiers[it.key] = it.value.asInt - } + tiers.clear() + if (items.has("crimson_tiers")) { + items.getAsJsonObject("crimson_tiers").entrySet().forEach { + tiers[it.key] = it.value.asInt } - - } catch (e: Exception) { - e.printStackTrace() - LorenzUtils.error("error in RepositoryReloadEvent") } } @@ -130,4 +124,4 @@ class ItemStars { return -1 } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt index 0fd9f2cc2..5265d6cfd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt @@ -24,7 +24,7 @@ class QuickCraftFeatures { @SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
- quickCraftableItems = event.getConstant<List<String>>("QuickCraftableItems") ?: emptyList()
+ quickCraftableItems = event.getConstant<List<String>>("QuickCraftableItems")
}
@SubscribeEvent
@@ -74,4 +74,4 @@ class QuickCraftFeatures { fun isEnabled() =
LorenzUtils.inSkyBlock && config.quickCraftingConfirmation && InventoryUtils.openInventoryName() == "Craft Item"
-}
\ No newline at end of file +}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt index f3bb75c46..69991dc76 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt @@ -28,7 +28,7 @@ object QuickModMenuSwitch { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val modsJar = event.getConstant<ModsJson>("ModGuiSwitcher") ?: return + val modsJar = event.getConstant<ModsJson>("ModGuiSwitcher") mods = buildList { out@ for ((name, mod) in modsJar.mods) { for (path in mod.guiPath) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt index 6c60de732..ee49b3023 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt @@ -138,9 +138,7 @@ object AdvancedPlayerList { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant<ContributorListJson>("ContributorList")?.usernames?.let { - contributors = it - } + contributors = event.getConstant<ContributorListJson>("ContributorList").usernames } private fun createCustomName(data: PlayerData): String { @@ -230,4 +228,4 @@ object AdvancedPlayerList { MAGE(" §5ቾ"), NONE("") } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 5906d136a..9202be686 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -42,7 +42,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - repoData = event.getConstant("CrimsonIsleReputation") ?: return + repoData = event.getConstant("CrimsonIsleReputation") tryLoadConfig() update() @@ -165,4 +165,4 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { 1 -> config.hotkey.isKeyHeld() else -> false } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt index f7acdfd1d..ec503bcfd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt @@ -12,7 +12,12 @@ import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase import at.hannibal2.skyhanni.utils.jsonobjects.DanceRoomInstructionsJson -import kotlinx.coroutines.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -160,9 +165,7 @@ object DanceRoomHelper { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant<DanceRoomInstructionsJson>("DanceRoomInstructions")?.let { - instructions = it.instructions - } + instructions = event.getConstant<DanceRoomInstructionsJson>("DanceRoomInstructions").instructions } fun start(interval: Long): Job { @@ -176,4 +179,4 @@ object DanceRoomHelper { } fun isEnabled() = RiftAPI.inRift() && config.enabled -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt index 28ae5b5fa..12bebc3ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt @@ -18,7 +18,7 @@ class RiftLavaMazeParkour { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<ParkourJson>("RiftLavaMazeParkour") ?: return + val data = event.getConstant<ParkourJson>("RiftLavaMazeParkour") parkourHelper = ParkourHelper( data.locations, data.shortCuts, diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt index e8aa8b00f..136c956cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt @@ -18,7 +18,7 @@ class RiftUpsideDownParkour { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<ParkourJson>("RiftUpsideDownParkour") ?: return + val data = event.getConstant<ParkourJson>("RiftUpsideDownParkour") parkourHelper = ParkourHelper( data.locations.map { it.add(-1.0, -1.0, -1.0) },// TODO remove offset. change repo instead data.shortCuts, diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt index 2f3b2bc82..fcd880b3d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt @@ -20,7 +20,7 @@ class TubulatorParkour { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<ParkourJson>("RiftTubulator") ?: return + val data = event.getConstant<ParkourJson>("RiftTubulator") parkourHelper = ParkourHelper( data.locations, data.shortCuts, diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt index f4fd7415d..b2691210e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt @@ -50,12 +50,11 @@ class RiftBloodEffigies { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant<RiftEffigiesJson>("RiftEffigies")?.locations?.let { - if (it.size != 6) { - error("Invalid rift effigies size: ${it.size} (expeced 6)") - } - locations = it + val newLocations = event.getConstant<RiftEffigiesJson>("RiftEffigies").locations + if (newLocations.size != 6) { + error("Invalid rift effigies size: ${newLocations.size} (expeced 6)") } + locations = newLocations } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index 292b71539..e58215a68 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -144,7 +144,7 @@ object EnigmaSoulWaypoints { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<EnigmaSoulsJson>("EnigmaSouls") ?: return + val data = event.getConstant<EnigmaSoulsJson>("EnigmaSouls") val areas = data.areas ?: error("'areas' is null in EnigmaSouls!") soulLocations = buildMap { for ((area, locations) in areas) { @@ -181,4 +181,4 @@ object EnigmaSoulWaypoints { } fun isEnabled() = RiftAPI.inRift() && config.enabled -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt index 00d4ad0d2..67b5f595f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt @@ -67,8 +67,7 @@ object SlayerItemProfitTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val items = event.getConstant<SlayerProfitTrackerItemsJson>("SlayerProfitTrackerItems") ?: return - allowedItems = items.slayers + allowedItems = event.getConstant<SlayerProfitTrackerItemsJson>("SlayerProfitTrackerItems").slayers } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/AccessorEventBus.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/AccessorEventBus.java new file mode 100644 index 000000000..053b585c6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/AccessorEventBus.java @@ -0,0 +1,12 @@ +package at.hannibal2.skyhanni.mixins.transformers; + +import net.minecraftforge.fml.common.eventhandler.EventBus; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(EventBus.class) +public interface AccessorEventBus { + + @Accessor("busID") + int getBusId(); +} diff --git a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt index 06983d328..00ea73570 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt @@ -53,13 +53,12 @@ class HighlightMissingRepoItems { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - event.getConstant("IgnoredItems")?.let { - ignoreItems.load(it.asJsonObject) - } + val ignoredItems = event.getConstant("IgnoredItems") + ignoreItems.load(ignoredItems.asJsonObject) } @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "dev.highlightMissingRepo", "dev.debug.highlightMissingRepo") } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index c0d3fd169..7db251300 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -17,6 +17,10 @@ object ErrorManager { private var cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build<Pair<String, Int>, Unit>() + fun resetCache() { + cache.asMap().clear() + } + fun skyHanniError(message: String): Nothing { val exception = IllegalStateException(message) logError(exception, message) |