Skip to content

Commit

Permalink
repo events
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs committed Jan 7, 2025
1 parent bf4f2fa commit 2fbc41b
Show file tree
Hide file tree
Showing 70 changed files with 88 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.lang.reflect.Method

@SkyHanniModule
Expand Down Expand Up @@ -46,8 +45,8 @@ object SkyHanniEvents {
.addListener(method, instance, options)
}

@SubscribeEvent
fun onRepoLoad(event: RepositoryReloadEvent) {
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<DisabledEventsJson>("DisabledEvents")
disabledHandlers = data.disabledHandlers
disabledHandlerInvokers = data.disabledInvokers
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/data/FameRanks.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.FameRankJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object FameRanks {
Expand All @@ -12,7 +12,7 @@ object FameRanks {

fun getFameRankByNameOrNull(name: String) = fameRanks[name]

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val ranks = event.getConstant<FameRankJson>("FameRank")
fameRanks = ranks.fameRank.values.map { FameRank(it.name, it.fameRequired, it.bitsMultiplier, it.votes) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.SoundUtils.playSound
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object GardenCropMilestones {
Expand Down Expand Up @@ -193,7 +192,7 @@ object GardenCropMilestones {
return (progress - startCrops).toDouble() / (end - startCrops)
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
cropMilestoneData = event.getConstant<GardenJson>("Garden").cropMilestones
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
Expand All @@ -24,7 +25,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import kotlinx.coroutines.launch
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object GardenCropMilestonesCommunityFix {
Expand All @@ -40,7 +40,7 @@ object GardenCropMilestonesCommunityFix {
private var showWrongData = false
private var showWhenAllCorrect = false

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<GardenJson>("Garden")
val map = data.cropMilestoneCommunityHelp
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ object IslandGraphs {
"Glacite Tunnels|Dwarven Base Camp|Great Glacite Lake|Fossil Research Center",
)

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
if (!LorenzUtils.inSkyBlock) return

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.LocationFixJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside
import net.minecraft.util.AxisAlignedBB
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object LocationFixData {
Expand All @@ -16,7 +15,7 @@ object LocationFixData {
private data class LocationFix(val area: AxisAlignedBB, val realLocation: String)

// priority set to low so that IslandType can load their island names from repo earlier
@SubscribeEvent(priority = EventPriority.LOW)
@HandleEvent(priority = HandleEvent.LOW)
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<LocationFixJson>("LocationFix")
locationFixes.clear()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ object MaxwellAPI {
private fun isEnabled() = LorenzUtils.inSkyBlock && !LorenzUtils.isOnAlphaServer && storage != null

// Load powers from repo
@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<MaxwellPowersJson>("MaxwellPowers")
powers = data.powers
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ object QuiverAPI {
}

// Load arrows from repo
@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val arrowData = event.getConstant<ArrowTypeJson>("ArrowTypes")
arrows = arrowData.arrows.map { ArrowType(it.value.arrow, it.key.toInternalName()) }
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Matcher
import java.util.regex.Pattern
Expand Down Expand Up @@ -445,7 +444,7 @@ enum class TabWidget(
sentSinceWorldChange = false
}

@SubscribeEvent(priority = EventPriority.LOW)
@HandleEvent(priority = HandleEvent.LOW)
fun onRepoReload(event: RepositoryReloadEvent) {
extraPatterns = repoGroup.getUnusedPatterns()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class RepoManager(private val configLocation: File) {
unsuccessfulConstants.clear()
lastConstant = null

RepositoryReloadEvent(repoLocation, gson).postAndCatchAndBlock(ignoreErrorCache = true) {
RepositoryReloadEvent(repoLocation, gson).post {
error = true
lastConstant?.let {
unsuccessfulConstants.add(it)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package at.hannibal2.skyhanni.events

import at.hannibal2.skyhanni.api.event.SkyHanniEvent
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 java.io.File
import java.lang.reflect.Type

class RepositoryReloadEvent(val repoLocation: File, val gson: Gson) : LorenzEvent() {
class RepositoryReloadEvent(val repoLocation: File, val gson: Gson) : SkyHanniEvent() {

inline fun <reified T : Any> getConstant(constant: String, type: Type? = null, gson: Gson = this.gson): T = try {
RepoManager.setLastConstant(constant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.time.LocalTime
import java.time.OffsetDateTime
import java.time.ZoneOffset
Expand Down Expand Up @@ -71,7 +70,7 @@ object BingoAPI {
}
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
ranks = event.getConstant<BingoRanksJson>("BingoRanks").ranks
data = event.getConstant<BingoJson>("Bingo").bingoTips
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.chat

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.features.chat.PowderMiningFilterConfig
import at.hannibal2.skyhanni.config.features.chat.PowderMiningFilterConfig.SimplePowderMiningRewardTypes.ASCENSION_ROPE
import at.hannibal2.skyhanni.config.features.chat.PowderMiningFilterConfig.SimplePowderMiningRewardTypes.JUNGLE_HEART
Expand All @@ -22,8 +23,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern

@SkyHanniModule
Expand Down Expand Up @@ -317,7 +316,7 @@ object PowderMiningChatFilter {
private var rewardPatterns: Map<Pair<Pattern, PowderMiningFilterConfig.SimplePowderMiningRewardTypes>, String> =
emptyMap()

@SubscribeEvent(priority = EventPriority.HIGHEST)
@HandleEvent(priority = HandleEvent.HIGHEST)
fun onRepoReload(event: RepositoryReloadEvent) {
rewardPatterns = mapOf(
ascensionRopeRewardPattern to ASCENSION_ROPE to "powder_mining_ascension_rope",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package at.hannibal2.skyhanni.features.chat.playerchat

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.PlayerChatFilterJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.MultiFilter
import net.minecraft.util.IChatComponent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object PlayerChatFilter {
Expand All @@ -23,7 +23,7 @@ object PlayerChatFilter {
return false
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
filters.clear()
var countCategories = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ object GhostTracker {
tracker.renderDisplay(config.position)
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
allowedDrops = event.getConstant<GhostDropsJson>("GhostDrops").ghostDrops
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.features.commands.suggestions.LazySuggestionEntry
import at.hannibal2.skyhanni.features.commands.suggestions.SuggestionProvider
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.EntityUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object PlayerTabComplete {
Expand Down Expand Up @@ -105,7 +104,7 @@ object PlayerTabComplete {
it.isNotEmpty()
}?.distinct()

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<VipVisitsJson>("VipVisits")
vipVisits = data.vipVisits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.events.chat.TabCompletionEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object WarpTabComplete {

private val config get() = SkyHanniMod.feature.misc.commands.tabComplete
private var warps = listOf<String>()

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<WarpsJson>("Warps")
warps = data.warpCommands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object DungeonsRaceGuide {
currentRace = null
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<DungeonHubRacesJson>("DungeonHubRaces")
for ((key, map) in data.data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ object DianaProfitTracker {

private fun isAllowedItem(internalName: NEUInternalName): Boolean = internalName in allowedDrops

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
allowedDrops = event.getConstant<DianaDropsJson>("DianaDrops").dianaDrops
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ object HoppityCollectionStats {
hotspotRabbitCount -= 1
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<HoppityEggLocationsJson>("HoppityEggLocations")
for ((island, residents) in data.residentLocations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object HoppityEggLocations {

fun hasCollectedEgg(location: LorenzVec): Boolean = islandCollectedLocations.contains(location)

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
// TODO: split Chocolate Factory and Hoppity repo data
val data = event.getConstant<HoppityEggLocationsJson>("HoppityEggLocations")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object HoppityEventSummary {

private fun MutableList<StatString>.addEmptyLine() = this.add(StatString("", false))

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
allowedHoppityIslands = event.getConstant<HoppityEggLocationsJson>("HoppityEggLocations").apiEggLocations.keys.toSet()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.jsonobjects.repo.HoppityRabbitTextureEntry
import at.hannibal2.skyhanni.data.jsonobjects.repo.HoppityRabbitTexturesJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.LorenzRarity
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object HoppityTextureHandler {

private var hoppityRabbitTextures = mutableMapOf<LorenzRarity, List<HoppityRabbitTextureEntry>>()

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<HoppityRabbitTexturesJson>("HoppityRabbitTextures")
hoppityRabbitTextures = data.textures.mapNotNull { (key, entries) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object ReplaceHoppityWithContributor {
Expand All @@ -28,7 +26,7 @@ object ReplaceHoppityWithContributor {
update()
}

@SubscribeEvent(priority = EventPriority.LOW)
@HandleEvent(priority = HandleEvent.LOW)
fun onRepoReload(event: RepositoryReloadEvent) {
update()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.event.lobby.waypoints.christmas

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.WinterAPI
import at.hannibal2.skyhanni.data.jsonobjects.repo.EventWaypointsJson
Expand Down Expand Up @@ -117,7 +118,7 @@ object PresentWaypoints {

private fun EventWaypoint.shouldShow(): Boolean = !isFound && (!config.onlyClosest || closest == this)

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<EventWaypointsJson>("EventWaypoints")
presentLocations = loadEventWaypoints(data.presents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ object TheGreatSpook {
}
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<EventsJson>("Events").greatSpook

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object FishingAPI {
holdingWaterRod = event.newItem.isWaterRod()
}

@SubscribeEvent
@HandleEvent
fun onRepoReload(event: RepositoryReloadEvent) {
val data = event.getConstant<ItemsJson>("Items")
lavaRods = data.lavaFishingRods
Expand Down
Loading

0 comments on commit 2fbc41b

Please sign in to comment.