Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Accessory MP as stack size #2243

Merged
merged 34 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
706eefb
feat: mp as stack size
minhperry Jul 20, 2024
9ba8a35
fix: fix edge cases
minhperry Jul 20, 2024
fe75cb8
refactor: rename and restructure variables
minhperry Jul 20, 2024
7f71190
refactor: spacing
minhperry Jul 20, 2024
a05c6d8
test: add regex tests
minhperry Jul 21, 2024
491fff0
refactor: move and rename class to correct place
minhperry Jul 21, 2024
c7da6c6
fix: resolving conversations pt 1
minhperry Jul 21, 2024
d53cc47
fix: resolving conversations pt final / re-add isAcc
minhperry Jul 21, 2024
e954d31
clean: cleanup spaces
minhperry Jul 21, 2024
589e7d8
fix: map -> fun
minhperry Jul 21, 2024
7c4d267
refactor: change 4 convention
minhperry Jul 21, 2024
7e44efa
feat: add edge case abicases
minhperry Jul 22, 2024
5e0f150
fix: pattern for AH
minhperry Jul 24, 2024
bf467aa
Merge branch 'refs/heads/beta' into fork/minhperry/mp-stack-size
hannibal002 Jul 24, 2024
3587ce9
fix: use built-in rarity detection
minhperry Jul 24, 2024
1e4b275
Merge remote-tracking branch 'origin/mp-stack-size' into mp-stack-size
minhperry Jul 24, 2024
b20f956
clean: cleanup debug code
minhperry Jul 24, 2024
e0b54fd
fix: resolving Thunder's conversations pt 1
minhperry Jul 25, 2024
5cd784a
Merge branch 'refs/heads/beta' into fork/minhperry/mp-stack-size
hannibal002 Jul 28, 2024
5ebab78
fixed regex test
hannibal002 Jul 28, 2024
8cb6a11
formatting
hannibal002 Jul 28, 2024
004b5d6
Merge branch 'hannibal002:beta' into mp-stack-size
minhperry Aug 14, 2024
ffee790
fix: resolving Thunder's conversations pt 2
minhperry Aug 19, 2024
e832a22
fix: resolving Hanni's conv pt 1
minhperry Aug 19, 2024
2e53def
Merge remote-tracking branch 'origin/mp-stack-size' into mp-stack-size
minhperry Aug 19, 2024
8cd35dd
refactor: regex tests
minhperry Aug 19, 2024
5e06829
fix: default to 0 contact
minhperry Aug 19, 2024
561adeb
fix: nullability 2
minhperry Aug 21, 2024
511fbe4
fix: nullability 2.5
minhperry Aug 21, 2024
3cb2167
Merge branch 'beta' into mp-stack-size
minhperry Aug 26, 2024
ce36e85
Merge branch 'hannibal002:beta' into mp-stack-size
minhperry Aug 26, 2024
7d2496a
Merge branch 'refs/heads/beta' into fork/minhperry/mp-stack-size
hannibal002 Sep 7, 2024
a3b9ec3
fixed regex tests not working
hannibal002 Sep 7, 2024
603583e
code cleanup
hannibal002 Sep 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public class InventoryConfig {
@Accordion
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
minhperry marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,6 @@ public class MiscConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean maintainGameVolume = false;

minhperry marked this conversation as resolved.
Show resolved Hide resolved

}
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,7 @@ public static class WardrobeStorage {

@Expose
public UpgradeReminder.CommunityShopUpgrade communityShopProfileUpgrade = null;

@Expose
public int abiphoneContactAmount = -1;
minhperry marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package at.hannibal2.skyhanni.features.misc

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.events.InventoryOpenEvent
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.Companion.asInternalName
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import io.github.moulberry.notenoughupdates.util.stripControlCodes
minhperry marked this conversation as resolved.
Show resolved Hide resolved
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
minhperry marked this conversation as resolved.
Show resolved Hide resolved
get() = ProfileStorageData.profileSpecific?.abiphoneContactAmount ?: -1
private set(value) { ProfileStorageData.profileSpecific?.abiphoneContactAmount = value }

/*
* 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(
minhperry marked this conversation as resolved.
Show resolved Hide resolved
"inv.acceptable",
"""^(Accessory Bag(?: \(\d+/\d+\))?|Auctions Browser|Manage Auctions|Auctions: ".*"?)$"""
)

@SubscribeEvent
fun onRenderItemTip(event: RenderItemTipEvent) {
if (!isEnabled()) return
if (!acceptedInvPattern.matches(InventoryUtils.openInventoryName().stripControlCodes())) return

val item = event.stack
val rarity = item.isAccessory() ?: return
val itemID = item.getInternalNameOrNull() ?: return

var endMP = rarity.toMP() ?: run {
ErrorManager.skyHanniError(
"Unknown rarity '$rarity' for item '${item.displayName}§7'"
)
}
minhperry marked this conversation as resolved.
Show resolved Hide resolved
if (itemID == "HEGEMONY_ARTIFACT".asInternalName())
endMP *= 2
if (itemID == "RIFT_PRISM".asInternalName())
endMP = 11
minhperry marked this conversation as resolved.
Show resolved Hide resolved
if (item.isAbicase())
endMP += contactAmount / 2
minhperry marked this conversation as resolved.
Show resolved Hide resolved
event.stackTip = "${if (config.colored) rarity.chatColorCode else "§7"}${endMP}"
}

@SubscribeEvent
fun onInventoryOpened(event: InventoryOpenEvent) {
minhperry marked this conversation as resolved.
Show resolved Hide resolved
if (!isEnabled()) return
if (event.inventoryName.startsWith("Abiphone")) {
minhperry marked this conversation as resolved.
Show resolved Hide resolved
minhperry marked this conversation as resolved.
Show resolved Hide resolved
val theBookLore = event.inventoryItems[51]?.getLore() ?: return
for (line in theBookLore) {
val stripped = line.stripControlCodes()
if (stripped.startsWith("Your contacts: ")) {
contactAmount = stripped.split(" ")[2].split("/")[0].toInt()
return
}
minhperry marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

private fun ItemStack.isAbicase(): Boolean {
val id = this.getInternalNameOrNull() ?: return false
return id.startsWith("ABICASE_")
}
minhperry marked this conversation as resolved.
Show resolved Hide resolved

private fun LorenzRarity.toMP(): Int? {
return 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
}
}
minhperry marked this conversation as resolved.
Show resolved Hide resolved

private fun ItemStack.isAccessory(): LorenzRarity? {
minhperry marked this conversation as resolved.
Show resolved Hide resolved
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
}
Loading