aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-15 10:36:57 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-15 10:36:57 +0200
commit5eae6a82b10cca07f3148f4d831ce285051634ca (patch)
treeae669f050b2f2aa8caeb3fde92dac7c07919d656 /src/main/java
parentb1a2491e9a84b8a4a6261b43f97d3a907d979f06 (diff)
downloadskyhanni-5eae6a82b10cca07f3148f4d831ce285051634ca.tar.gz
skyhanni-5eae6a82b10cca07f3148f4d831ce285051634ca.tar.bz2
skyhanni-5eae6a82b10cca07f3148f4d831ce285051634ca.zip
Added /shcopyinternalname and hotkey to copy internal names of items
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt4
6 files changed, 52 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index c82a7a46d..69fc0c83a 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -247,6 +247,10 @@ object Commands {
"shtestmessage",
"Sends a custom chat message client side in the chat"
) { TestChatCommand.command(it) }
+ registerCommand(
+ "shcopyinternalname",
+ "Copies the internal name of the item in hand to the clipboard."
+ ) { SkyHanniDebugsAndTests.copyItemInternalName() }
}
private fun internalCommands() {
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 e0f62630c..2c5189bbc 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java
@@ -47,19 +47,25 @@ public class DevConfig {
public boolean showInternalName = false;
@Expose
- @ConfigOption(name = "Show NPC Price", desc = "Show NPC price in item lore.")
+ @ConfigOption(name = "Show empty internal names", desc = "Shows internal name even for items with none.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
- public boolean showNpcPrice = false;
+ public boolean showEmptyNames = false;
@Expose
- @ConfigOption(name = "Show empty internal names", desc = "Shows internal name even for items with none.")
+ @ConfigOption(name = "Copy Internal Name", desc = "Copies the internal name of an item on key press in the clipboard.")
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ @ConfigAccordionId(id = 0)
+ public int copyInternalName = Keyboard.KEY_NONE;
+
+ @Expose
+ @ConfigOption(name = "Show NPC Price", desc = "Show NPC price in item lore.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
- public boolean showEmptyNames = false;
+ public boolean showNpcPrice = false;
@Expose
- @ConfigOption(name = "Show item UUID", desc = "Show the Unique Identifier of items. in the lore.")
+ @ConfigOption(name = "Show item UUID", desc = "Show the Unique Identifier of items in the lore.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
public boolean showItemUuid = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
index f90fbd625..b89677aa0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
@@ -18,7 +18,6 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
-import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.round
@@ -44,7 +43,7 @@ class CaptureFarmingGear {
val farmingItems = farmingItems ?: return
val resultList = mutableListOf<String>()
- val itemStack = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem() ?: return
+ val itemStack = InventoryUtils.getItemInHand() ?: return
val itemID = itemStack.getInternalName_old()
resultList.add(itemStack.displayName.toString())
resultList.add(itemID)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
index e50a845da..9b1c920bd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
@@ -17,7 +17,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData.Companion.getTabList
import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay.getCurrentPet
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
-import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import java.util.function.Supplier
@@ -297,7 +296,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
} else item.getSubCompound("ExtraAttributes", false)
}
- val itemInHand = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem()
+ val itemInHand = InventoryUtils.getItemInHand()
val itemName = itemInHand?.displayName?.removeColor() ?: ""
val extraAttributes = getExtraAttributes(itemInHand)
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
index d330cc1d0..18baa8a5a 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt
@@ -11,12 +11,15 @@ import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
+import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.nbt.NBTTagCompound
+import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -230,6 +233,36 @@ class SkyHanniDebugsAndTests {
OSUtils.copyToClipboard(builder.toString())
LorenzUtils.chat("§eCopied SkyHanni debug data to clipboard.")
}
+
+ fun copyItemInternalName() {
+ val hand = InventoryUtils.getItemInHand()
+ if (hand == null) {
+ LorenzUtils.chat("§cNo item in hand!")
+ return
+ }
+
+ val internalName = hand.getInternalNameOrNull()
+ if (internalName == null) {
+ LorenzUtils.chat("§cInternal name is null for item ${hand.name}")
+ return
+ }
+
+ val rawInternalName = internalName.asString()
+ OSUtils.copyToClipboard(rawInternalName)
+ LorenzUtils.chat("§eCopied internal name §7$rawInternalName §eto the clipboard!")
+ }
+ }
+
+ @SubscribeEvent
+ fun onKeybind(event: GuiScreenEvent.KeyboardInputEvent.Post) {
+ if (!OSUtils.isKeyHeld(SkyHanniMod.feature.dev.copyInternalName)) return
+ val gui = event.gui as? GuiContainer ?: return
+ val focussedSlot = gui.slotUnderMouse ?: return
+ val stack = focussedSlot.stack ?: return
+ val internalName = stack.getInternalNameOrNull() ?: return
+ val rawInternalName = internalName.asString()
+ OSUtils.copyToClipboard(rawInternalName)
+ LorenzUtils.chat("§eCopied internal name §7$rawInternalName §eto the clipboard!")
}
@SubscribeEvent
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 d2f0b60ab..4fc82bbc3 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt
@@ -1,18 +1,18 @@
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
-import net.minecraft.client.Minecraft
object CopyItemCommand {
fun command(args: Array<String>) {
try {
val resultList = mutableListOf<String>()
- val itemStack = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem()!!
+ val itemStack = InventoryUtils.getItemInHand() ?: return
resultList.add("ITEM LORE")
resultList.add("display name: '" + itemStack.displayName.toString() + "'")
val itemID = itemStack.getInternalName_old()