diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt | 46 |
2 files changed, 34 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt index 95399fb1e..3f14885c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.test.command.CopyItemCommand.copyItemToClipboard import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.utils.ItemStackTypeAdapterFactory import at.hannibal2.skyhanni.utils.KSerializable @@ -21,6 +22,8 @@ import java.io.InputStreamReader import java.io.Reader object TestExportTools { + private val config get() = SkyHanniMod.feature.dev.debug + val gson = GsonBuilder() .registerTypeAdapterFactory(KotlinTypeAdapterFactory()) .registerTypeAdapter(NBTTagCompound::class.java, NBTTypeAdapter) @@ -49,13 +52,17 @@ object TestExportTools { @SubscribeEvent fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) { - if (!SkyHanniMod.feature.dev.debug.copyNBTDataCompressed.isKeyHeld()) return + if (!config.copyNBTDataCompressed.isKeyHeld() && !config.copyNBTData.isKeyHeld()) return val gui = event.gui as? GuiContainer ?: return val focussedSlot = gui.slotUnderMouse ?: return val stack = focussedSlot.stack ?: return + if (config.copyNBTData.isKeyHeld()) { + copyItemToClipboard(stack) + return + } val json = toJson(Item, stack) OSUtils.copyToClipboard(json) - LorenzUtils.chat("Copied test importable to clipbooard") + LorenzUtils.chat("Copied test importable to clipboard") } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt index 06496036d..f3d0d80ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt @@ -6,33 +6,15 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getMinecraftId +import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound object CopyItemCommand { fun command() { 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("minecraft id: '" + itemStack.getMinecraftId() + "'") - resultList.add("lore:") - for (line in itemStack.getLore()) { - resultList.add(" '$line'") - } - resultList.add("") - resultList.add("getTagCompound") - if (itemStack.hasTagCompound()) { - val tagCompound = itemStack.tagCompound - recurseTag(tagCompound, " ", resultList) - } - - val string = resultList.joinToString("\n") - OSUtils.copyToClipboard(string) - LorenzUtils.chat("§e[SkyHanni] Item info copied into the clipboard!") + val itemStack = InventoryUtils.getItemInHand() ?: throw Exception() + copyItemToClipboard(itemStack) } catch (_: Throwable) { LorenzUtils.chat("§c[SkyHanni] No item in hand!") } @@ -53,4 +35,26 @@ object CopyItemCommand { } } + fun copyItemToClipboard(itemStack: ItemStack){ + val resultList = mutableListOf<String>() + resultList.add("ITEM LORE") + resultList.add("display name: '" + itemStack.displayName.toString() + "'") + val itemID = itemStack.getInternalName_old() + resultList.add("internalName: '$itemID'") + resultList.add("minecraft id: '" + itemStack.getMinecraftId() + "'") + resultList.add("lore:") + for (line in itemStack.getLore()) { + resultList.add(" '$line'") + } + resultList.add("") + resultList.add("getTagCompound") + if (itemStack.hasTagCompound()) { + val tagCompound = itemStack.tagCompound + recurseTag(tagCompound, " ", resultList) + } + + val string = resultList.joinToString("\n") + OSUtils.copyToClipboard(string) + LorenzUtils.chat("§e[SkyHanni] Item info copied into the clipboard!") + } }
\ No newline at end of file |