aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-01-08 10:57:56 -0500
committerGitHub <noreply@github.com>2024-01-08 16:57:56 +0100
commita4c42054306a5c5ec6e3daeb2ff98e9c816b0b9a (patch)
tree86fb52cc45bb3e973a76d0e43a7d2f306cbb7844 /src/main/java/at
parent8559bcec78048bdabd0e19bbeead4218930201be (diff)
downloadskyhanni-a4c42054306a5c5ec6e3daeb2ff98e9c816b0b9a.tar.gz
skyhanni-a4c42054306a5c5ec6e3daeb2ff98e9c816b0b9a.tar.bz2
skyhanni-a4c42054306a5c5ec6e3daeb2ff98e9c816b0b9a.zip
option to hide pet candy count on max + fix pet lvl regex (#857)
Added option to hide pet candy count on maxed out pets. #857
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/PetCandyDisplayConfig.java20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt6
6 files changed, 47 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index b9263890a..59254412a 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -340,6 +340,7 @@ import at.hannibal2.skyhanni.utils.EntityOutlineRenderer
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging
import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternManager
import kotlinx.coroutines.CoroutineName
@@ -420,6 +421,7 @@ class SkyHanniMod {
loadModule(BingoCardReader())
loadModule(GardenBestCropTime())
loadModule(TrackerManager)
+ loadModule(SkyBlockItemModifierUtils)
// APIs
loadModule(BazaarApi())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
index 8fc9239a1..c2701c61b 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")
- const val CONFIG_VERSION = 20
+ const val CONFIG_VERSION = 22
fun JsonElement.at(chain: List<String>, 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/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
index 53a70019b..350f321f2 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
@@ -94,6 +94,11 @@ public class MiscConfig {
public TrackerConfig tracker = new TrackerConfig();
@Expose
+ @ConfigOption(name = "Pet Candy Display", desc = "")
+ @Accordion
+ public PetCandyDisplayConfig petCandy = new PetCandyDisplayConfig();
+
+ @Expose
@ConfigOption(name = "Exp Bottles", desc = "Hides all the experience orbs lying on the ground.")
@ConfigEditorBoolean
@FeatureToggle
@@ -154,12 +159,6 @@ public class MiscConfig {
public Position playerMovementSpeedPos = new Position(394, 124, false, true);
@Expose
- @ConfigOption(name = "Pet Candy Used", desc = "Show the number of Pet Candy used on a pet.")
- @ConfigEditorBoolean
- @FeatureToggle
- public boolean petCandyUsed = true;
-
- @Expose
@ConfigOption(name = "Server Restart Title", desc = "Show a title with seconds remaining until the server restarts after a Game Update or Scheduled Restart.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/PetCandyDisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/PetCandyDisplayConfig.java
new file mode 100644
index 000000000..57d97459b
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/PetCandyDisplayConfig.java
@@ -0,0 +1,20 @@
+package at.hannibal2.skyhanni.config.features.misc;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
+public class PetCandyDisplayConfig {
+ @Expose
+ @ConfigOption(name = "Pet Candy Used", desc = "Show the number of Pet Candy used on a pet.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean showCandy = true;
+
+ @Expose
+ @ConfigOption(name = "Hide On Maxed", desc = "Hides the candy count on pets that are max level.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean hideOnMaxed = false;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt
index 87def5df3..886827e23 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt
@@ -1,19 +1,28 @@
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getMaxPetLevel
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetCandyUsed
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class PetCandyUsedDisplay {
+ private val config get() = SkyHanniMod.feature.misc.petCandy
+
@SubscribeEvent
fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) {
val stack = event.stack ?: return
if (!LorenzUtils.inSkyBlock || stack.stackSize != 1) return
- if (!SkyHanniMod.feature.misc.petCandyUsed) return
+ if (!config.showCandy) return
+
+ if (config.hideOnMaxed) {
+ if (stack.getPetLevel() == stack.getMaxPetLevel()) return
+ }
val petCandyUsed = stack.getPetCandyUsed() ?: return
if (petCandyUsed == 0) return
@@ -24,4 +33,9 @@ class PetCandyUsedDisplay {
event.drawSlotText(x, y, stackTip, .9f)
}
+
+ @SubscribeEvent
+ fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
+ event.move(22, "misc.petCandyUsed", "misc.petCandy.showCandy")
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
index 82a6b076f..2d97c0564 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonObject
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
@@ -17,8 +18,7 @@ import java.util.Locale
object SkyBlockItemModifierUtils {
private val drillPartTypes = listOf("drill_part_upgrade_module", "drill_part_engine", "drill_part_fuel_tank")
- // TODO USE SH-REPO
- private val petLevelPattern = "§7\\[Lvl (?<level>.*)\\] .*".toPattern()
+ private val petLevelPattern by RepoPattern.pattern("utils.item.petlevel", "(?:§f§f)?§7\\[Lvl (?<level>\\d+)] .*")
fun ItemStack.getHotPotatoCount() = getAttributeInt("hot_potato_count")
@@ -100,6 +100,8 @@ object SkyBlockItemModifierUtils {
return 0
}
+ fun ItemStack.getMaxPetLevel() = if (this.getInternalName() == "GOLDEN_DRAGON;4".asInternalName()) 200 else 100
+
fun ItemStack.getDrillUpgrades() = getExtraAttributes()?.let {
val list = mutableListOf<NEUInternalName>()
for (attributes in it.keySet) {