aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
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 /src/main/java/at/hannibal2
parent88bff6a920bd597e7ef2a22bbcd99750158e6816 (diff)
downloadskyhanni-a10c097974d0b476be275c1fd2888d7502508efd.tar.gz
skyhanni-a10c097974d0b476be275c1fd2888d7502508efd.tar.bz2
skyhanni-a10c097974d0b476be275c1fd2888d7502508efd.zip
added profile specific config support
Diffstat (limited to 'src/main/java/at/hannibal2')
-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("profileSpecific loaded for first join!")
+ ConfigLoadEvent().postAndCatch()
+ }
+ }
+
+ @SubscribeEvent
+ fun onConfigLoad(event: HypixelJoinEvent) {
+ val playerUuid = LorenzUtils.getRawPlayerUuid()
+ playerSpecific = SkyHanniMod.feature.storage.players.getOrPut(playerUuid) { Storage.PlayerSpecific() }
+ migratePlayerSpecific()
+ println("loaded playerSpecific because of HypixelJoinEvent!")
+ ConfigLoadEvent().postAndCatch()
+ }
+
+ private fun migratePlayerSpecific() {
+ val oldHidden = SkyHanniMod.feature.hidden
+ if (oldHidden.isMigrated) return
+
+ SkyHanniMod.feature.storage.apiKey = oldHidden.apiKey
+
+ SkyHanniMod.feature.storage?.let {
+ it.gardenJacobFarmingContestTimes = oldHidden.gardenJacobFarmingContestTimes
+ }
+ }
+
+ private fun migrateProfileSpecific() {
+ val oldHidden = SkyHanniMod.feature.hidden
+ if (oldHidden.isMigrated) return
+
+ profileSpecific?.let {
+ it.currentPet = oldHidden.currentPet
+ }
+
+ profileSpecific?.garden?.let {
+ it.experience = oldHidden.gardenExp
+ it.cropCounter = oldHidden.gardenCropCounter
+ it.cropUpgrades = oldHidden.gardenCropUpgrades
+
+ for ((crop, speed) in oldHidden.gardenCropsPerSecond) {
+ if (speed != -1) {
+ it.cropsPerSecond[crop] = speed
+ }
+ }
+
+ it.latestBlocksPerSecond = oldHidden.gardenLatestBlocksPerSecond
+ it.latestTrueFarmingFortune = oldHidden.gardenLatestTrueFarmingFortune
+ it.savedCropAccessory = oldHidden.savedCropAccessory
+ it.dicerRngDrops = oldHidden.gardenDicerRngDrops
+ it.informedAboutLowMatter = oldHidden.informedAboutLowMatter
+ it.informedAboutLowFuel = oldHidden.informedAboutLowFuel
+ it.visitorInterval = oldHidden.visitorInterval
+ it.nextSixthVisitorArrival = oldHidden.nextSixthVisitorArrival
+ it.farmArmorDrops = oldHidden.gardenFarmingArmorDrops
+ it.composterUpgrades = oldHidden.gardenComposterUpgrades
+ it.toolWithBountiful = oldHidden.gardenToolHasBountiful
+ it.composterCurrentOrganicMatterItem = oldHidden.gardenComposterCurrentOrganicMatterItem
+ it.composterCurrentFuelItem = oldHidden.gardenComposterCurrentFuelItem
+ }
+
+ profileSpecific?.garden?.visitorDrops?.let {
+ val old = oldHidden.visitorDrops
+ it.acceptedVisitors = old.acceptedVisitors
+ it.deniedVisitors = old.deniedVisitors
+ it.visitorRarities = old.visitorRarities
+ it.copper = old.copper
+ it.farmingExp = old.farmingExp
+ it.coinsSpent = old.coinsSpent
+ it.rewardsCount = old.rewardsCount
+ }
+
+ oldHidden.isMigrated = true
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt
index 11e6f86f5..3f0562f0d 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt
@@ -13,6 +13,7 @@ class RenderGuiData {
@SubscribeEvent
fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) {
+// if (!ProfileStorage.loaded) return
if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) return
if (GuiEditManager.isInGui()) return
@@ -21,6 +22,7 @@ class RenderGuiData {
@SubscribeEvent
fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) {
+// if (!ProfileStorage.loaded) return
if (GuiEditManager.isInGui()) return
val currentScreen = Minecraft.getMinecraft().currentScreen ?: return
if (currentScreen !is GuiInventory && currentScreen !is GuiChest) return
diff --git a/src/main/java/at/hannibal2/skyhanni/data/TitleUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/TitleUtils.kt
index 89e11f447..c43511afa 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/TitleUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/TitleUtils.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import io.github.moulberry.moulconfig.internal.TextRenderUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.ScaledResolution
@@ -20,6 +21,11 @@ class TitleUtils {
}
@SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ sendTitle("", 1)
+ }
+
+ @SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
if (System.currentTimeMillis() > endTime) return
diff --git a/src/main/java/at/hannibal2/skyhanni/events/HypixelJoinEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/HypixelJoinEvent.kt
new file mode 100644
index 000000000..044d63daa
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/HypixelJoinEvent.kt
@@ -0,0 +1,3 @@
+package at.hannibal2.skyhanni.events
+
+class HypixelJoinEvent : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/PreProfileSwitchEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PreProfileSwitchEvent.kt
new file mode 100644
index 000000000..240f14758
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/PreProfileSwitchEvent.kt
@@ -0,0 +1,3 @@
+package at.hannibal2.skyhanni.events
+
+class PreProfileSwitchEvent : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index 65b92f8d2..9159c18ee 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -34,6 +34,12 @@ class FarmingFortuneDisplay {
private var ticks: Int = 0
@SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ display = emptyList()
+ accessoryProgressDisplay = ""
+ }
+
+ @SubscribeEvent
fun onTabListUpdate(event: TabListUpdateEvent) {
if (!GardenAPI.inGarden()) return
tabFortune = event.tabList.firstNotNullOfOrNull {
@@ -52,7 +58,6 @@ class FarmingFortuneDisplay {
fun onBlockBreak(event: CropClickEvent) {
val cropBroken = event.crop
if (cropBroken != currentCrop) {
- currentCrop = cropBroken
updateToolFortune(event.itemInHand)
}
}
@@ -60,9 +65,7 @@ class FarmingFortuneDisplay {
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
lastToolSwitch = System.currentTimeMillis()
- val heldTool = event.toolItem
- currentCrop = event.crop ?: currentCrop
- updateToolFortune(heldTool)
+ updateToolFortune(event.toolItem)
}
@SubscribeEvent
@@ -96,7 +99,7 @@ class FarmingFortuneDisplay {
} else "?"
)
if (GardenAPI.toolInHand != null) {
- latestTrueFarmingFortune[displayCrop] = getCurrentFarmingFortune(true)
+ latestFF?.put(displayCrop, getCurrentFarmingFortune(true))
}
})
@@ -130,10 +133,9 @@ class FarmingFortuneDisplay {
companion object {
private val config get() = SkyHanniMod.feature.garden
- private val hidden get() = SkyHanniMod.feature.hidden
- private val latestTrueFarmingFortune: MutableMap<CropType, Double> get() = hidden.gardenLatestTrueFarmingFortune
+ private val latestFF: MutableMap<CropType, Double>? get() = GardenAPI.config?.latestTrueFarmingFortune
- private var currentCrop: CropType? = null
+ private val currentCrop get() = GardenAPI.getCurrentlyFarmedCrop()
private var tabFortune: Double = 0.0
private var toolFortune: Double = 0.0
@@ -196,6 +198,6 @@ class FarmingFortuneDisplay {
return baseFortune + upgradeFortune + tabFortune + toolFortune + accessoryFortune
}
- fun CropType.getLatestTrueFarmingFortune() = latestTrueFarmingFortune[this]
+ fun CropType.getLatestTrueFarmingFortune() = latestFF?.get(this)
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
index 2eb6e4fee..f5d6b7943 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType
@@ -9,7 +10,6 @@ import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay
import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI
import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed
-import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed
import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice
import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -36,6 +36,7 @@ object GardenAPI {
var mushroomCowPet = false
var inBarn = false
val onBarnPlot get() = inBarn && inGarden()
+ val config get() = ProfileStorageData.profileSpecific?.garden
var tick = 0
@@ -143,14 +144,17 @@ object GardenAPI {
SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory
fun clearCropSpeed() {
- for (type in CropType.values()) {
- type.setSpeed(-1)
- }
+ config?.cropsPerSecond?.clear()
GardenBestCropTime.reset()
updateGardenTool()
LorenzUtils.chat("§e[SkyHanni] Manually reset all crop speed data!")
}
+ @SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ GardenBestCropTime.reset()
+ }
+
fun getCurrentlyFarmedCrop(): CropType? {
val brokenCrop = if (toolInHand != null) GardenCropSpeed.lastBrokenCrop else null
return cropInHand ?: brokenCrop
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
index 8fdec3787..b643e5771 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.data.GardenCropMilestones
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.setCounter
+import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay
@@ -47,6 +48,7 @@ class GardenCropMilestoneFix {
}
private fun check(cropName: String, tier: Int, percentage: Double) {
+ if (!ProfileStorageData.loaded) return
val baseCrops = GardenCropMilestones.getCropsForTier(tier)
val next = GardenCropMilestones.getCropsForTier(tier + 1)
val progressCrops = next - baseCrops
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
index 4ee33e2b4..8f26863e9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
@@ -21,9 +21,9 @@ class GardenLevelDisplay {
private val overflowPattern = ".*§r §6(?<overflow>.*) XP".toPattern()
private val namePattern = "Garden Level (?<currentLevel>.*)".toPattern()
private var gardenExp
- get() = SkyHanniMod.feature.hidden.gardenExp
+ get() = GardenAPI.config?.experience ?: -1
set(value) {
- SkyHanniMod.feature.hidden.gardenExp = value
+ GardenAPI.config?.experience = value
}
private var display = ""
private var visitorRewardPattern = " {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience".toPattern()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index 10ecc6df0..7feaf7ca4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -139,7 +139,7 @@ class GardenNextJacobContest {
}
private fun saveConfig() {
- val map = SkyHanniMod.feature.hidden.gardenJacobFarmingContestTimes
+ val map = SkyHanniMod.feature.storage.gardenJacobFarmingContestTimes
map.clear()
for (contest in contests.values) {
map[contest.endTime] = contest.crops
@@ -148,7 +148,7 @@ class GardenNextJacobContest {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
- for ((time, crops) in SkyHanniMod.feature.hidden.gardenJacobFarmingContestTimes) {
+ for ((time, crops) in SkyHanniMod.feature.storage.gardenJacobFarmingContestTimes) {
contests[time] = FarmingContest(time, crops)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
index 73cdce3ad..5c3e6d433 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.GardenCropMilestones
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -24,10 +23,6 @@ class ToolTooltipTweaks {
@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (!LorenzUtils.inSkyBlock) return
- if (GardenCropMilestones.cropCounter.isEmpty()) {
- LorenzUtils.debug("Garden ToolTip Tweaks: crop counter data not yet loaded!")
- return
- }
val crop = event.itemStack.getCropType() ?: return
val toolFortune = FarmingFortuneDisplay.getToolFortune(event.itemStack)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterAPI.kt
index fb45d179c..3a22e5d39 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterAPI.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.features.garden.composter
-import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.model.ComposterUpgrade
+import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import kotlin.time.Duration
@@ -9,9 +9,9 @@ import kotlin.time.Duration.Companion.minutes
object ComposterAPI {
var tabListData = mapOf<ComposterDisplay.DataType, String>()
- val composterUpgrades: MutableMap<ComposterUpgrade, Int> get() = SkyHanniMod.feature.hidden.gardenComposterUpgrades
+ val composterUpgrades: MutableMap<ComposterUpgrade, Int>? get() = GardenAPI.config?.composterUpgrades
- fun ComposterUpgrade.getLevel(addOne: ComposterUpgrade?) = (composterUpgrades[this] ?: 0) + if (addOne == this) 1 else 0
+ fun ComposterUpgrade.getLevel(addOne: ComposterUpgrade?) = (composterUpgrades?.get(this) ?: 0) + if (addOne == this) 1 else 0
fun getFuel() = tabListData[ComposterDisplay.DataType.FUEL]?.removeColor()?.formatNumber() ?: 0
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
index 763186a03..8f6a34a18 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
@@ -17,7 +17,7 @@ import kotlin.time.DurationUnit
class ComposterDisplay {
private val config get() = SkyHanniMod.feature.garden
- private val hidden get() = SkyHanniMod.feature.hidden
+ private val hidden get() = GardenAPI.config
private var display = listOf<List<Any>>()
private var composterEmptyTime: Duration? = null
@@ -33,7 +33,7 @@ class ComposterDisplay {
NEUItems.getItemStack(icon)
}
- val pattern by lazy {rawPattern.toPattern()}
+ val pattern by lazy { rawPattern.toPattern() }
fun addToList(map: Map<DataType, String>): List<Any> {
return listOf(displayItem, map[this]!!)
@@ -57,7 +57,7 @@ class ComposterDisplay {
val organicMatter = ComposterAPI.getOrganicMatter()
val fuel = ComposterAPI.getFuel()
- if (ComposterAPI.composterUpgrades.isEmpty()) {
+ if (ComposterAPI.composterUpgrades.isNullOrEmpty()) {
composterEmptyTime = null
return
}
@@ -135,6 +135,7 @@ class ComposterDisplay {
private fun sendNotify() {
if (!config.composterNotifyLowEnabled) return
+ val hidden = hidden ?: return
if (ComposterAPI.getOrganicMatter() <= config.composterNotifyLowOrganicMatter) {
if (System.currentTimeMillis() >= hidden.informedAboutLowMatter) {
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 1e027b6ab..7616ee323 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
@@ -49,17 +49,16 @@ class ComposterOverlay {
private var lastHovered = 0L
companion object {
- private val hidden get() = SkyHanniMod.feature.hidden
- var currentOrganicMatterItem: String
- get() = hidden.gardenComposterCurrentOrganicMatterItem
+ var currentOrganicMatterItem: String?
+ get() = GardenAPI.config?.composterCurrentOrganicMatterItem
private set(value) {
- hidden.gardenComposterCurrentOrganicMatterItem = value
+ GardenAPI.config?.composterCurrentOrganicMatterItem = value
}
- var currentFuelItem: String
- get() = hidden.gardenComposterCurrentFuelItem
+ var currentFuelItem: String?
+ get() = GardenAPI.config?.composterCurrentFuelItem
private set(value) {
- hidden.gardenComposterCurrentFuelItem = value
+ GardenAPI.config?.composterCurrentFuelItem = value
}
var testOffset = 0
@@ -270,8 +269,8 @@ class ComposterOverlay {
}
private fun addExtraData(newList: MutableList<List<Any>>) {
- val organicMatterItem = currentOrganicMatterItem
- val fuelItem = currentFuelItem
+ val organicMatterItem = currentOrganicMatterItem ?: return
+ val fuelItem = currentFuelItem ?: return
if (organicMatterItem == "" || fuelItem == "") return
newList.addSelector("§7Per ", TimeType.values(),
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
index 4c6bb23f8..aedcab012 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.farming
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi
import at.hannibal2.skyhanni.features.bazaar.BazaarData
import at.hannibal2.skyhanni.features.garden.CropType
@@ -43,7 +44,12 @@ object CropMoneyDisplay {
private var loaded = false
private var ready = false
private val cropNames = mutableMapOf<String, CropType>() // internalName -> cropName
- private val toolHasBountiful: MutableMap<CropType, Boolean> get() = SkyHanniMod.feature.hidden.gardenToolHasBountiful
+ private val toolHasBountiful get() = GardenAPI.config?.toolWithBountiful
+
+ @SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ display = emptyList()
+ }
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
@@ -102,7 +108,7 @@ object CropMoneyDisplay {
var extraNetherWartPrices = 0.0
GardenAPI.getCurrentlyFarmedCrop()?.let {
val reforgeName = Minecraft.getMinecraft().thePlayer.heldItem?.getReforgeName()
- toolHasBountiful[it] = reforgeName == "bountiful"
+ toolHasBountiful?.put(it, reforgeName == "bountiful")
if (GardenAPI.mushroomCowPet && it != CropType.MUSHROOM) {
val redPrice = NEUItems.getPrice("ENCHANTED_RED_MUSHROOM") / 160
@@ -301,7 +307,7 @@ object CropMoneyDisplay {
}
}
- val bountifulMoney = if (toolHasBountiful[crop] == true) speedPerHour * 0.2 else 0.0
+ val bountifulMoney = if (toolHasBountiful?.get(crop) == true) speedPerHour * 0.2 else 0.0
moneyPerHours[internalName] =
formatNumbers(sellOffer + bountifulMoney, instantSell + bountifulMoney, npcPrice + bountifulMoney)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt
index ca15c038a..ad9ad9737 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt
@@ -1,10 +1,7 @@
package at.hannibal2.skyhanni.features.garden.farming
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.ConfigLoadEvent
-import at.hannibal2.skyhanni.events.GardenToolChangeEvent
-import at.hannibal2.skyhanni.events.GuiRenderEvent
-import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ItemUtils.name
@@ -20,8 +17,7 @@ class DicerRngDropCounter {
private val config get() = SkyHanniMod.feature.garden
init {
- drops[CropType.MELON] = mutableMapOf()
- drops[CropType.PUMPKIN] = mutableMapOf()
+ initDrops()
itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a1x §r§aEnchanted Melon§r§e!"))
itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, "§9§lRARE DROP! §r§eDicer dropped §r§a5x §r§aEnchanted Melon§r§e!"))
@@ -34,6 +30,11 @@ class DicerRngDropCounter {
itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§a64x §r§aEnchanted Pumpkin§r§e!"))
}
+ private fun initDrops() {
+ drops[CropType.MELON] = mutableMapOf()
+ drops[CropType.PUMPKIN] = mutableMapOf()
+ }
+
enum class DropRarity(val displayName: String) {
UNCOMMON("§a§lUNCOMMON DROP"),
RARE("§9§lRARE DROP"),
@@ -42,6 +43,13 @@ class DicerRngDropCounter {
}
@SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ display = emptyList()
+ drops.clear()
+ initDrops()
+ }
+
+ @SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!isEnabled()) return
@@ -104,7 +112,7 @@ class DicerRngDropCounter {
class ItemDrop(val crop: CropType, val rarity: DropRarity, val message: String)
private fun saveConfig() {
- val map = SkyHanniMod.feature.hidden.gardenDicerRngDrops
+ val map = GardenAPI.config?.dicerRngDrops ?: return
map.clear()
for (drop in drops) {
val crop = drop.key
@@ -116,7 +124,8 @@ class DicerRngDropCounter {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
- for ((internalName, amount) in SkyHanniMod.feature.hidden.gardenDicerRngDrops) {
+ val map = GardenAPI.config?.dicerRngDrops ?: return
+ for ((internalName, amount) in map) {
val split = internalName.split(".")
val crop = CropType.getByName(split[0])
val rarityName = split[1]
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt
index a71edb381..37c92258e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/EliteFarmingWeight.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed
@@ -49,6 +50,15 @@ class EliteFarmingWeight {
nextPlayerWeight = 0.0
nextPlayerName = ""
hasPassedNext = false
+ localCounter.clear()
+ }
+
+ @SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ display = emptyList()
+ profileId = ""
+ weight = -2.0
+
}
var tick = 0
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 2423f1a62..f9ad49e17 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
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -28,6 +29,13 @@ class FarmingArmorDrops {
}
@SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ display = emptyList()
+ drops.clear()
+ hasArmor = false
+ }
+
+ @SubscribeEvent
fun onChat(event: LorenzChatEvent) {
for (dropType in ArmorDropType.values()) {
if (dropType.chatMessage == event.message) {
@@ -62,7 +70,7 @@ class FarmingArmorDrops {
}
private fun saveConfig() {
- val map = SkyHanniMod.feature.hidden.gardenFarmingArmorDrops
+ val map = GardenAPI.config?.farmArmorDrops ?: return
map.clear()
for ((drop, amount) in drops) {
map[drop.toString()] = amount
@@ -71,7 +79,8 @@ class FarmingArmorDrops {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
- for ((rawName, amount) in SkyHanniMod.feature.hidden.gardenFarmingArmorDrops) {
+ val map = GardenAPI.config?.farmArmorDrops ?: return
+ for ((rawName, amount) in map) {
drops[ArmorDropType.valueOf(rawName)] = amount
}
update()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
index de8d299fd..5d98bd05d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt
@@ -11,7 +11,6 @@ import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
-import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
@@ -78,8 +77,10 @@ object GardenCropMilestoneDisplay {
@SubscribeEvent(priority = EventPriority.LOW)
fun onProfileJoin(event: ProfileJoinEvent) {
- if (GardenCropMilestones.cropCounter.values.sum() == 0L) {
- needsInventory = true
+ GardenCropMilestones.cropCounter?.let {
+ if (it.values.sum() == 0L) {
+ needsInventory = true
+ }
}
}
@@ -102,17 +103,6 @@ object GardenCropMilestoneDisplay {
if (cultivatingData.containsKey(crop)) {
val old = cultivatingData[crop]!!
val addedCounter = (counter - old).toInt()
-
- if (GardenCropMilestones.cropCounter.isEmpty()) {
- for (innerCrop in CropType.values()) {
- innerCrop.setCounter(0)
- }
- }
- if (isSpeedDataEmpty()) {
- for (cropType in CropType.values()) {
- cropType.setSpeed(-1)
- }
- }
EliteFarmingWeight.addCrop(crop, addedCounter)
update()
crop.setCounter(
@@ -133,10 +123,6 @@ object GardenCropMilestoneDisplay {
mushroomCowPerkDisplay = emptyList()
bestCropTime.display = emptyList()
val currentCrop = GardenAPI.getCurrentlyFarmedCrop()
- if (GardenCropMilestones.cropCounter.isEmpty()) {
- LorenzUtils.debug("Garden Crop Milestone Display: crop counter data not yet loaded!")
- return
- }
currentCrop?.let {
progressDisplay = drawProgressDisplay(it)
}
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 af797ba2e..3c61691ef 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
@@ -7,20 +7,19 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.setCounter
import at.hannibal2.skyhanni.data.MayorElection
import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
-import at.hannibal2.skyhanni.events.ProfileJoinEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
object GardenCropSpeed {
private val config get() = SkyHanniMod.feature.garden
- private val hidden get() = SkyHanniMod.feature.hidden
- private val cropsPerSecond: MutableMap<CropType, Int> get() = hidden.gardenCropsPerSecond
- private val latestBlocksPerSecond: MutableMap<CropType, Double> get() = hidden.gardenLatestBlocksPerSecond
+ private val cropsPerSecond: MutableMap<CropType, Int>? get() = GardenAPI.config?.cropsPerSecond
+ private val latestBlocksPerSecond: MutableMap<CropType, Double>? get() = GardenAPI.config?.latestBlocksPerSecond
var lastBrokenCrop: CropType? = null
+
var averageBlocksPerSecond = 0.0
private val blocksSpeedList = mutableListOf<Int>()
@@ -41,6 +40,11 @@ object GardenCropSpeed {
}
@SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ lastBrokenCrop = null
+ }
+
+ @SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
if (isEnabled()) {
resetSpeed()
@@ -85,7 +89,7 @@ object GardenCropSpeed {
blocksSpeedList.dropLast(1).average()
} else 0.0
GardenAPI.getCurrentlyFarmedCrop()?.let {
- latestBlocksPerSecond[it] = averageBlocksPerSecond
+ latestBlocksPerSecond?.put(it, averageBlocksPerSecond)
}
}
}
@@ -102,28 +106,15 @@ object GardenCropSpeed {
return forcefullyEnabledAlwaysFinnegan || perkActive
}
- @SubscribeEvent(priority = EventPriority.LOW)
- fun onProfileJoin(event: ProfileJoinEvent) {
- if (cropsPerSecond.isEmpty()) {
- for (cropType in CropType.values()) {
- cropType.setSpeed(-1)
- }
- }
- }
-
fun isEnabled() = GardenAPI.inGarden()
- fun CropType.getSpeed(): Int? {
- val speed = cropsPerSecond[this]
- if (speed == -1) return null
- return speed
- }
+ fun CropType.getSpeed() = cropsPerSecond?.get(this)
fun CropType.setSpeed(speed: Int) {
- cropsPerSecond[this] = speed
+ cropsPerSecond?.put(this, speed)
}
- fun CropType.getLatestBlocksPerSecond() = latestBlocksPerSecond[this]
+ fun CropType.getLatestBlocksPerSecond() = latestBlocksPerSecond?.get(this)
- fun isSpeedDataEmpty() = cropsPerSecond.values.sum() < 0
+ fun isSpeedDataEmpty() = cropsPerSecond?.values?.sum()?.let { it == 0 } ?: true
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
index 91c36e5b9..c056a8eb4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
@@ -1,8 +1,10 @@
package at.hannibal2.skyhanni.features.garden.visitor
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
@@ -13,12 +15,10 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object GardenVisitorDropStatistics {
private val config get() = SkyHanniMod.feature.garden.visitorDropsStatistics
- private val hidden get() = SkyHanniMod.feature.hidden.visitorDrops
private var display = listOf<List<Any>>()
private var acceptedVisitors = 0
@@ -43,6 +43,11 @@ object GardenVisitorDropStatistics {
}
@SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ display = emptyList()
+ }
+
+ @SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!GardenAPI.onBarnPlot) return
val message = event.message.removeColor().trim()
@@ -134,6 +139,7 @@ object GardenVisitorDropStatistics {
fun saveAndUpdate() {
if (!GardenAPI.inGarden()) return
+ val hidden = GardenAPI.config?.visitorDrops ?: return
hidden.acceptedVisitors = acceptedVisitors
hidden.deniedVisitors = deniedVisitors
totalVisitors = acceptedVisitors + deniedVisitors
@@ -146,7 +152,8 @@ object GardenVisitorDropStatistics {
}
@SubscribeEvent
- fun onWorldLoad(event: WorldEvent.Load) {
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ val hidden = GardenAPI.config?.visitorDrops ?: return
if (hidden.visitorRarities.size == 0) {
hidden.visitorRarities.add(0)
hidden.visitorRarities.add(0)
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 4018f170f..4554f3845 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
@@ -55,6 +55,12 @@ class GardenVisitorFeatures {
}
@SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ display = emptyList()
+ visitors.clear()
+ }
+
+ @SubscribeEvent
fun onInventoryOpen(event: InventoryOpenEvent) {
inVisitorInventory = false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
index 3c64c076b..cc04a303b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleUtils
import at.hannibal2.skyhanni.events.CropClickEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.events.VisitorArrivalEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.test.command.CopyErrorCommand
@@ -25,12 +26,17 @@ class GardenVisitorTimer {
private var render = ""
private var lastMillis = 0L
private var sixthVisitorArrivalTime: Long = 0
- private var visitorJustArrived: Boolean = false
- private var sixthVisitorReady: Boolean = false
- private var visitorInterval
- get() = SkyHanniMod.feature.hidden.visitorInterval
+ private var visitorJustArrived = false
+ private var sixthVisitorReady = false
+
+ //TODO nea?
+// private val visitorInterval by dynamic(GardenAPI::config, Storage.ProfileSpecific.GardenStorage::visitorInterval)
+ private var visitorInterval: Long?
+ get() = GardenAPI.config?.visitorInterval
set(value) {
- SkyHanniMod.feature.hidden.visitorInterval = value
+ value?.let {
+ GardenAPI.config?.visitorInterval = it
+ }
}
companion object {
@@ -53,14 +59,25 @@ class GardenVisitorTimer {
}
try {
GardenVisitorDropStatistics.saveAndUpdate()
- } catch (_: Throwable) {} // no config yet
+ } catch (_: Throwable) {
+ } // no config yet
}
}
+ @SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ render = ""
+ lastMillis = 0
+ sixthVisitorArrivalTime = 0
+ visitorJustArrived = false
+ sixthVisitorReady = false
+ }
+
private fun updateVisitorDisplay() {
if (!isEnabled()) return
var visitorsAmount = 0
+ var visitorInterval = visitorInterval ?: return
var millis = visitorInterval
var queueFull = false
for (line in TabListData.getTabList()) {
@@ -95,8 +112,9 @@ class GardenVisitorTimer {
sixthVisitorReady = false
}
millis = sixthVisitorArrivalTime - System.currentTimeMillis()
- SkyHanniMod.feature.hidden.nextSixthVisitorArrival = System.currentTimeMillis() + millis + (5 - visitorsAmount) * visitorInterval
- if (isSixthVisitorEnabled() && millis < 0) {
+ GardenAPI.config?.nextSixthVisitorArrival =
+ System.currentTimeMillis() + millis + (5 - visitorsAmount) * visitorInterval
+ if (isSixthVisitorEnabled() && millis < 0) {
visitorsAmount++
if (!sixthVisitorReady) {
TitleUtils.sendTitle("§a6th Visitor Ready", 5_000)
@@ -136,7 +154,9 @@ class GardenVisitorTimer {
@SubscribeEvent
fun onWorldLoad(event: WorldEvent.Load) {
lastVisitors = -1
- sixthVisitorArrivalTime = SkyHanniMod.feature.hidden.nextSixthVisitorArrival
+ GardenAPI.config?.nextSixthVisitorArrival?.let {
+ sixthVisitorArrivalTime = it
+ }
sixthVisitorReady = false
lastMillis = sixthVisitorArrivalTime - System.currentTimeMillis()
}
@@ -148,7 +168,9 @@ class GardenVisitorTimer {
}
private fun updateSixthVisitorArrivalTime() {
- sixthVisitorArrivalTime = System.currentTimeMillis() + visitorInterval
+ visitorInterval?.let {
+ sixthVisitorArrivalTime = System.currentTimeMillis() + it
+ }
}
private fun isSixthVisitorEnabled() = config.visitorTimerSixthVisitorEnabled
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt
index 693c40210..bb21b7da6 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -10,23 +11,23 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchRegex
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class CurrentPetDisplay {
- private val config get() = SkyHanniMod.feature.hidden
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!LorenzUtils.inSkyBlock) return
-
+ val message = event.message
+ val config = ProfileStorageData.profileSpecific ?: return
var blocked = false
+ if (message.matchRegex("§cAutopet §eequipped your §7(.*)§e! §a§lVIEW RULE")) {
+ config.currentPet = message.between("] ", "§e!")
+ blocked = true
+ }
+
+ if (!LorenzUtils.inSkyBlock) return
- val message = event.message
if (message.matchRegex("§aYou summoned your §r(.*)§r§a!")) {
config.currentPet = message.between("your §r", "§r§a")
blocked = true
}
- if (message.matchRegex("§cAutopet §eequipped your §7(.*)§e! §a§lVIEW RULE")) {
- config.currentPet = message.between("] ", "§e!")
- blocked = true
- }
if (message.matchRegex("§aYou despawned your §r(.*)§r§a!")) {
config.currentPet = ""
blocked = true
@@ -42,6 +43,7 @@ class CurrentPetDisplay {
if (!LorenzUtils.inSkyBlock) return
if (!SkyHanniMod.feature.misc.petDisplay) return
+ val config = ProfileStorageData.profileSpecific ?: return
SkyHanniMod.feature.misc.petDisplayPos.renderString(config.currentPet, posLabel = "Current Pet")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
index fae6b5104..9a57ddd5e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getTierForCrops
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.progressToNextLevel
import at.hannibal2.skyhanni.data.HypixelData
+import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -174,12 +175,13 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}),
PETS({
- val pet = SkyHanniMod.feature.hidden.currentPet
- val colorCode = pet.substring(1..2).first()
- val petName = pet.substring(2)
- val petLevel = getCurrentPet().petLevel.currentLevel
+ ProfileStorageData.profileSpecific?.currentPet?.let {
+ val colorCode = it.substring(1..2).first()
+ val petName = it.substring(2)
+ val petLevel = getCurrentPet().petLevel.currentLevel
- "[Lvl $petLevel] ${colorCodeToRarity(colorCode)} $petName"
+ "[Lvl $petLevel] ${colorCodeToRarity(colorCode)} $petName"
+ } ?: ""
})
;
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index b7930bfd1..556eb59a0 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -24,6 +24,10 @@ import java.text.DecimalFormat
import java.text.NumberFormat
import java.text.SimpleDateFormat
import java.util.*
+import kotlin.properties.ReadWriteProperty
+import kotlin.reflect.KMutableProperty1
+import kotlin.reflect.KProperty
+import kotlin.reflect.KProperty0
object LorenzUtils {
@@ -183,7 +187,9 @@ object LorenzUtils {
return monthNr
}
- fun getPlayerUuid() = Minecraft.getMinecraft().thePlayer.uniqueID.toDashlessUUID()
+ fun getPlayerUuid() = getRawPlayerUuid().toDashlessUUID()
+
+ fun getRawPlayerUuid() = Minecraft.getMinecraft().thePlayer.uniqueID
fun getPlayerName() = Minecraft.getMinecraft().thePlayer.name
@@ -312,4 +318,32 @@ object LorenzUtils {
}
add(newList)
}
+
+ // TODO nea?
+// fun <T> dynamic(block: () -> KMutableProperty0<T>?): ReadWriteProperty<Any?, T?> {
+// return object : ReadWriteProperty<Any?, T?> {
+// override fun getValue(thisRef: Any?, property: KProperty<*>): T? {
+// return block()?.get()
+// }
+//
+// override fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) {
+// if (value != null)
+// block()?.set(value)
+// }
+// }
+// }
+
+ fun <T, R> dynamic(root: KProperty0<R?>, child: KMutableProperty1<R, T>) =
+ object : ReadWriteProperty<Any?, T?> {
+ override fun getValue(thisRef: Any?, property: KProperty<*>): T? {
+ val rootObj = root.get() ?: return null
+ return child.get(rootObj)
+ }
+
+ override fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) {
+ if (value == null) return
+ val rootObj = root.get() ?: return
+ child.set(rootObj, value)
+ }
+ }
} \ No newline at end of file