aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-09-11 13:56:56 +0200
committerGitHub <noreply@github.com>2024-09-11 13:56:56 +0200
commitc48d82d06f375139f1e0a0a32ffd6d2f4aa98546 (patch)
treeae3213d6bc097abb3f288bd0e8ea07badfafd1db /src/main/java/at/hannibal2/skyhanni
parent7aea6aa7b3774a3797f68a503eb42e99e88c2e56 (diff)
downloadskyhanni-c48d82d06f375139f1e0a0a32ffd6d2f4aa98546.tar.gz
skyhanni-c48d82d06f375139f1e0a0a32ffd6d2f4aa98546.tar.bz2
skyhanni-c48d82d06f375139f1e0a0a32ffd6d2f4aa98546.zip
Feature: Pet Nametag (#1880)
Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetNametagConfig.java19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/pets/CurrentPetDisplay.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetCandyUsedDisplay.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetItemDisplay.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt56
7 files changed, 84 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java
index 8cd295249..02c2b2ed4 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetConfig.java
@@ -31,6 +31,11 @@ public class PetConfig {
public PetExperienceToolTipConfig petExperienceToolTip = new PetExperienceToolTipConfig();
@Expose
+ @ConfigOption(name = "Pet Nametag", desc = "")
+ @Accordion
+ public PetNametagConfig nametag = new PetNametagConfig();
+
+ @Expose
@ConfigOption(name = "Hide Autopet Messages", desc = "Hide the autopet messages from chat.\n" +
"§eRequires the display to be enabled.")
@ConfigEditorBoolean
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetNametagConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetNametagConfig.java
new file mode 100644
index 000000000..4da1b8160
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/pets/PetNametagConfig.java
@@ -0,0 +1,19 @@
+package at.hannibal2.skyhanni.config.features.misc.pets;
+
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+public class PetNametagConfig {
+
+ @Expose
+ @ConfigOption(name = "Hide Pet Level", desc = "Hide the pet level above the pet.")
+ @ConfigEditorBoolean
+ public boolean hidePetLevel = false;
+
+ @Expose
+ @ConfigOption(name = "Hide Max Pet Level", desc = "Hide the pet level above the pet if it is max level.")
+ @ConfigEditorBoolean
+ public boolean hideMaxPetLevel = false;
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/CurrentPetDisplay.kt
index 1c93d6b3c..6f74f353d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/CurrentPetDisplay.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.misc
+package at.hannibal2.skyhanni.features.misc.pets
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetCandyUsedDisplay.kt
index c80c30f09..e331e6c75 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetCandyUsedDisplay.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.misc
+package at.hannibal2.skyhanni.features.misc.pets
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt
index 3a7cf784a..8e544a3df 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetExpTooltip.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.misc
+package at.hannibal2.skyhanni.features.misc.pets
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetItemDisplay.kt
index 12e82a893..9d3349c5b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetItemDisplay.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.misc
+package at.hannibal2.skyhanni.features.misc.pets
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt
new file mode 100644
index 000000000..f3b16069e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/PetNametag.kt
@@ -0,0 +1,56 @@
+package at.hannibal2.skyhanni.features.misc.pets
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
+import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.chat.Text.asComponent
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@SkyHanniModule
+object PetNametag {
+
+ private val config get() = SkyHanniMod.feature.misc.pets.nametag
+
+ /**
+ * REGEX-TEST: §8[§7Lv99§8] Ammonite
+ * REGEX-TEST: §8[§7Lv100§8] Endermite§5 ✦
+ */
+ private val petNametagPattern by RepoPattern.pattern(
+ "pet.nametag",
+ "(?<start>§8\\[§7Lv(?<lvl>\\d+)§8]) (?<rarity>§.)(?<pet>[\\w\\s]+)(?<skin>§. ✦)?",
+ )
+
+ @SubscribeEvent
+ fun onNameTagRender(event: EntityDisplayNameEvent) {
+ if (!isEnabled()) return
+ if (event.entity !is EntityArmorStand) return
+
+ petNametagPattern.matchMatcher(event.chatComponent.unformattedText) {
+ val start = group("start")
+ val lvl = group("lvl").formatInt()
+ val rarity = group("rarity")
+ val pet = group("pet")
+ val skin = groupOrNull("skin") ?: ""
+
+ val hideLevel = config.hidePetLevel
+ val hideMaxLevel = config.hideMaxPetLevel && (lvl == 100 || lvl == 200)
+
+ val text = buildString {
+ if (!hideLevel && !hideMaxLevel) {
+ append(start)
+ }
+ append(rarity + pet + skin)
+ }
+
+ event.chatComponent = text.asComponent()
+ }
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && (config.hidePetLevel || config.hideMaxPetLevel)
+}