diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-03-22 18:16:36 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-03-22 18:16:36 +0100 |
commit | 788adb59f20e01c83f4e030fa077a70275c00074 (patch) | |
tree | fca6631ca0f5962669154e9bdfb42119cff69c35 /src/main | |
parent | eb0624abe02204461222b980e9cf395e1ddbdbd8 (diff) | |
parent | 527580c5c6362594909c83213f7d6838790a3ef6 (diff) | |
download | skyhanni-788adb59f20e01c83f4e030fa077a70275c00074.tar.gz skyhanni-788adb59f20e01c83f4e030fa077a70275c00074.tar.bz2 skyhanni-788adb59f20e01c83f4e030fa077a70275c00074.zip |
Merge remote-tracking branch 'origin/beta' into beta
Diffstat (limited to 'src/main')
6 files changed, 39 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 9eb8d3b99..e38172d3a 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -54,6 +54,7 @@ import at.hannibal2.skyhanni.data.TrackerManager import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson +import at.hannibal2.skyhanni.data.jsonobjects.local.VisualWordsJson import at.hannibal2.skyhanni.data.repo.RepoManager import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PreInitFinishedEvent @@ -863,6 +864,7 @@ class SkyHanniMod { val friendsData: FriendsJson get() = configManager.friendsData val knownFeaturesData: KnownFeaturesJson get() = configManager.knownFeaturesData val jacobContestsData: JacobContestsJson get() = configManager.jacobContestData + val visualWordsData: VisualWordsJson get() = configManager.visualWordsData lateinit var repo: RepoManager lateinit var configManager: ConfigManager diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index 4d98581c3..16deb3baf 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson import at.hannibal2.skyhanni.data.jsonobjects.other.HypixelApiTrophyFish +import at.hannibal2.skyhanni.data.jsonobjects.local.VisualWordsJson import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.utils.KotlinTypeAdapterFactory @@ -174,6 +175,7 @@ class ConfigManager { val friendsData get() = jsonHolder[ConfigFileType.FRIENDS] as FriendsJson val knownFeaturesData get() = jsonHolder[ConfigFileType.KNOWN_FEATURES] as KnownFeaturesJson val jacobContestData get() = jsonHolder[ConfigFileType.JACOB_CONTESTS] as JacobContestsJson + val visualWordsData get() = jsonHolder[ConfigFileType.VISUAL_WORDS] as VisualWordsJson private val logger = LorenzLogger("config_manager") @@ -301,6 +303,7 @@ enum class ConfigFileType(val fileName: String, val clazz: Class<*>) { FRIENDS("friends", FriendsJson::class.java), KNOWN_FEATURES("known_features", KnownFeaturesJson::class.java), JACOB_CONTESTS("jacob_contests", JacobContestsJson::class.java), + VISUAL_WORDS("visual_words", VisualWordsJson::class.java), ; val file by lazy { File(ConfigManager.configDirectory, "$fileName.json") } diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java index 5256d33ea..1f9be2875 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java @@ -26,6 +26,7 @@ public class Storage { @Expose public Map<String, List<String>> knownFeatureToggles = new HashMap<>(); + @Deprecated @Expose public List<VisualWord> modifiedWords = new ArrayList<>(); diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/local/VisualWordsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/local/VisualWordsJson.java new file mode 100644 index 000000000..bf3440be9 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/local/VisualWordsJson.java @@ -0,0 +1,12 @@ +package at.hannibal2.skyhanni.data.jsonobjects.local; + +import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord; +import com.google.gson.annotations.Expose; + +import java.util.ArrayList; +import java.util.List; + +public class VisualWordsJson { + @Expose + public List<VisualWord> modifiedWords = new ArrayList<>(); +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt index 9198438aa..55d9b7202 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt @@ -1,10 +1,13 @@ package at.hannibal2.skyhanni.features.misc.visualwords import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.enums.OutsideSbFeature +import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.convertToFormatted import at.hannibal2.skyhanni.utils.TimeLimitedCache +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes object ModifyVisualWords { @@ -21,7 +24,7 @@ object ModifyVisualWords { if (!LorenzUtils.inSkyBlock && !OutsideSbFeature.MODIFY_VISUAL_WORDS.isSelected()) return originalText if (modifiedWords.isEmpty()) { - modifiedWords = SkyHanniMod.feature.storage.modifiedWords + modifiedWords.addAll(SkyHanniMod.visualWordsData.modifiedWords) } val cachedResult = textCache.getOrNull(originalText) @@ -49,4 +52,14 @@ object ModifyVisualWords { textCache.put(originalText, modifiedText) return modifiedText } + + @SubscribeEvent + fun onHypixelJoin(event: HypixelJoinEvent) { + val oldModifiedWords = SkyHanniMod.feature.storage.modifiedWords + if (oldModifiedWords.isNotEmpty()) { + SkyHanniMod.visualWordsData.modifiedWords = oldModifiedWords + SkyHanniMod.feature.storage.modifiedWords = emptyList() + SkyHanniMod.configManager.saveConfig(ConfigFileType.VISUAL_WORDS, "Migrate visual words") + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt index 387a3e222..e41803ffb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc.visualwords import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils.chat @@ -231,7 +232,7 @@ open class VisualWordGui : GuiScreen() { } if (modifiedWords.size < 1) { - modifiedWords = SkyHanniMod.feature.storage.modifiedWords + modifiedWords = ModifyVisualWords.modifiedWords } if (toRemove != null) { @@ -444,7 +445,7 @@ open class VisualWordGui : GuiScreen() { currentText = "" currentIndex = modifiedWords.size - 1 saveChanges() - pageScroll = -(SkyHanniMod.feature.storage.modifiedWords.size * 30 - 100) + pageScroll = -(modifiedWords.size * 30 - 100) scrollScreen() } currentlyEditing = !currentlyEditing @@ -465,7 +466,7 @@ open class VisualWordGui : GuiScreen() { if (!currentlyEditing) { if (keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_S) { if (KeyboardManager.isModifierKeyDown()) { - pageScroll = -(SkyHanniMod.feature.storage.modifiedWords.size * 30 - 100) + pageScroll = -(modifiedWords.size * 30 - 100) } else { pageScroll -= 30 } @@ -549,14 +550,15 @@ open class VisualWordGui : GuiScreen() { pageScroll = 0 } - pageScroll = MathHelper.clamp_int(pageScroll, -(SkyHanniMod.feature.storage.modifiedWords.size * 30 - 100), 0) + pageScroll = MathHelper.clamp_int(pageScroll, -(modifiedWords.size * 30 - 100), 0) lastMouseScroll = 0 } private fun saveChanges() { ModifyVisualWords.modifiedWords = modifiedWords ModifyVisualWords.textCache.clear() - SkyHanniMod.feature.storage.modifiedWords = modifiedWords + SkyHanniMod.visualWordsData.modifiedWords = modifiedWords + SkyHanniMod.configManager.saveConfig(ConfigFileType.VISUAL_WORDS, "Updated visual words") } private fun tryImportFromSBE() { |