aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
blob: 4fc82bbc305297d0d91bdbcda775f75429e888de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package at.hannibal2.skyhanni.test.command

import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.OSUtils

object CopyItemCommand {

    fun command(args: Array<String>) {
        try {
            val resultList = mutableListOf<String>()
            val itemStack = InventoryUtils.getItemInHand() ?: return
            resultList.add("ITEM LORE")
            resultList.add("display name: '" + itemStack.displayName.toString() + "'")
            val itemID = itemStack.getInternalName_old()
            resultList.add("internalName: '$itemID'")
            resultList.add("")
            for (line in itemStack.getLore()) {
                resultList.add("'$line'")
            }
            resultList.add("")
            resultList.add("getTagCompound")
            if (itemStack.hasTagCompound()) {
                val tagCompound = itemStack.tagCompound
                for (s in tagCompound.keySet) {
                    resultList.add("  '$s'")
                }
                if (tagCompound.hasKey("ExtraAttributes")) {
                    resultList.add("")
                    resultList.add("ExtraAttributes")
                    val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes")
                    SkyHanniDebugsAndTests.runn(extraAttributes, "  .  ")
                }
            }

            val string = resultList.joinToString("\n")
            OSUtils.copyToClipboard(string)
            LorenzUtils.chat("§e[SkyHanni] item info copied into the clipboard!")
        } catch (_: Throwable) {
            LorenzUtils.chat("§c[SkyHanni] No item in hand!")
        }
    }
}