-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
8158ada
commit 9399de6
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters