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/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt117
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt8
5 files changed, 139 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 15baf702d..f96af1007 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -380,6 +380,7 @@ class SkyHanniMod {
loadModule(PacketTest())
loadModule(TestBingo)
loadModule(TestCopyRngMeterValues)
+ loadModule(TestCopyBestiaryValues)
loadModule(HighlightMissingRepoItems())
loadModule(ParkourWaypointSaver())
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
index 08f9fe4e2..6c42d1e82 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
@@ -2,7 +2,12 @@ package at.hannibal2.skyhanni.config.features;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
-import io.github.moulberry.moulconfig.annotations.*;
+import io.github.moulberry.moulconfig.annotations.Accordion;
+import io.github.moulberry.moulconfig.annotations.ConfigAccordionId;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
import org.lwjgl.input.Keyboard;
public class DevConfig {
@@ -65,6 +70,12 @@ public class DevConfig {
public boolean copyRngMeter = false;
@Expose
+ @ConfigOption(name = "Copy Bestiary Data", desc = "Copies the besiary data from the inventory as json in clipboard.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean copyBestiaryData = false;
+
+ @Expose
@ConfigOption(name = "Highlight Missing Repo Items", desc = "Highlights each item in the current inventory that is not in your current NEU repo.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
diff --git a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt
index 790b51c43..b6dab180a 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt
@@ -89,6 +89,7 @@ object OtherInventoryData {
private fun done(inventory: Inventory) {
InventoryFullyOpenedEvent(inventory).postAndCatch()
+ InventoryUpdatedEvent(inventory).postAndCatch()
acceptItems = false
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
new file mode 100644
index 000000000..870752a25
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
@@ -0,0 +1,117 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullOwner
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils.nextAfter
+import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.OSUtils
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import com.google.gson.GsonBuilder
+import com.google.gson.annotations.Expose
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object TestCopyBestiaryValues {
+
+ class BestiarityObject {
+ @Expose
+ var name: String = ""
+
+ @Expose
+ var skullOwner: String = ""
+
+ @Expose
+ var texture: String = ""
+
+ @Expose
+ var cap: Int = 0
+
+ @Expose
+ var mobs: Array<String> = emptyArray()
+
+ @Expose
+ var bracket: Int = 0
+ }
+
+ val pattern = "\\[Lv(?<lvl>.*)] (?<text>.*)".toPattern()
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ fun onLateInventoryOpen(event: InventoryUpdatedEvent) {
+ if (!SkyHanniMod.feature.dev.copyBestiaryData) return
+ SkyHanniTestCommand.displayLine = ""
+
+ val backItem = event.inventoryItems[3 + 9 * 5 + 3]
+ if (backItem == null) {
+// println("first is null!")
+ return
+ }
+ if (backItem.getLore().none { it.contains("Bestiary Milestone") }) {
+// println("wrong first: ${backItem.getLore()}")
+ return
+ }
+
+ val rankingItem = event.inventoryItems[3 + 9 * 5 + 2]
+ if (rankingItem == null) {
+// println("second is null!")
+ return
+ }
+ if (rankingItem.getLore().none { it.contains("Ranking") }) {
+// println("wrong second: ${rankingItem.getLore()}")
+ return
+ }
+
+ val titleItem = event.inventoryItems[4] ?: return
+ copy(titleItem, event.inventoryItems)
+ }
+
+ private fun copy(titleItem: ItemStack, inventoryItems: Map<Int, ItemStack>) {
+ val name = titleItem.name ?: return
+ val titleName = name.split(" ").dropLast(1).joinToString(" ")
+
+ val obj: BestiarityObject = BestiarityObject()
+ obj.name = titleName
+ obj.texture = titleItem.getSkullTexture() ?: "no texture found"
+ obj.skullOwner = titleItem.getSkullOwner() ?: "no skullOwner found"
+
+ val lore = titleItem.getLore()
+ val overallProgress = lore.find { it.contains("Overall Progress") }
+ if (overallProgress == null) {
+ println("overallProgress not found!")
+ return
+ }
+ val capLine = lore.nextAfter(overallProgress) ?: return
+ val rawCap = capLine.substringAfter("/").removeColor().formatNumber()
+ obj.cap = rawCap.toInt()
+
+ val mobs = mutableListOf<String>()
+ for (i in 10..43) {
+ val stack = inventoryItems[i] ?: continue
+ val stackName = stack.name ?: continue
+ pattern.matchMatcher(stackName.removeColor()) {
+ val lvl = group("lvl").toInt()
+ var text = group("text").lowercase().replace(" ", "_")
+
+ val master = text.endsWith("(master)")
+ val masterText = if (master) "master_" else ""
+ if (master) {
+ text = text.split("_").dropLast(1).joinToString("_")
+ }
+ val result = "$masterText${text}_$lvl"
+ mobs.add(result)
+ }
+ }
+ obj.mobs = mobs.toTypedArray()
+
+ val gson = GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create()
+ val text = gson.toJson(obj)
+ OSUtils.copyToClipboard(text)
+
+ SkyHanniTestCommand.displayLine = "Bestiary for $titleName"
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 1683f90e0..3df9e4673 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -141,6 +141,14 @@ object ItemUtils {
.getTagList("textures", Constants.NBT.TAG_COMPOUND).getCompoundTagAt(0).getString("Value")
}
+ fun ItemStack.getSkullOwner(): String? {
+ if (item != Items.skull) return null
+ if (tagCompound == null) return null
+ val nbt = tagCompound
+ if (!nbt.hasKey("SkullOwner")) return null
+ return nbt.getCompoundTag("SkullOwner").getString("Id")
+ }
+
fun ItemStack.getItemRarity(): Int {
//todo make into an enum in future
return when (this.getLore().lastOrNull()?.take(4)) {