aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/MagicalPowerConfig.java19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/MagicalPowerDisplay.kt132
4 files changed, 159 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java
index f66f784c2..6c43591a5 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java
@@ -119,6 +119,11 @@ public class InventoryConfig {
public PageScrollingConfig pageScrolling = new PageScrollingConfig();
@Expose
+ @ConfigOption(name = "Magical Power Display", desc = "")
+ @Accordion
+ public MagicalPowerConfig magicalPower = new MagicalPowerConfig();
+
+ @Expose
@ConfigOption(name = "Item Number", desc = "Showing the item number as a stack size for these items.")
@ConfigEditorDraggableList
public List<ItemNumberEntry> itemNumberAsStackSize = new ArrayList<>(Arrays.asList(
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/MagicalPowerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/MagicalPowerConfig.java
new file mode 100644
index 000000000..ef6b76da3
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/MagicalPowerConfig.java
@@ -0,0 +1,19 @@
+package at.hannibal2.skyhanni.config.features.inventory;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+public class MagicalPowerConfig {
+ @Expose
+ @ConfigOption(name = "Magical Power Display", desc = "Show Magical Power as stack size inside Accessory Bag and Auction House.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Colored", desc = "Whether to make the numbers colored.")
+ @ConfigEditorBoolean
+ public boolean colored = false;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java
index 51be4daf1..e7a7565bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java
@@ -670,6 +670,9 @@ public class ProfileSpecificStorage {
public UpgradeReminder.CommunityShopUpgrade communityShopProfileUpgrade = null;
@Expose
+ @Nullable
+ public Integer abiphoneContactAmount = null;
+
public Map<Integer, HoppityEventStats> hoppityEventStats = new HashMap<>();
public static class HoppityEventStats {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MagicalPowerDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MagicalPowerDisplay.kt
new file mode 100644
index 000000000..e7b8ea26c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MagicalPowerDisplay.kt
@@ -0,0 +1,132 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.events.RenderItemTipEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.test.command.ErrorManager
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemCategory
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
+import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
+import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzRarity
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@SkyHanniModule
+object MagicalPowerDisplay {
+ private val config get() = SkyHanniMod.feature.inventory.magicalPower
+ private var contactAmount: Int?
+ get() = ProfileStorageData.profileSpecific?.abiphoneContactAmount
+ private set(value) {
+ ProfileStorageData.profileSpecific?.abiphoneContactAmount = value
+ }
+
+ private val hegemonyArtifact = "HEGEMONY_ARTIFACT".asInternalName()
+ private val riftPrism = "RIFT_PRISM".asInternalName()
+
+ /**
+ * REGEX-TEST: Accessory Bag
+ * REGEX-TEST: Accessory Bag (1/75)
+ * REGEX-TEST: Accessory Bag (909/394294)
+ * REGEX-TEST: Auctions Browser
+ * REGEX-TEST: Auctions: "ligma"
+ * REGEX-TEST: Auctions: ""sugoma""
+ * */
+ private val acceptedInvPattern by RepoPattern.pattern(
+ "inv.acceptable",
+ "^(Accessory Bag(?: \\(\\d+\\/\\d+\\))?|Auctions Browser|Manage Auctions|Auctions: \".*\"?)$",
+ )
+
+ private val abiphoneGroup = RepoPattern.group("data.abiphone")
+
+ /**
+ * REGEX-TEST: Abiphone X Plus
+ * REGEX-TEST: Abiphone X Plus Special Edition
+ * REGEX-TEST: Abiphone XI Ultra Style
+ * REGEX-TEST: Abiphone XII Mega Color
+ * REGEX-TEST: Abiphone XIII Pro
+ * REGEX-TEST: Abiphone XIV Enormous Purple
+ * REGEX-TEST: Abiphone Flip
+ * */
+ private val abiphoneNamePattern by abiphoneGroup.pattern(
+ "name",
+ "Abiphone .*",
+ )
+
+ /**
+ * REGEX-TEST: Your contacts: 0/0
+ * REGEX-TEST: Your contacts: 1/75
+ * REGEX-TEST: Your contacts: 52/60
+ * */
+ private val yourContactPattern by abiphoneGroup.pattern(
+ "contacts",
+ "Your contacts: (?<contacts>\\d+)\\/\\d+",
+ )
+
+ @SubscribeEvent
+ fun onRenderItemTip(event: RenderItemTipEvent) {
+ if (!isEnabled()) return
+ if (!acceptedInvPattern.matches(InventoryUtils.openInventoryName().removeColor())) return
+
+ val item = event.stack
+ val rarity = item.getAccessoryRarityOrNull() ?: return
+ val internalName = item.getInternalNameOrNull() ?: return
+
+ var endMP = rarity.toMP() ?: ErrorManager.skyHanniError(
+ "Unknown rarity '$rarity' for item '${item.displayName}§7'",
+ )
+
+ when (internalName) {
+ hegemonyArtifact -> endMP *= 2
+ riftPrism -> endMP = 11
+ else -> if (internalName.isAbicase()) endMP += (contactAmount ?: 0) / 2
+ }
+
+ event.stackTip = "${if (config.colored) rarity.chatColorCode else "§7"}${endMP}"
+ }
+
+ @SubscribeEvent
+ fun onInventoryOpened(event: InventoryFullyOpenedEvent) {
+ if (!isEnabled()) return
+ if (!abiphoneNamePattern.matches(event.inventoryName)) return
+
+ val theBookLore = event.inventoryItems[51]?.getLore() ?: return
+ for (line in theBookLore) {
+ yourContactPattern.matchMatcher(line.removeColor()) {
+ contactAmount = group("contacts").toInt()
+ return
+ }
+ }
+ }
+
+ private fun NEUInternalName.isAbicase(): Boolean = this.startsWith("ABICASE_")
+
+ private fun LorenzRarity.toMP(): Int? = when (this) {
+ LorenzRarity.COMMON, LorenzRarity.SPECIAL -> 3
+ LorenzRarity.UNCOMMON, LorenzRarity.VERY_SPECIAL -> 5
+ LorenzRarity.RARE -> 8
+ LorenzRarity.EPIC -> 12
+ LorenzRarity.LEGENDARY -> 16
+ LorenzRarity.MYTHIC -> 22
+ else -> null
+ }
+
+ private fun ItemStack.getAccessoryRarityOrNull(): LorenzRarity? {
+ val category = this.getItemCategoryOrNull() ?: return null
+ if (category != ItemCategory.ACCESSORY && category != ItemCategory.HATCESSORY) return null
+ return this.getItemRarityOrNull()
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
+}