Skip to content

Commit

Permalink
added toggle to hide autopet messages
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs committed Nov 2, 2023
1 parent ad12389 commit 4995d0b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ 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.")
@ConfigEditorBoolean
@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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,34 @@ 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()

@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"
}
}
Expand All @@ -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")
}
}

0 comments on commit 4995d0b

Please sign in to comment.