From 4995d0bef9c890fec2765536055987319d1a8140 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Fri, 3 Nov 2023 08:24:33 +1100 Subject: [PATCH] added toggle to hide autopet messages --- .../skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../skyhanni/config/features/MiscConfig.java | 14 +++++++++++--- .../features/misc/CurrentPetDisplay.kt | 19 +++++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 69a77d6dfc78..308587d5439d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -9,7 +9,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - val configVersion = 6 + val configVersion = 7 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index 86f60a8f7f46..36472bc45e11 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -25,6 +25,7 @@ public class MiscConfig { @ConfigOption(name = "Pet", desc = "") @Accordion public PetConfig pets = new PetConfig(); + public static class PetConfig { @Expose @ConfigOption(name = "Pet Display", desc = "Show the currently active pet.") @@ -32,6 +33,16 @@ public static class PetConfig { @FeatureToggle public boolean display = false; + @Expose + @ConfigOption(name = "Hide Autopet Messages", desc = "Hides the autopet messages from chat. §eRequires the " + + "display to be enabled.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hideAutopet = false; + + @Expose + public Position petDisplayPos = new Position(-330, -15, false, true); + @Expose @ConfigOption(name = "Pet Experience Tooltip", desc = "") @Accordion @@ -58,9 +69,6 @@ public static class PetExperienceToolTipConfig { } } - @Expose - public Position petDisplayPos = new Position(-330, -15, false, true); - @ConfigOption(name = "Hide Armor", desc = "") @Accordion @Expose 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 e4b9622816d4..089bc59b6eb3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchRegex import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class CurrentPetDisplay { + private val config get() = SkyHanniMod.feature.misc.pets // TODO USE SH-REPO private val inventoryNamePattern = "(?:\\(\\d+/\\d+\\))? Pets".toPattern() @@ -23,25 +24,26 @@ class CurrentPetDisplay { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { val message = event.message - val config = ProfileStorageData.profileSpecific ?: return + val hidden = ProfileStorageData.profileSpecific ?: return + var blocked = false if (message.matchRegex("§cAutopet §eequipped your §7(.*)§e! §a§lVIEW RULE")) { - config.currentPet = message.between("] ", "§e!") + hidden.currentPet = message.between("] ", "§e!") blocked = true } if (!LorenzUtils.inSkyBlock) return if (message.matchRegex("§aYou summoned your §r(.*)§r§a!")) { - config.currentPet = message.between("your §r", "§r§a") + hidden.currentPet = message.between("your §r", "§r§a") blocked = true } if (message.matchRegex("§aYou despawned your §r(.*)§r§a!")) { - config.currentPet = "" + hidden.currentPet = "" blocked = true } - if (blocked && SkyHanniMod.feature.misc.pets.display) { + if (blocked && config.display && config.hideAutopet) { event.blockedReason = "pets" } } @@ -66,14 +68,15 @@ class CurrentPetDisplay { if (!LorenzUtils.inSkyBlock) return if (RiftAPI.inRift()) return - if (!SkyHanniMod.feature.misc.pets.display) return - val config = ProfileStorageData.profileSpecific ?: return + if (!config.display) return + val hidden = ProfileStorageData.profileSpecific ?: return - SkyHanniMod.feature.misc.petDisplayPos.renderString(config.currentPet, posLabel = "Current Pet") + config.petDisplayPos.renderString(hidden.currentPet, posLabel = "Current Pet") } @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "misc.petDisplay", "misc.pets.display") + event.move(7, "misc.petDisplayPos", "misc.pets.petDisplayPos") } }