aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorPhoebe <77941535+catgirlseraid@users.noreply.github.com>2024-05-25 05:34:37 +1200
committerGitHub <noreply@github.com>2024-05-24 19:34:37 +0200
commit9399de6e5814cd599aec276aa3663d0f95cc127f (patch)
tree71809f4d14fff5c25ff111d170cc9230c5607c4a /src/main/java
parent8158ada47f0a1dd0fcdc982c36fb2646f0481e43 (diff)
downloadskyhanni-9399de6e5814cd599aec276aa3663d0f95cc127f.tar.gz
skyhanni-9399de6e5814cd599aec276aa3663d0f95cc127f.tar.bz2
skyhanni-9399de6e5814cd599aec276aa3663d0f95cc127f.zip
Add: click on playtime item to copy (#1807)
Co-authored-by: SeRaid <77941535+SeRaid743@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt6
3 files changed, 49 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index a2e800678..54a69f87b 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -328,6 +328,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
@@ -932,7 +933,8 @@ class SkyHanniMod {
loadModule(MaxPurseItems())
loadModule(SuperCraftFeatures)
loadModule(InfernoMinionFeatures())
- loadModule(LimboPlaytime())
+ loadModule(LimboPlaytime)
+ loadModule(CopyPlaytime)
loadModule(RareDropMessages())
loadModule(CraftMaterialsFromBazaar())
loadModule(DungeonShadowAssassinNotification())
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt
new file mode 100644
index 000000000..89d1c5741
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt
@@ -0,0 +1,41 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.data.HypixelData
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.features.misc.limbo.LimboPlaytime
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.ClipboardUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object CopyPlaytime {
+ @SubscribeEvent(priority = EventPriority.LOWEST)
+ fun onTooltip(event: LorenzToolTipEvent) {
+ if (InventoryUtils.openInventoryName() != "Detailed /playtime") return
+ if (event.slot.slotNumber != 4) return
+
+ event.toolTip.add("")
+ event.toolTip.add("§eClick to Copy!")
+ }
+
+ @SubscribeEvent
+ fun onSlotClicked(event: GuiContainerEvent.SlotClickEvent) {
+ if (InventoryUtils.openInventoryName() != "Detailed /playtime") return
+ if (event.slotId != 4) return
+ if (event.clickedButton != 0) return
+
+ event.cancel()
+ val text = LimboPlaytime.tooltipPlaytime.dropLast(2).toMutableList()
+
+ val profile = HypixelData.profileName.firstLetterUppercase()
+ text.add(0, "${LorenzUtils.getPlayerName()}'s - $profile Playtime Stats")
+
+ ClipboardUtils.copyToClipboard(text.joinToString("\n") { it.removeColor() })
+ ChatUtils.chat("Copied playtime stats into clipboard.")
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
index 89162c619..82ea1f873 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
@@ -18,7 +18,7 @@ import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
-class LimboPlaytime {
+object LimboPlaytime {
private lateinit var modifiedList: MutableList<String>
private var setMinutes = false
private val patternGroup = RepoPattern.group("misc.limbo.tooltip")
@@ -31,6 +31,8 @@ class LimboPlaytime {
"§5§o§b([\\d.,]+) hours.+\$"
)
+ var tooltipPlaytime = mutableListOf<String>()
+
private var wholeMinutes = 0
private var hoursString: String = ""
@@ -161,6 +163,8 @@ class LimboPlaytime {
toolTip.addAll(modifiedList)
}
toolTip.addAll(lastList)
+
+ tooltipPlaytime = toolTip
}
private fun findFloatDecimalPlace(input: Float): Int {