Skip to content

Commit

Permalink
copy playtime
Browse files Browse the repository at this point in the history
  • Loading branch information
catgirlseraid committed May 16, 2024
1 parent 5d4c57e commit 6dab56d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ import at.hannibal2.skyhanni.features.misc.BrewingStandOverlay
import at.hannibal2.skyhanni.features.misc.ButtonOnPause
import at.hannibal2.skyhanni.features.misc.CollectionTracker
import at.hannibal2.skyhanni.features.misc.ContributorManager
import at.hannibal2.skyhanni.features.misc.CopyPlaytime
import at.hannibal2.skyhanni.features.misc.CurrentPetDisplay
import at.hannibal2.skyhanni.features.misc.CustomTextBox
import at.hannibal2.skyhanni.features.misc.ExpOrbsOnGroundHider
Expand Down Expand Up @@ -937,6 +938,7 @@ class SkyHanniMod {
loadModule(ColdOverlay())
loadModule(QuiverDisplay())
loadModule(QuiverWarning())
loadModule(CopyPlaytime)

init()

Expand Down
36 changes: 36 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package at.hannibal2.skyhanni.features.misc

import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.utils.ClipboardUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object CopyPlaytime {

@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (InventoryUtils.openInventoryName() != "Detailed /playtime") return
if (event.slot.slotNumber != 4) return

event.toolTip.add("")
event.toolTip.add("§7[§b§lClick to Copy§7]")
}

@SubscribeEvent
fun onSlotClicked(event: GuiContainerEvent.SlotClickEvent) {
if (InventoryUtils.openInventoryName() != "Detailed /playtime") return
if (event.slotId != 4) return

val text = event.item?.getLore()?.toMutableList() ?: return

if (event.clickedButton == 0) {
event.isCanceled = true
text.add(0, "${LorenzUtils.getPlayerName()}'s Playtime Stats")
ClipboardUtils.copyToClipboard(text.joinToString("\n") { it.removeColor() })
}
}
}

0 comments on commit 6dab56d

Please sign in to comment.