diff options
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 import at.hannibal2.skyhanni.data.repo.RepoUtils import com.google.gson.Gson -import com.google.gson.JsonObject import java.io.File 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): T = try { + RepoManager.setlastConstant(constant) if (!repoLocation.exists()) throw RepoError("Repo folder does not exist!") RepoUtils.getConstant(repoLocation, constant, gson, T::class.java, type) } catch (e: Exception) { 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 6de251af5..e4db8ee3b 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 @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.chat.playerchat import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MultiFilter +import at.hannibal2.skyhanni.utils.jsonobjects.PlayerChatFilterJson import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PlayerChatFilter { @@ -29,18 +30,16 @@ class PlayerChatFilter { var countCategories = 0 var countFilters = 0 - val data = event.getConstant("PlayerChatFilter") - for (category in data["filters"].asJsonArray) { - val jsonObject = category.asJsonObject - val description = jsonObject["description"].asString + val data = event.getConstant<PlayerChatFilterJson>("PlayerChatFilter") + for (category in data.filters) { + val description = category.description val filter = MultiFilter() - filter.load(jsonObject) + filter.load(category) filters[description] = filter countCategories++ countFilters += filter.count() } - LorenzUtils.debug("Loaded $countFilters filters in $countCategories categories from repo") } } 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 2c1c339dc..97a110508 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 @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.jsonobjects.SackListJson +import at.hannibal2.skyhanni.utils.jsonobjects.SacksJson import net.minecraft.network.play.client.C01PacketChatMessage import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -15,7 +15,7 @@ object GetFromSacksTabComplete { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - sackList = event.getConstant<SackListJson>("Sacks").sackList + sackList = event.getConstant<SacksJson>("Sacks").sackList } fun handleTabComplete(command: String): List<String>? { diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt index 96bfeb83a..688d6f6b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt @@ -13,11 +13,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object PlayerTabComplete { private val config get() = SkyHanniMod.feature.commands.tabComplete - private var vipVisitsJson: VipVisitsJson? = null + private var vipVisits = listOf<String>() @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - vipVisitsJson = event.getConstant<VipVisitsJson>("VipVisits") + val data = event.getConstant<VipVisitsJson>("VipVisits") + vipVisits = data.vipVisits } @SubscribeEvent @@ -75,12 +76,10 @@ object PlayerTabComplete { } if (config.vipVisits && command == "visit") { - vipVisitsJson?.let { - for (visit in it.vipVisits) { - add(visit) - } + for (visit in vipVisits) { + add(visit) } } } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt index 4120ebd9d..ea76e03ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt @@ -8,19 +8,20 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object WarpTabComplete { private val config get() = SkyHanniMod.feature.commands.tabComplete - private var warpsJson: WarpsJson? = null + private var warps = listOf<String>() @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - warpsJson = event.getConstant<WarpsJson>("Warps") + val data = event.getConstant<WarpsJson>("Warps") + warps = data.warpCommands } fun handleTabComplete(command: String): List<String>? { if (!isEnabled()) return null if (command != "warp") return null - return warpsJson?.warpCommands + return warps } fun isEnabled() = LorenzUtils.inSkyBlock && config.warps -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt index 0ae437db7..2775becc7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.fishing.trophy import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFilletValue import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils @@ -13,7 +14,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard class TrophyFishFillet { - @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return @@ -36,5 +36,4 @@ class TrophyFishFillet { } private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.fishing.trophyFishing.filletTooltip - -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishInfo.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishInfo.kt deleted file mode 100644 index aba9f5c5f..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishInfo.kt +++ /dev/null @@ -1,54 +0,0 @@ -package at.hannibal2.skyhanni.features.fishing.trophy - -import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.StringUtils.splitLines -import com.google.gson.annotations.Expose -import net.minecraft.event.HoverEvent -import net.minecraft.util.ChatComponentText -import net.minecraft.util.ChatStyle - -data class TrophyFishInfo( - @Expose - val displayName: String, - @Expose - private val description: String, - @Expose - private val rate: Int?, - @Expose - private val fillet: Map<TrophyRarity, Int> -) { - - // Credit to NotEnoughUpdates (Trophy Fish profile viewer page) for the format. - fun getTooltip(counts: Map<TrophyRarity, Int>): ChatStyle { - val bestFishObtained = counts.keys.maxOrNull() ?: TrophyRarity.BRONZE - val rateString = if (rate != null) "§8[§7$rate%§8]" else "" - val display = """ - |$displayName $rateString - |${description.splitLines(150)} - | - |${TrophyRarity.DIAMOND.formattedString}: ${formatCount(counts, TrophyRarity.DIAMOND)} - |${TrophyRarity.GOLD.formattedString}: ${formatCount(counts, TrophyRarity.GOLD)} - |${TrophyRarity.SILVER.formattedString}: ${formatCount(counts, TrophyRarity.SILVER)} - |${TrophyRarity.BRONZE.formattedString}: ${formatCount(counts, TrophyRarity.BRONZE)} - | - |§7Total: ${bestFishObtained.formatCode}${counts.values.sum().addSeparators()} - """.trimMargin() - return ChatStyle().setChatHoverEvent( - HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText(display)) - ) - } - - fun getFilletValue(rarity: TrophyRarity): Int { - if (fillet == null) { - ErrorManager.logError(Error("fillet is null for '$displayName'"), "Error trying to read trophy fish info") - return -1 - } - return fillet.getOrDefault(rarity, -1) - } - - private fun formatCount(counts: Map<TrophyRarity, Int>, rarity: TrophyRarity): String { - val count = counts.getOrDefault(rarity, 0) - return if (count > 0) "§6${count.addSeparators()}" else "§c✖" - } -}
\ 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 4d8b547a4..6617b31b2 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 @@ -2,27 +2,62 @@ package at.hannibal2.skyhanni.features.fishing.trophy import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.StringUtils.splitLines import at.hannibal2.skyhanni.utils.jsonobjects.TrophyFishJson +import at.hannibal2.skyhanni.utils.jsonobjects.TrophyFishJson.TrophyFishInfo +import net.minecraft.event.HoverEvent +import net.minecraft.util.ChatComponentText +import net.minecraft.util.ChatStyle import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TrophyFishManager { +object TrophyFishManager { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val json = event.getConstant<TrophyFishJson>("TrophyFish") - trophyFishInfo = json.trophy_fish - LorenzUtils.debug("Loaded trophy fish from repo") + val data = event.getConstant<TrophyFishJson>("TrophyFish") + trophyFishInfo = data.trophy_fish } - companion object { - val fishes: MutableMap<String, MutableMap<TrophyRarity, Int>>? - get() = ProfileStorageData.profileSpecific?.crimsonIsle?.trophyFishes + val fishes: MutableMap<String, MutableMap<TrophyRarity, Int>>? + get() = ProfileStorageData.profileSpecific?.crimsonIsle?.trophyFishes - private var trophyFishInfo = mapOf<String, TrophyFishInfo>() + private var trophyFishInfo = mapOf<String, TrophyFishInfo>() - fun getInfo(internalName: String) = trophyFishInfo[internalName] + fun getInfo(internalName: String) = trophyFishInfo[internalName] - fun getInfoByName(name: String) = trophyFishInfo.values.find { it.displayName == name } + fun getInfoByName(name: String) = trophyFishInfo.values.find { it.displayName == name } + + private fun formatCount(counts: Map<TrophyRarity, Int>, rarity: TrophyRarity): String { + val count = counts.getOrDefault(rarity, 0) + return if (count > 0) "§6${count.addSeparators()}" else "§c✖" + } + + fun TrophyFishInfo.getFilletValue(rarity: TrophyRarity): Int { + if (fillet == null) { + ErrorManager.logError(Error("fillet is null for '$displayName'"), "Error trying to read trophy fish info") + return -1 + } + return fillet.getOrDefault(rarity, -1) + } + + fun TrophyFishInfo.getTooltip(counts: Map<TrophyRarity, Int>): ChatStyle { + val bestFishObtained = counts.keys.maxOrNull() ?: TrophyRarity.BRONZE + val rateString = if (rate != null) "§8[§7$rate%§8]" else "" + val display = """ + |$displayName $rateString + |${description.splitLines(150)} + | + |${TrophyRarity.DIAMOND.formattedString}: ${formatCount(counts, TrophyRarity.DIAMOND)} + |${TrophyRarity.GOLD.formattedString}: ${formatCount(counts, TrophyRarity.GOLD)} + |${TrophyRarity.SILVER.formattedString}: ${formatCount(counts, TrophyRarity.SILVER)} + |${TrophyRarity.BRONZE.formattedString}: ${formatCount(counts, TrophyRarity.BRONZE)} + | + |§7Total: ${bestFishObtained.formatCode}${counts.values.sum().addSeparators()} + """.trimMargin() + return ChatStyle().setChatHoverEvent( + HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText(display)) + ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt index e6087a5b5..7723617a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt @@ -3,12 +3,14 @@ package at.hannibal2.skyhanni.features.fishing.trophy import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.Companion.fishes +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.fishes +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getTooltip import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut import at.hannibal2.skyhanni.utils.LorenzUtils.sumAllValues import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.ordinal +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.util.ChatComponentText @@ -16,16 +18,19 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class TrophyFishMessages { private val trophyFishPattern = - Regex("§6§lTROPHY FISH! §r§bYou caught an? §r(?<displayName>§[0-9a-f](?:§k)?[\\w -]+)§r§r§r §r§l§r(?<displayRarity>§[0-9a-f]§l\\w+)§r§b\\.") + "§6§lTROPHY FISH! §r§bYou caught an? §r(?<displayName>§[0-9a-f](?:§k)?[\\w -]+)§r§r§r §r§l§r(?<displayRarity>§[0-9a-f]§l\\w+)§r§b\\.".toPattern() private val config get() = SkyHanniMod.feature.fishing.trophyFishing.chatMessages @SubscribeEvent fun onStatusBar(event: LorenzChatEvent) { if (!LorenzUtils.inSkyBlock) return + var displayName = "" + var displayRarity = "" - val match = trophyFishPattern.matchEntire(event.message)?.groups ?: return - val displayName = match["displayName"]!!.value.replace("§k", "") - val displayRarity = match["displayRarity"]!!.value + trophyFishPattern.matchMatcher(event.message) { + displayName = group("displayName").replace("§k", "") + displayRarity = group("displayRarity") + } ?: return val internalName = displayName.replace("Obfuscated", "Obfuscated Fish") .replace("[- ]".toRegex(), "").lowercase().removeColor() 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 05b78d047..d114d2455 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.BlockClickEvent @@ -20,6 +21,7 @@ import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice +import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop import at.hannibal2.skyhanni.utils.InventoryUtils @@ -248,5 +250,5 @@ object GardenAPI { } private var gardenExperience = listOf<Int>() - private const val gardenOverflowExp = 10000 // can be changed I guess + private const val gardenOverflowExp = 10000 } 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 8b0b3d70d..88695da9a 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 @@ -47,9 +47,10 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlin.time.DurationUnit -class ComposterOverlay { +object ComposterOverlay { private var organicMatterFactors: Map<String, Double> = emptyMap() private var fuelFactors: Map<String, Double> = emptyMap() + private var organicMatter: Map<String, Double> = emptyMap() private val config get() = SkyHanniMod.feature.garden.composters private var organicMatterDisplay = emptyList<List<Any>>() @@ -68,34 +69,31 @@ class ComposterOverlay { private var lastHovered = 0L private var lastAttemptTime = SimpleTimeMark.farPast() - companion object { - var currentOrganicMatterItem: String? - get() = GardenAPI.config?.composterCurrentOrganicMatterItem - private set(value) { - GardenAPI.config?.composterCurrentOrganicMatterItem = value - } + var inInventory = false - var currentFuelItem: String? - get() = GardenAPI.config?.composterCurrentFuelItem - private set(value) { - GardenAPI.config?.composterCurrentFuelItem = value - } + private var testOffset = 0 - var testOffset = 0 + var currentOrganicMatterItem: String? + get() = GardenAPI.config?.composterCurrentOrganicMatterItem + private set(value) { + GardenAPI.config?.composterCurrentOrganicMatterItem = value + } - fun onCommand(args: Array<String>) { - if (args.size != 1) { - LorenzUtils.chat("§cUsage: /shtestcomposter <offset>") - return - } - testOffset = args[0].toInt() - LorenzUtils.chat("§e[SkyHanni] Composter test offset set to $testOffset.") + var currentFuelItem: String? + get() = GardenAPI.config?.composterCurrentFuelItem + private set(value) { + GardenAPI.config?.composterCurrentFuelItem = value } - var inInventory = false + fun onCommand(args: Array<String>) { + if (args.size != 1) { + LorenzUtils.chat("§cUsage: /shtestcomposter <offset>") + return + } + testOffset = args[0].toInt() + LorenzUtils.chat("§e[SkyHanni] Composter test offset set to $testOffset.") } - var garden: GardenJson? = null @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { @@ -331,6 +329,7 @@ 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]!! @@ -358,6 +357,7 @@ 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 = @@ -460,8 +460,7 @@ 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" @@ -506,14 +505,19 @@ class ComposterOverlay { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - garden = event.getConstant<GardenJson>("Garden") + val data = event.getConstant<GardenJson>("Garden") + organicMatter = data.organic_matter + fuelFactors = data.fuel updateOrganicMatterFactors() } private fun updateOrganicMatterFactors() { - val garden = this.garden ?: return - organicMatterFactors = updateOrganicMatterFactors(garden.organic_matter) - fuelFactors = garden.fuel + try { + organicMatterFactors = updateOrganicMatterFactors(organicMatter) + } catch (e: Exception) { + e.printStackTrace() + LorenzUtils.error("error in RepositoryReloadEvent") + } } private fun updateOrganicMatterFactors(baseValues: Map<String, Double>): Map<String, Double> { 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 fc68546e8..8092ff476 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 @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.jsonobjects.ArmorDropsJson +import at.hannibal2.skyhanni.utils.jsonobjects.ArmorDropsJson.DropInfo import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -111,7 +112,7 @@ class FarmingArmorDrops { } companion object { - var armorDropInfo = mapOf<String, ArmorDropsJson.DropInfo>() + var armorDropInfo = mapOf<String, DropInfo>() private var currentArmorDropChance = 0.0 private var lastCalculationTime = SimpleTimeMark.farPast() 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 0d9e4409f..a9a2066bd 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 @@ -15,7 +15,8 @@ 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.editCopy -import com.google.gson.JsonObject +import at.hannibal2.skyhanni.utils.jsonobjects.DicerDropsJson +import at.hannibal2.skyhanni.utils.jsonobjects.DicerDropsJson.DicerType import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer @@ -129,31 +130,28 @@ object GardenCropSpeed { } } - private fun calculateAverageDicer(dicerList: MutableList<Double>, dropsJson: JsonObject) { + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<DicerDropsJson>("DicerDrops") + calculateAverageDicer(melonDicer, data.MELON) + calculateAverageDicer(pumpkinDicer, data.PUMPKIN) + } + + private fun calculateAverageDicer(dicerList: MutableList<Double>, data: DicerType) { dicerList.clear() - val totalChance = dropsJson["total chance"].asDouble - val dropTypes = dropsJson["drops"].asJsonArray - for (dropType in dropTypes) { - val dropJson = dropType.asJsonObject - val chance = (dropJson["chance"].asDouble / totalChance) - dropJson["amount"].asJsonArray.forEachIndexed { index, element -> - val amount = element.asInt * chance + for (dropType in data.drops) { + val chance = dropType.chance / data.totalChance.toDouble() + for ((index, amount) in dropType.amount.withIndex()) { + val dropAmount = amount * chance if (index < dicerList.size) { - dicerList[index] += amount + dicerList[index] += dropAmount } else { - dicerList.add(amount) + dicerList.add(dropAmount) } } } } - @SubscribeEvent - fun onRepoReload(event: RepositoryReloadEvent) { - val dicerJson = event.getConstant("DicerDrops") - calculateAverageDicer(melonDicer, dicerJson["MELON"].asJsonObject) - calculateAverageDicer(pumpkinDicer, dicerJson["PUMPKIN"].asJsonObject) - } - fun getRecentBPS(): Double { val size = blocksSpeedList.size return if (size <= 1) { @@ -192,6 +190,5 @@ object GardenCropSpeed { @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "garden.blocksBrokenResetTime", "garden.cropMilestones.blocksBrokenResetTime") - } } 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 0a3eabf86..904ec9bb4 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 @@ -13,12 +13,13 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.jsonobjects.AnitaUpgradeCostsJson +import at.hannibal2.skyhanni.utils.jsonobjects.AnitaUpgradeCostsJson.Price import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AnitaExtraFarmingFortune { private val config get() = SkyHanniMod.feature.garden.anitaShop - private var levelPrice = emptyMap<Int, AnitaUpgradeCostsJson.Price>() + private var levelPrice = mapOf<Int, Price>() @SubscribeEvent fun onItemTooltipLow(event: ItemTooltipEvent) { @@ -71,12 +72,8 @@ class AnitaExtraFarmingFortune { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - 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 + val data = event.getConstant<AnitaUpgradeCostsJson>("AnitaUpgradeCosts") + levelPrice = data.level_price } @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 84e8f17d3..16efb90b1 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 @@ -3,36 +3,30 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.jsonobjects.GardenJson import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenVisitorColorNames { +object GardenVisitorColorNames { + private var visitorColours = mutableMapOf<String, String>() + var visitorItems = mutableMapOf<String, List<String>>() @SubscribeEvent fun onRepoReload(event: 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 } + val data = event.getConstant<GardenJson>("Garden") + visitorColours.clear() + visitorItems.clear() + for ((visitor, visitorData) in data.visitors) { + visitorColours[visitor] = getColor(visitorData.rarity) + visitorItems[visitor] = visitorData.need_items } - visitorColor = mapColor - visitorItems = mapItems } - companion object { - private var visitorColor = mapOf<String, String>() // name -> color code - var visitorItems = mapOf<String, List<String>>() + fun getColoredName(name: String): String { + if (!SkyHanniMod.feature.garden.visitors.coloredName) return name - fun getColoredName(name: String): String { - if (!SkyHanniMod.feature.garden.visitors.coloredName) return name - - val cleanName = name.removeColor() - val color = visitorColor[cleanName] ?: return name - return color + cleanName - } + val cleanName = name.removeColor() + val color = visitorColours[cleanName] ?: return name + return color + cleanName } private fun getColor(rarity: String) = when (rarity) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 37a1ff142..f77a27107 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent -import at.hannibal2.skyhanni.events.TabListLineRenderEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptedEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent @@ -404,18 +403,6 @@ class GardenVisitorFeatures { } @SubscribeEvent - fun onTabListText(event: TabListLineRenderEvent) { - if (!GardenAPI.inGarden()) return - if (!config.coloredName) return - val text = event.text - val replace = VisitorAPI.fromHypixelName(text) - val visitor = VisitorAPI.getVisitor(replace) - visitor?.let { - event.text = " " + GardenVisitorColorNames.getColoredName(it.visitorName) - } - } - - @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { if (config.hypixelArrivedMessage && newVisitorArrivedMessage.matcher(event.message).matches()) { event.blockedReason = "new_visitor_arrived" 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 0e8a9fe0b..ddb4645d6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -27,7 +27,9 @@ import at.hannibal2.skyhanni.utils.MultiFilter import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRiftExportable import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRiftTransferable import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import com.google.gson.JsonObject +import at.hannibal2.skyhanni.utils.jsonobjects.HideNotClickableItemsJson +import at.hannibal2.skyhanni.utils.jsonobjects.HideNotClickableItemsJson.SalvageFilter +import at.hannibal2.skyhanni.utils.jsonobjects.MultiFilterJson import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest @@ -54,21 +56,22 @@ class HideNotClickableItems { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - 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) + val data = event.getConstant<MultiFilterJson>("TradeNpcs") + tradeNpcFilter.load(data) + + val hideNotClickable = event.getConstant<HideNotClickableItemsJson>("HideNotClickableItems") + hideNpcSellFilter.load(hideNotClickable.hide_npc_sell) + hideInStorageFilter.load(hideNotClickable.hide_in_storage) + hidePlayerTradeFilter.load(hideNotClickable.hide_player_trade) + notAuctionableFilter.load(hideNotClickable.not_auctionable) + updateSalvageList(hideNotClickable.salvage) } - private fun updateSalvageList(hideNotClickableItems: JsonObject) { + private fun updateSalvageList(data: SalvageFilter) { itemsToSalvage.clear() - val salvage = hideNotClickableItems["salvage"].asJsonObject - itemsToSalvage.addAll(salvage.asJsonObject["items"].asJsonArray.map { it.asString }) - for (armor in salvage.asJsonObject["armor"].asJsonArray.map { it.asString }) { + + itemsToSalvage.addAll(data.items) + for (armor in data.armor) { itemsToSalvage.add("$armor Helmet") itemsToSalvage.add("$armor Chestplate") itemsToSalvage.add("$armor Leggings") @@ -128,7 +131,7 @@ class HideNotClickableItems { } else { event.toolTip.add("§c$hideReason") if (config.itemsBypass) { - event.toolTip.add(" §7(Disable with holding the control key)") + event.toolTip.add(" §7(Bypass by holding the control key)") } } } 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 1e43944f3..f8dd111b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.jsonobjects.ItemsJson import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -39,17 +40,12 @@ class ItemStars { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val items = event.getConstant("Items") - if (items.has("crimson_armors")) { - armorNames.clear() - armorNames.addAll(items.getAsJsonArray("crimson_armors").map { it.asString }) - } - + val data = event.getConstant<ItemsJson>("Items") + armorNames.clear() tiers.clear() - if (items.has("crimson_tiers")) { - items.getAsJsonObject("crimson_tiers").entrySet().forEach { - tiers[it.key] = it.value.asInt - } + armorNames.addAll(data.crimson_armors) + for (tier in data.crimson_tiers) { + tiers[tier.key] = tier.value } } 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 69991dc76..2890e8593 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.jsonobjects.ModsJson +import at.hannibal2.skyhanni.utils.jsonobjects.ModGuiSwitcherJson import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager @@ -28,7 +28,7 @@ object QuickModMenuSwitch { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val modsJar = event.getConstant<ModsJson>("ModGuiSwitcher") + val modsJar = event.getConstant<ModGuiSwitcherJson>("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/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 9202be686..7e9690a2e 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 @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra.DailyKuudraBossHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper +import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.QuestLoader import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMiniBossHelper import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils @@ -17,7 +18,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.TabListData -import com.google.gson.JsonObject +import at.hannibal2.skyhanni.utils.jsonobjects.CrimsonIsleReputationJson import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -28,7 +29,6 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { val miniBossHelper = DailyMiniBossHelper(this) val kuudraBossHelper = DailyKuudraBossHelper(this) - var repoData: JsonObject? = null var factionType = FactionType.NONE private var display = emptyList<List<Any>>() @@ -42,21 +42,24 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - repoData = event.getConstant("CrimsonIsleReputation") + val data = event.getConstant<CrimsonIsleReputationJson>("CrimsonIsleReputation") + miniBossHelper.onRepoReload(data.MINIBOSS) + kuudraBossHelper.onRepoReload(data.KUUDRA) + + QuestLoader.quests.clear() + QuestLoader.loadQuests(data.FISHING, "FISHING") + QuestLoader.loadQuests(data.RESCUE, "RESCUE") + QuestLoader.loadQuests(data.FETCH, "FETCH") + QuestLoader.loadQuests(data.DOJO, "DOJO") - tryLoadConfig() update() } @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { - tryLoadConfig() - } - - private fun tryLoadConfig() { ProfileStorageData.profileSpecific?.crimsonIsle?.let { - miniBossHelper.load(it) - kuudraBossHelper.load(it) + miniBossHelper.loadData(it) + kuudraBossHelper.loadData(it) questHelper.load(it) } } @@ -150,14 +153,9 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { update() } - fun readLocationData(data: JsonObject): LorenzVec? { - val locationData = data["location"]?.asJsonArray ?: return null - if (locationData.size() == 0) return null - - val x = locationData[0].asDouble - 1 - val y = locationData[1].asDouble - val z = locationData[2].asDouble - 1 - return LorenzVec(x, y, z) + fun readLocationData(locations: List<Double>): LorenzVec? { + if (locations.isEmpty()) return null + return LorenzVec(locations[0] - 1, locations[1], locations[2] - 1) } fun showLocations() = when (config.showLocation) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt index 34ba68f38..39e888ade 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailykuudra/DailyKuudraBossHelper.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.jsonobjects.CrimsonIsleReputationJson.ReputationQuest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { @@ -98,26 +99,23 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH .forEach { storage.kuudraTiersDone.add(it.name) } } - fun load(storage: Storage.ProfileSpecific.CrimsonIsleStorage) { + fun onRepoReload(data: Map<String, ReputationQuest>) { kuudraTiers.clear() - - //Repo - val repoData = reputationHelper.repoData ?: return - val jsonElement = repoData["KUUDRA"] var tier = 1 - for ((displayName, extraData) in jsonElement.asJsonObject.entrySet()) { - val data = extraData.asJsonObject - val displayItem = data["item"]?.asString - val location = reputationHelper.readLocationData(data) - kuudraTiers.add(KuudraTier(displayName, displayItem, location, tier)) + for ((displayName, kuudraTier) in data) { + val displayItem = kuudraTier.item + val location = reputationHelper.readLocationData(kuudraTier.location) if (location != null) { kuudraLocation = location } + kuudraTiers.add(KuudraTier(displayName, displayItem, location, tier)) tier++ } + } - //Config + fun loadData(storage: Storage.ProfileSpecific.CrimsonIsleStorage) { + if (kuudraTiers.isEmpty()) return for (name in storage.kuudraTiersDone) { getByDisplayName(name)!!.doneToday = true } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index 846cc12e1..37b26dce3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -312,9 +312,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { fun load(storage: Storage.ProfileSpecific.CrimsonIsleStorage) { reset() - questLoader.loadConfig(storage) - } fun saveConfig(storage: Storage.ProfileSpecific.CrimsonIsleStorage) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index b7c4c2cbf..a35510196 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -15,9 +15,19 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.U import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.TabListData +import at.hannibal2.skyhanni.utils.jsonobjects.CrimsonIsleReputationJson.ReputationQuest class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) { + companion object { + val quests = mutableMapOf<String, Pair<String,ReputationQuest>>() + fun loadQuests(data: Map<String, ReputationQuest>, questType: String) { + for ((questName, questInfo) in data) { + quests[questName] = Pair(questType, questInfo) + } + } + } + fun loadFromTabList() { var i = -1 for (line in TabListData.getTabList()) { @@ -83,29 +93,26 @@ class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) { return KuudraQuest(kuudraTier, state) } } + var questName = name + var dojoGoal = "" - val repoData = dailyQuestHelper.reputationHelper.repoData ?: return UnknownQuest(name) - for (entry in repoData.entrySet()) { - val categoryName = entry.key - val category = entry.value.asJsonObject - for ((entryName, extraData) in category.entrySet()) { - val data = extraData.asJsonObject - val displayItem = data["item"]?.asString - val location = dailyQuestHelper.reputationHelper.readLocationData(data) - if (name.startsWith("$entryName Rank ")) { - val split = name.split(" Rank ") - val dojoName = split[0] - val dojoRankGoal = split[1] - return DojoQuest(dojoName, location, displayItem, dojoRankGoal, state) - } + if (name.contains(" Rank ")) { + val split = name.split(" Rank ") + questName = split[0] + dojoGoal = split[1] + } - if (name == entryName) { - when (categoryName) { - "FISHING" -> return TrophyFishQuest(name, location, displayItem, state, needAmount) - "RESCUE" -> return RescueMissionQuest(displayItem, location, state) - "FETCH" -> return FetchQuest(name, location, displayItem, state, needAmount) - } - } + if (questName in quests) { + val questInfo = quests[questName] ?: return UnknownQuest(name) + val locationInfo = questInfo.second.location + val location = dailyQuestHelper.reputationHelper.readLocationData(locationInfo) + val displayItem = questInfo.second.item + + when (questInfo.first) { + "FISHING" -> return TrophyFishQuest(name, location, displayItem, state, needAmount) + "RESCUE" -> return RescueMissionQuest(displayItem, location, state) + "FETCH" -> return FetchQuest(name, location, displayItem, state, needAmount) + "DOJO" -> return DojoQuest(questName, location, displayItem, dojoGoal, state) } } LorenzUtils.chat("§c[SkyHanni] Unknown Crimson Isle quest: '$name'") diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index 1e1bf98e7..10eae5816 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.jsonobjects.CrimsonIsleReputationJson.ReputationQuest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) { @@ -104,21 +105,18 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel .forEach { storage.miniBossesDoneToday.add(it.displayName) } } - fun load(storage: Storage.ProfileSpecific.CrimsonIsleStorage) { + fun onRepoReload(data: Map<String, ReputationQuest>) { miniBosses.clear() - - //Repo - val repoData = reputationHelper.repoData ?: return - val jsonElement = repoData["MINIBOSS"] - for ((displayName, extraData) in jsonElement.asJsonObject.entrySet()) { - val data = extraData.asJsonObject - val displayItem = data["item"]?.asString - val patterns = " *§r§6§l${displayName.uppercase()} DOWN!".toPattern() - val location = reputationHelper.readLocationData(data) - miniBosses.add(CrimsonMiniBoss(displayName, displayItem, location, patterns)) + for ((displayName, quest) in data) { + val displayItem = quest.item + val pattern = " *§r§6§l${displayName.uppercase()} DOWN!".toPattern() + val location = reputationHelper.readLocationData(quest.location) + miniBosses.add(CrimsonMiniBoss(displayName, displayItem, location, pattern)) } + } - //Config + fun loadData(storage: Storage.ProfileSpecific.CrimsonIsleStorage) { + if (miniBosses.isEmpty()) return for (name in storage.miniBossesDoneToday) { getByDisplayName(name)!!.doneToday = true } 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 b2691210e..90e6c32ba 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 @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.rift.area.stillgorechateau +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent @@ -94,7 +95,7 @@ class RiftBloodEffigies { for (entity in EntityUtils.getEntitiesNearby<EntityArmorStand>(LocationUtils.playerLocation(), 6.0)) { effigiesTimerPattern.matchMatcher(entity.name) { - val nearest = locations.sortedBy { it.distanceSq(entity.getLorenzVec()) }.firstOrNull() ?: return + val nearest = locations.minByOrNull { it.distanceSq(entity.getLorenzVec()) } ?: return val index = locations.indexOf(nearest) val string = group("time") diff --git a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt index 00ea73570..28e657c1e 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MultiFilter import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.jsonobjects.MultiFilterJson import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.client.gui.inventory.GuiInventory @@ -53,8 +54,8 @@ class HighlightMissingRepoItems { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val ignoredItems = event.getConstant("IgnoredItems") - ignoreItems.load(ignoredItems.asJsonObject) + val ignoredItems = event.getConstant<MultiFilterJson>("IgnoredItems") + ignoreItems.load(ignoredItems) } @SubscribeEvent 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 84b180cd8..adf8d2637 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -58,8 +58,8 @@ object ErrorManager { fun logError(throwable: Throwable, message: String, ignoreErrorCache: Boolean) { val error = Error(message, throwable) - Minecraft.getMinecraft().thePlayer ?: throw error error.printStackTrace() + Minecraft.getMinecraft().thePlayer ?: return if (!ignoreErrorCache) { val pair = if (throwable.stackTrace.isNotEmpty()) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt b/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt index c8ecc2055..ab9817ef4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils -import com.google.gson.JsonObject +import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpace +import at.hannibal2.skyhanni.utils.jsonobjects.MultiFilterJson class MultiFilter { @@ -10,25 +11,23 @@ class MultiFilter { private val contains = mutableListOf<String>() private val containsWord = mutableListOf<String>() - fun load(hideNpcSell: JsonObject) { + fun load(data: MultiFilterJson) { equals.clear() startsWith.clear() endsWith.clear() contains.clear() containsWord.clear() - fill(hideNpcSell, "equals", equals) - fill(hideNpcSell, "exact", equals) - fill(hideNpcSell, "startsWith", startsWith) - fill(hideNpcSell, "endsWith", endsWith) - fill(hideNpcSell, "contains", contains) - fill(hideNpcSell, "containsWord", containsWord) + fill(equals, data.equals) + fill(startsWith, data.startsWith) + fill(endsWith, data.endsWith) + fill(contains, data.contains) + fill(containsWord, data.containsWord) } - private fun fill(jsonObject: JsonObject, key: String, list: MutableList<String>) { - if (jsonObject.has(key)) { - list.addAll(jsonObject[key].asJsonArray.map { it.asString }) - } + private fun fill(list: MutableList<String>, data: List<String>?) { + if (data == null) return + list.addAll(data) } fun match(string: String): Boolean { @@ -50,8 +49,9 @@ class MultiFilter { return null } - private fun containsWord(message: String, word: String): Boolean = - message.startsWith("$word ") || message.endsWith(" $word") || message.contains(" $word ") + private fun containsWord(message: String, word: String): Boolean { + return message.split(" ").any { it.trimWhiteSpace() == word } + } fun count(): Int { return equals.size + startsWith.size + endsWith.size + contains.size + containsWord.size diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt index 416b7dfd3..c9903ffc2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt @@ -11,14 +11,14 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea import at.hannibal2.skyhanni.utils.RenderUtils.drawString import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock import at.hannibal2.skyhanni.utils.RenderUtils.outlineTopFace -import at.hannibal2.skyhanni.utils.jsonobjects.ParkourJson +import at.hannibal2.skyhanni.utils.jsonobjects.ParkourJson.ShortCut import net.minecraft.client.Minecraft import java.awt.Color import kotlin.time.Duration.Companion.seconds class ParkourHelper( val locations: List<LorenzVec>, - private val shortCuts: List<ParkourJson.ShortCut>, + private val shortCuts: List<ShortCut>, val platformSize: Double = 1.0, val detectionRange: Double = 1.0 ) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 187407cbf..802decbce 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -18,9 +18,11 @@ object StringUtils { private val playerChatPattern = "(?<important>.*?)(?:§[f7r])*: .*".toPattern() private val chatUsernamePattern = "^(?:§\\w\\[§\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?<rankedName>(?:§\\w\\[\\w.+] )?(?:§\\w)?(?<username>\\w+))(?: (?:§\\w)?\\[.+?])?".toPattern() private val whiteSpaceResetPattern = "^(?:\\s|§r)*|(?:\\s|§r)*$".toPattern() + private val whiteSpacePattern = "^\\s*|\\s*$".toPattern() private val resetPattern = "(?i)§R".toPattern() fun String.trimWhiteSpaceAndResets(): String = whiteSpaceResetPattern.matcher(this).replaceAll("") + fun String.trimWhiteSpace(): String = whiteSpacePattern.matcher(this).replaceAll("") fun String.removeResets(): String = resetPattern.matcher(this).replaceAll("") fun String.firstLetterUppercase(): String { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java index c0fbd0ad0..09a2de7db 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/AnitaUpgradeCostsJson.java @@ -6,12 +6,13 @@ import java.util.Map; public class AnitaUpgradeCostsJson { @Expose - public Map<String, Price> level_price; + public Map<Integer, Price> level_price; public static class Price { @Expose public Integer gold_medals; + @Expose public Integer jacob_tickets; } -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ArmorDropsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ArmorDropsJson.java index 747a33a13..698bad3db 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ArmorDropsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ArmorDropsJson.java @@ -12,7 +12,8 @@ public class ArmorDropsJson { public static class DropInfo { @Expose public String armor_type; + @Expose public List<Double> chance; } -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoJson.java index 472993c46..810f6d3ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoJson.java @@ -12,7 +12,8 @@ public class BingoJson { public static class BingoTip { @Expose public String difficulty; + @Expose public List<String> note; } -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanks.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanksJson.java index 6cac52622..49d7e662f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanks.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/BingoRanksJson.java @@ -4,7 +4,7 @@ import com.google.gson.annotations.Expose; import java.util.Map; -public class BingoRanks { +public class BingoRanksJson { @Expose public Map<String, Integer> ranks; -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ContributorListJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ContributorListJson.java index 77e3d639b..6ab663941 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ContributorListJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ContributorListJson.java @@ -2,7 +2,8 @@ package at.hannibal2.skyhanni.utils.jsonobjects; import com.google.gson.annotations.Expose; import java.util.List; + public class ContributorListJson { @Expose public List<String> usernames; -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/CrimsonIsleReputationJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/CrimsonIsleReputationJson.java new file mode 100644 index 000000000..907081611 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/CrimsonIsleReputationJson.java @@ -0,0 +1,34 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.List; +import java.util.Map; + +public class CrimsonIsleReputationJson { + @Expose + public Map<String, ReputationQuest> FISHING; + + @Expose + public Map<String, ReputationQuest> RESCUE; + + @Expose + public Map<String, ReputationQuest> FETCH; + + @Expose + public Map<String, ReputationQuest> DOJO; + + @Expose + public Map<String, ReputationQuest> MINIBOSS; + + @Expose + public Map<String, ReputationQuest> KUUDRA; + + public static class ReputationQuest { + @Expose + public String item; + + @Expose + public List<Double> location; + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DanceRoomInstructionsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DanceRoomInstructionsJson.java index 0f4568bbd..9316d8671 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DanceRoomInstructionsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DanceRoomInstructionsJson.java @@ -7,4 +7,4 @@ import java.util.List; public class DanceRoomInstructionsJson { @Expose public List<String> instructions; -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DicerDropsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DicerDropsJson.java new file mode 100644 index 000000000..996a558ea --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DicerDropsJson.java @@ -0,0 +1,31 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class DicerDropsJson { + @Expose + public DicerType MELON; + + @Expose + public DicerType PUMPKIN; + + public static class DicerType { + @Expose + @SerializedName("total chance") + public Integer totalChance; + + @Expose + public List<DropInfo> drops; + } + + public static class DropInfo { + @Expose + public Integer chance; + + @Expose + public List<Integer> amount; + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DisabledFeaturesJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DisabledFeaturesJson.java new file mode 100644 index 000000000..45abedfa3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/DisabledFeaturesJson.java @@ -0,0 +1,10 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.Map; + +public class DisabledFeaturesJson { + @Expose + public Map<String, Boolean> features; +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/EnigmaSoulsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/EnigmaSoulsJson.java index 41c4451e5..5769520f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/EnigmaSoulsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/EnigmaSoulsJson.java @@ -13,7 +13,8 @@ public class EnigmaSoulsJson { public static class EnigmaPosition { @Expose public String name; + @Expose public LorenzVec position; } -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java index 46fe188b6..87a80d391 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/GardenJson.java @@ -14,8 +14,19 @@ public class GardenJson { public Map<CropType, List<Integer>> crop_milestones; @Expose + public Map<String, GardenVisitor> visitors; + + @Expose public Map<String, Double> organic_matter; @Expose public Map<String, Double> fuel; -} + + public static class GardenVisitor { + @Expose + public String rarity; + + @Expose + public List<String> need_items; + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/HideNotClickableItemsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/HideNotClickableItemsJson.java new file mode 100644 index 000000000..d4ac9c52b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/HideNotClickableItemsJson.java @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +public class HideNotClickableItemsJson { + @Expose + public MultiFilterJson hide_npc_sell; + + @Expose + public MultiFilterJson hide_in_storage; + + @Expose + public MultiFilterJson hide_player_trade; + + @Expose + public MultiFilterJson not_auctionable; + + @Expose + public SalvageFilter salvage; + + public static class SalvageFilter { + @Expose + public List<String> armor; + + @Expose + public List<String> items; + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ItemsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ItemsJson.java new file mode 100644 index 000000000..f37671913 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ItemsJson.java @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.List; +import java.util.Map; + +public class ItemsJson { + @Expose + public List<String> crimson_armors; + + @Expose + public Map<String, Integer> crimson_tiers; +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ModsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ModGuiSwitcherJson.java index 9e04d55c7..078b1f6ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ModsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ModGuiSwitcherJson.java @@ -7,7 +7,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class ModsJson { +public class ModGuiSwitcherJson { @Expose public Map<String, Mod> mods = new HashMap<>(); @@ -22,4 +22,4 @@ public class ModsJson { @Expose public List<String> guiPath = new ArrayList<>(); } -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/MultiFilterJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/MultiFilterJson.java new file mode 100644 index 000000000..8704f91fb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/MultiFilterJson.java @@ -0,0 +1,25 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +public class MultiFilterJson { + @Expose + public List<String> equals; + + @Expose + public List<String> startsWith; + + @Expose + public List<String> endsWith; + + @Expose + public List<String> contains; + + @Expose + public List<String> containsWord; + + @Expose + public String description; +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ParkourJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ParkourJson.java index 71206d18c..5ae2d40ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ParkourJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/ParkourJson.java @@ -9,13 +9,15 @@ import java.util.List; public class ParkourJson { @Expose public List<LorenzVec> locations; + @Expose public List<ShortCut> shortCuts = new ArrayList<>(); public static class ShortCut { @Expose public int from; + @Expose public int to; } -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/PlayerChatFilterJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/PlayerChatFilterJson.java new file mode 100644 index 000000000..a65a2f8a1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/PlayerChatFilterJson.java @@ -0,0 +1,10 @@ +package at.hannibal2.skyhanni.utils.jsonobjects; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +public class PlayerChatFilterJson { + @Expose + public List<MultiFilterJson> filters; +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/RiftEffigiesJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/RiftEffigiesJson.java index 85453a3bf..d914ef934 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/RiftEffigiesJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/RiftEffigiesJson.java @@ -8,4 +8,4 @@ import java.util.List; public class RiftEffigiesJson { @Expose public List<LorenzVec> locations; -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SackListJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SacksJson.java index 11b4f09ed..dfd2103ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SackListJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SacksJson.java @@ -4,7 +4,7 @@ import com.google.gson.annotations.Expose; import java.util.List; -public class SackListJson { +public class SacksJson { @Expose public List<String> sackList; -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SlayerProfitTrackerItemsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SlayerProfitTrackerItemsJson.java index cbb6b2899..377582200 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SlayerProfitTrackerItemsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/SlayerProfitTrackerItemsJson.java @@ -9,4 +9,4 @@ import java.util.Map; public class SlayerProfitTrackerItemsJson { @Expose public Map<String, List<NEUInternalName>> slayers; -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java index 719c0db2d..6303c16be 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/TrophyFishJson.java @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.utils.jsonobjects; -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishInfo; +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; import com.google.gson.annotations.Expose; import java.util.Map; @@ -8,4 +8,18 @@ import java.util.Map; public class TrophyFishJson { @Expose public Map<String, TrophyFishInfo> trophy_fish; -} + + public static class TrophyFishInfo { + @Expose + public String displayName; + + @Expose + public String description; + + @Expose + public Integer rate; + + @Expose + public Map<TrophyRarity, Integer> fillet; + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/VipVisitsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/VipVisitsJson.java index 8f3ffbe0f..c80f4953f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/VipVisitsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/VipVisitsJson.java @@ -7,4 +7,4 @@ import java.util.List; public class VipVisitsJson { @Expose public List<String> vipVisits; -} +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/WarpsJson.java b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/WarpsJson.java index c5b1aa3c4..e09bf3c9d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/WarpsJson.java +++ b/src/main/java/at/hannibal2/skyhanni/utils/jsonobjects/WarpsJson.java @@ -7,4 +7,4 @@ import java.util.List; public class WarpsJson { @Expose public List<String> warpCommands; -} +}
\ No newline at end of file |