aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-18 00:27:01 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-18 00:27:01 +0200
commita10c097974d0b476be275c1fd2888d7502508efd (patch)
treeb9059f9ff1d010ce7ee32c4aece25a5dbc4141c3
parent88bff6a920bd597e7ef2a22bbcd99750158e6816 (diff)
downloadSkyHanni-a10c097974d0b476be275c1fd2888d7502508efd.tar.gz
SkyHanni-a10c097974d0b476be275c1fd2888d7502508efd.tar.bz2
SkyHanni-a10c097974d0b476be275c1fd2888d7502508efd.zip
added profile specific config support
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java119
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/OldHidden.java (renamed from src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java)17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt131
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/TitleUtils.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/HypixelJoinEvent.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/PreProfileSwitchEvent.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterAPI.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt37
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt36
37 files changed, 525 insertions, 159 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 0cea9f1cd..976e99e2c 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -132,6 +132,7 @@ class SkyHanniMod {
loadModule(ActionBarStatsData())
loadModule(GardenCropMilestoneAverage())
loadModule(GardenCropSpeed)
+ loadModule(ProfileStorageData)
// APIs
loadModule(BazaarApi())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index 292c87836..74e6f1461 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -1,17 +1,20 @@
package at.hannibal2.skyhanni.config
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.misc.update.UpdateManager
import at.hannibal2.skyhanni.utils.LorenzLogger
import com.google.gson.GsonBuilder
+import com.google.gson.TypeAdapter
+import com.google.gson.stream.JsonReader
+import com.google.gson.stream.JsonWriter
import io.github.moulberry.moulconfig.observer.PropertyTypeAdapterFactory
import io.github.moulberry.moulconfig.processor.BuiltinMoulConfigGuis
import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver
import io.github.moulberry.moulconfig.processor.MoulConfigProcessor
import java.io.*
import java.nio.charset.StandardCharsets
+import java.util.*
import kotlin.concurrent.fixedRateTimer
class ConfigManager {
@@ -20,6 +23,16 @@ class ConfigManager {
.excludeFieldsWithoutExposeAnnotation()
.serializeSpecialFloatingPointValues()
.registerTypeAdapterFactory(PropertyTypeAdapterFactory())
+ .registerTypeAdapter(UUID::class.java, object : TypeAdapter<UUID>() {
+ override fun write(out: JsonWriter, value: UUID) {
+ out.value(value.toString())
+ }
+
+ override fun read(reader: JsonReader): UUID {
+ return UUID.fromString(reader.nextString())
+ }
+ }.nullSafe())
+ .enableComplexMapKeySerialization()
.create()
}
@@ -83,8 +96,6 @@ class ConfigManager {
saveConfig("blank config")
}
- ConfigLoadEvent().postAndCatch()
-
val features = SkyHanniMod.feature
processor = MoulConfigProcessor(SkyHanniMod.feature)
BuiltinMoulConfigGuis.addProcessors(processor)
@@ -116,6 +127,7 @@ class ConfigManager {
file.parentFile.mkdirs()
file.createNewFile()
BufferedWriter(OutputStreamWriter(FileOutputStream(file), StandardCharsets.UTF_8)).use { writer ->
+ // TODO remove old "hidden" area
writer.write(gson.toJson(SkyHanniMod.feature))
}
} catch (e: IOException) {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index e91e89c8b..9a65ead70 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -124,5 +124,8 @@ public class Features extends Config {
public DevData dev = new DevData();
@Expose
- public Hidden hidden = new Hidden();
+ public OldHidden hidden = new OldHidden();
+
+ @Expose
+ public Storage storage = new Storage();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
new file mode 100644
index 000000000..b99b7cd7d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -0,0 +1,119 @@
+package at.hannibal2.skyhanni.config;
+
+import at.hannibal2.skyhanni.data.model.ComposterUpgrade;
+import at.hannibal2.skyhanni.features.garden.CropAccessory;
+import at.hannibal2.skyhanni.features.garden.CropType;
+import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward;
+import com.google.gson.annotations.Expose;
+
+import java.util.*;
+
+public class Storage {
+
+ @Expose
+ public Map<Long, List<CropType>> gardenJacobFarmingContestTimes = new HashMap<>();
+
+ @Expose
+ public String apiKey = "";
+
+ @Expose
+ public Map<UUID, PlayerSpecific> players = new HashMap<>();
+
+ public static class PlayerSpecific {
+
+ @Expose
+ public Map<String, ProfileSpecific> profiles = new HashMap<>(); // profile name
+
+ // TODO save community shop account upgrades here
+ }
+
+ public static class ProfileSpecific {
+
+ @Expose
+ public String currentPet = "";
+
+ @Expose
+ public GardenStorage garden = new GardenStorage();
+
+ public static class GardenStorage {
+
+ @Expose
+ public int experience = -1;
+
+ @Expose
+ public Map<CropType, Long> cropCounter = new HashMap<>();
+
+ @Expose
+ public Map<CropType, Integer> cropUpgrades = new HashMap<>();
+
+ @Expose
+ public Map<CropType, Integer> cropsPerSecond = new HashMap<>();
+
+ @Expose
+ public Map<CropType, Double> latestBlocksPerSecond = new HashMap<>();
+
+ @Expose
+ public Map<CropType, Double> latestTrueFarmingFortune = new HashMap<>();
+
+ @Expose
+ public CropAccessory savedCropAccessory = null;
+
+ @Expose
+ public Map<String, Integer> dicerRngDrops = new HashMap<>();
+
+ @Expose
+ public long informedAboutLowMatter = 0;
+
+ @Expose
+ public long informedAboutLowFuel = 0;
+
+ @Expose
+ public long visitorInterval = 15 * 60_000L;
+
+ @Expose
+ public long nextSixthVisitorArrival = 0;
+
+ @Expose
+ public Map<String, Integer> farmArmorDrops = new HashMap<>();
+
+ @Expose
+ public Map<ComposterUpgrade, Integer> composterUpgrades = new HashMap<>();
+
+ @Expose
+ public Map<CropType, Boolean> toolWithBountiful = new HashMap<>();
+
+ @Expose
+ public String composterCurrentOrganicMatterItem = "";
+
+ @Expose
+ public String composterCurrentFuelItem = "";
+
+ @Expose
+ public VisitorDrops visitorDrops = new VisitorDrops();
+
+ public static class VisitorDrops {
+ @Expose
+ public int acceptedVisitors = 0;
+
+ @Expose
+ public int deniedVisitors = 0;
+
+ @Expose
+ public List<Long> visitorRarities = new ArrayList<>();
+
+ @Expose
+ public int copper = 0;
+
+ @Expose
+ public long farmingExp = 0;
+
+ @Expose
+ public long coinsSpent = 0;
+
+ @Expose
+ public Map<VisitorReward, Integer> rewardsCount = new HashMap<>();
+ }
+ }
+
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/OldHidden.java
index bb5349168..be4407ce0 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/OldHidden.java
@@ -11,7 +11,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class Hidden {
+public class OldHidden {
@Expose
public String apiKey = "";
@@ -20,22 +20,22 @@ public class Hidden {
public String currentPet = "";
@Expose
- public Map<String, Long> minionLastClick = new HashMap<>();
+ public Map<String, Long> minionLastClick = new HashMap<>(); // TODO migration needed
@Expose
- public Map<String, String> minionName = new HashMap<>();
+ public Map<String, String> minionName = new HashMap<>(); // TODO migration needed
@Expose
- public List<String> crimsonIsleQuests = new ArrayList<>();
+ public List<String> crimsonIsleQuests = new ArrayList<>(); // TODO migration needed
@Expose
- public int crimsonIsleLatestTrophyFishInInventory = 0;
+ public int crimsonIsleLatestTrophyFishInInventory = 0; // TODO migration needed
@Expose
- public List<String> crimsonIsleMiniBossesDoneToday = new ArrayList<>();
+ public List<String> crimsonIsleMiniBossesDoneToday = new ArrayList<>(); // TODO migration needed
@Expose
- public List<String> crimsonIsleKuudraTiersDone = new ArrayList<>();
+ public List<String> crimsonIsleKuudraTiersDone = new ArrayList<>(); // TODO migration needed
@Expose
public Map<CropType, Long> gardenCropCounter = new HashMap<>();
@@ -117,4 +117,7 @@ public class Hidden {
@Expose
public Map<VisitorReward, Integer> rewardsCount = new HashMap<>();
}
+
+ @Expose
+ public boolean isMigrated = false;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
index d3b6a4e29..82938994a 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
@@ -28,7 +28,7 @@ class ApiDataLoader {
if (nextApiCallTime != -1L && System.currentTimeMillis() > nextApiCallTime) {
nextApiCallTime = System.currentTimeMillis() + 60_000 * 5
SkyHanniMod.coroutineScope.launch {
- val apiKey = SkyHanniMod.feature.hidden.apiKey
+ val apiKey = SkyHanniMod.feature.storage.apiKey
val uuid = LorenzUtils.getPlayerUuid()
loadProfileData(apiKey, uuid, currentProfileId)
}
@@ -39,7 +39,7 @@ class ApiDataLoader {
fun onStatusBar(event: LorenzChatEvent) {
val message = event.message
if (message.startsWith("§aYour new API key is §r§b")) {
- SkyHanniMod.feature.hidden.apiKey = message.substring(26)
+ SkyHanniMod.feature.storage.apiKey = message.substring(26)
LorenzUtils.chat("§b[SkyHanni] A new API Key has been detected and installed")
if (currentProfileName != "") {
@@ -86,13 +86,13 @@ class ApiDataLoader {
private fun updateApiData() {
nextApiCallTime = -1
SkyHanniMod.coroutineScope.launch {
- val oldApiKey = SkyHanniMod.feature.hidden.apiKey
+ val oldApiKey = SkyHanniMod.feature.storage.apiKey
if (oldApiKey.isNotEmpty() && tryUpdateProfileDataAndVerifyKey(oldApiKey)) {
return@launch
}
findApiCandidatesFromOtherMods().forEach { (modName, newApiKey) ->
if (tryUpdateProfileDataAndVerifyKey(newApiKey)) {
- SkyHanniMod.feature.hidden.apiKey = newApiKey
+ SkyHanniMod.feature.storage.apiKey = newApiKey
LorenzUtils.chat("§e[SkyHanni] Imported valid new API key from $modName.")
return@launch
} else {
@@ -149,7 +149,7 @@ class ApiDataLoader {
private var nextApiCallTime = -1L
fun command(args: Array<String>) {
- SkyHanniMod.feature.hidden.apiKey = args[0]
+ SkyHanniMod.feature.storage.apiKey = args[0]
LorenzUtils.chat("§e[SkyHanni] Api key set via command!")
nextApiCallTime = -1
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
index ed524e233..2899999c3 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt
@@ -1,11 +1,11 @@
package at.hannibal2.skyhanni.data
-import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.features.garden.CropAccessory
+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
@@ -116,9 +116,9 @@ class CropAccessoryData {
val pagesLoaded get() = accessoryPage.size
var cropAccessory: CropAccessory?
- get() = SkyHanniMod.feature.hidden.savedCropAccessory
+ get() = GardenAPI.config?.savedCropAccessory
private set(accessory) {
- SkyHanniMod.feature.hidden.savedCropAccessory = accessory
+ GardenAPI.config?.savedCropAccessory = accessory
}
// Derived partially from NotEnoughUpdates/NotEnoughUpdates, ProfileViewer.Profile#getInventoryInfo
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt
index 126cd52ea..1cf65578d 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt
@@ -23,7 +23,7 @@ class GardenComposterUpgradesData {
val name = matcher.group("name")
val level = matcher.group("level")?.romanToDecimalIfNeeded() ?: 0
val composterUpgrade = ComposterUpgrade.getByName(name)!!
- ComposterAPI.composterUpgrades[composterUpgrade] = level
+ ComposterAPI.composterUpgrades?.put(composterUpgrade, level)
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
index da7f0b05b..e78c68872 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt
@@ -1,12 +1,11 @@
package at.hannibal2.skyhanni.data
-import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.CropMilestoneUpdateEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.features.garden.CropType
+import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
-import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class GardenCropMilestones {
@@ -27,15 +26,6 @@ class GardenCropMilestones {
// }
@SubscribeEvent
- fun onWorldChange(event: WorldEvent.Load) {
- if (cropCounter.isEmpty()) {
- for (crop in CropType.values()) {
- crop.setCounter(0)
- }
- }
- }
-
- @SubscribeEvent
fun onInventoryOpen(event: InventoryOpenEvent) {
if (event.inventoryName != "Crop Milestones") return
@@ -52,17 +42,17 @@ class GardenCropMilestones {
}
}
}
-
CropMilestoneUpdateEvent().postAndCatch()
}
companion object {
- val cropCounter: MutableMap<CropType, Long> get() = SkyHanniMod.feature.hidden.gardenCropCounter
+ val cropCounter: MutableMap<CropType, Long>? get() = GardenAPI.config?.cropCounter
- fun CropType.getCounter() = cropCounter[this]!!
+ // TODO make nullable
+ fun CropType.getCounter() = cropCounter?.get(this) ?: 0
fun CropType.setCounter(counter: Long) {
- cropCounter[this] = counter
+ cropCounter?.set(this, counter)
}
fun getTierForCrops(crops: Long): Int {
@@ -153,6 +143,7 @@ class GardenCropMilestones {
}
}
+// TODO delete?
private fun String.formatNumber(): Long {
var text = replace(",", "")
val multiplier = if (text.endsWith("k")) {
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
index e5ece4acc..04717a9a5 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
@@ -1,11 +1,11 @@
package at.hannibal2.skyhanni.data
-import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.CropUpgradeUpdateEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull
+import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -32,22 +32,23 @@ class GardenCropUpgrades {
val crop = item.name?.removeColor()?.let {
CropType.getByNameOrNull(it)
} ?: return@forEach
+ println("finding for '$crop'")
val level = item.getLore().firstNotNullOfOrNull {
tierPattern.matchEntire(it)?.groups?.get(1)?.value?.toIntOrNull()
- } ?: return@forEach
+ } ?: 0
+ println("found: $level")
crop.setUpgradeLevel(level)
}
CropUpgradeUpdateEvent().postAndCatch()
}
companion object {
- private val cropUpgrades: MutableMap<CropType, Int> get() =
- SkyHanniMod.feature.hidden.gardenCropUpgrades
+ private val cropUpgrades: MutableMap<CropType, Int>? get() = GardenAPI.config?.cropUpgrades
- fun CropType.getUpgradeLevel() = cropUpgrades[this]
+ fun CropType.getUpgradeLevel() = cropUpgrades?.get(this)
fun CropType.setUpgradeLevel(level: Int) {
- cropUpgrades[this] = level
+ cropUpgrades?.put(this, level)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index 580954dc2..b3e27f011 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.events.HypixelJoinEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
@@ -83,6 +84,9 @@ class HypixelData {
if (!LorenzUtils.onHypixel) {
checkHypixel()
+ if (LorenzUtils.onHypixel) {
+ HypixelJoinEvent().postAndCatch()
+ }
}
if (!LorenzUtils.onHypixel) return
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
new file mode 100644
index 000000000..4a15c90d4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt
@@ -0,0 +1,131 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.Storage
+import at.hannibal2.skyhanni.events.*
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object ProfileStorageData {
+ var playerSpecific: Storage.PlayerSpecific? = null
+ var profileSpecific: Storage.ProfileSpecific? = null
+ var loaded = false
+
+ private var nextProfile: String? = null
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ fun onChat(event: LorenzChatEvent) {
+ "§7Switching to profile (?<name>.*)\\.\\.\\.".toPattern().matchMatcher(event.message) {
+ nextProfile = group("name").lowercase()
+ println("switching to profile: '$nextProfile'")
+ loaded = false
+ PreProfileSwitchEvent().postAndCatch()
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ fun onWorldChange(event: WorldEvent.Load) {
+ val profileName = nextProfile ?: return
+ nextProfile = null
+ println("new world after profile swap.")
+
+ val playerSpecific = playerSpecific
+ if (playerSpecific == null) {
+ LorenzUtils.error("profileSpecific after profile swap can not be set: playerSpecific is null!")
+ return
+ }
+ profileSpecific = playerSpecific.profiles.getOrPut(profileName) { Storage.ProfileSpecific() }
+ loaded = true
+ println("profileSpecific loaded after profile swap!")
+ ConfigLoadEvent().postAndCatch()
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ fun onProfileJoin(event: ProfileJoinEvent) {
+ val playerSpecific = playerSpecific
+ if (playerSpecific == null) {
+ LorenzUtils.error("playerSpecific is null in ProfileJoinEvent!")
+ return
+ }
+
+ if (profileSpecific == null) {
+ val profileName = event.name
+ profileSpecific = playerSpecific.profiles.getOrPut(profileName) { Storage.ProfileSpecific() }
+ loaded = true
+ migrateProfileSpecific()
+ println("profileSpecif