diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt index f9eb6b024..b4ad1d1af 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.SackData import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzUtils @@ -17,6 +18,10 @@ object ProfileStorageData { private var nextProfile: String? = null + + private var sackPlayers: SackData.PlayerSpecific? = null + var sackProfiles: SackData.ProfileSpecific? = null + @SubscribeEvent(priority = EventPriority.HIGHEST) fun onChat(event: LorenzChatEvent) { "§7Switching to profile (?<name>.*)\\.\\.\\.".toPattern().matchMatcher(event.message) { @@ -32,25 +37,35 @@ object ProfileStorageData { nextProfile = null val playerSpecific = playerSpecific + val sackPlayers = sackPlayers if (playerSpecific == null) { LorenzUtils.error("profileSpecific after profile swap can not be set: playerSpecific is null!") return } - loadProfileSpecific(playerSpecific, profileName, "profile swap (chat message)") + if (sackPlayers == null) { + LorenzUtils.error("sackPlayers after profile swap can not be set: sackPlayers is null!") + return + } + loadProfileSpecific(playerSpecific, sackPlayers, profileName, "profile swap (chat message)") ConfigLoadEvent().postAndCatch() } @SubscribeEvent(priority = EventPriority.HIGHEST) fun onProfileJoin(event: ProfileJoinEvent) { val playerSpecific = playerSpecific + val sackPlayers = sackPlayers if (playerSpecific == null) { LorenzUtils.error("playerSpecific is null in ProfileJoinEvent!") return } + if (sackPlayers == null) { + LorenzUtils.error("sackPlayers is null in sackPlayers!") + return + } if (profileSpecific == null) { val profileName = event.name - loadProfileSpecific(playerSpecific, profileName, "first join (chat message)") + loadProfileSpecific(playerSpecific, sackPlayers, profileName, "first join (chat message)") } } @@ -58,11 +73,12 @@ object ProfileStorageData { fun onTabListUpdate(event: TabListUpdateEvent) { if (profileSpecific != null) return val playerSpecific = playerSpecific ?: return + val sackPlayers = sackPlayers ?: return for (line in event.tabList) { val pattern = "§e§lProfile: §r§a(?<name>.*)".toPattern() pattern.matchMatcher(line) { val profileName = group("name").lowercase() - loadProfileSpecific(playerSpecific, profileName, "tab list") + loadProfileSpecific(playerSpecific, sackPlayers, profileName, "tab list") nextProfile = null return } @@ -87,18 +103,20 @@ object ProfileStorageData { } } - private fun loadProfileSpecific(playerSpecific: Storage.PlayerSpecific, profileName: String, reason: String) { + private fun loadProfileSpecific(playerSpecific: Storage.PlayerSpecific, sackProfile: SackData.PlayerSpecific, profileName: String, reason: String) { noTabListTime = -1 profileSpecific = playerSpecific.profiles.getOrPut(profileName) { Storage.ProfileSpecific() } + sackProfiles = sackProfile.profiles.getOrPut(profileName) { SackData.ProfileSpecific() } tryMigrateProfileSpecific() - ConfigLoadEvent().postAndCatch() loaded = true + ConfigLoadEvent().postAndCatch() } @SubscribeEvent fun onHypixelJoin(event: HypixelJoinEvent) { val playerUuid = LorenzUtils.getRawPlayerUuid() playerSpecific = SkyHanniMod.feature.storage.players.getOrPut(playerUuid) { Storage.PlayerSpecific() } + sackPlayers = SkyHanniMod.sackData.players.getOrPut(playerUuid) { SackData.PlayerSpecific() } migratePlayerSpecific() ConfigLoadEvent().postAndCatch() } @@ -137,7 +155,7 @@ object ProfileStorageData { } profileSpecific?.garden?.let { - it.experience = oldHidden.gardenExp + it.experience = oldHidden.gardenExp.toLong() it.cropCounter = oldHidden.gardenCropCounter it.cropUpgrades = oldHidden.gardenCropUpgrades |
