diff options
author | NetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com> | 2023-10-22 11:38:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-22 17:38:20 +0200 |
commit | 20ccdd23d0abf8536bf9714551a49d3aa5a2acce (patch) | |
tree | 5e21b573fff0f9901b10ad454273db218caefd06 /src/main | |
parent | 12e8ec96cb2d79057344b706a44843166e891863 (diff) | |
download | skyhanni-20ccdd23d0abf8536bf9714551a49d3aa5a2acce.tar.gz skyhanni-20ccdd23d0abf8536bf9714551a49d3aa5a2acce.tar.bz2 skyhanni-20ccdd23d0abf8536bf9714551a49d3aa5a2acce.zip |
Add AFK to Discord Rich Presence Dynamic (#570)
Added AFK time to Discord RPC #570
Diffstat (limited to 'src/main')
3 files changed, 25 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index 23dcd5429..dd029147c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -258,9 +258,10 @@ public class MiscConfig { "Slayer", "Stacking Enchantment", "Dungeon", + "AFK Indicator" } ) - public List<Integer> autoPriority = new ArrayList<>(Arrays.asList(0, 1, 2, 3)); + public List<Integer> autoPriority = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4)); @Expose @ConfigOption(name = "Dynamic Fallback", desc = "What to show when none of your \"Dynamic Priority\" statuses are active.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index 81ea37edb..a4469398b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -6,10 +6,12 @@ import at.hannibal2.skyhanni.SkyHanniMod.Companion.consoleLog import at.hannibal2.skyhanni.SkyHanniMod.Companion.coroutineScope import at.hannibal2.skyhanni.SkyHanniMod.Companion.feature import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle +import at.hannibal2.skyhanni.utils.SimpleTimeMark import com.google.gson.JsonObject import com.jagrosh.discordipc.IPCClient import com.jagrosh.discordipc.IPCListener @@ -197,4 +199,12 @@ object DiscordRPCManager : IPCListener { LorenzUtils.chat("§c[SkyHanni] Unable to start Discord Rich Presence! Please report this on Discord and ping @netheriteminer.") } } + + + // Events that change things in DiscordStatus + @SubscribeEvent + fun onKeybind(event: LorenzKeyPressEvent) { + if (!isEnabled() || !feature.misc.discordRPC.autoPriority.contains(4)) return // autoPriority 4 is dynamic afk + beenAfkFor = SimpleTimeMark.now() + } } 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 7e0f7b310..b270f8b04 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 @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData.Companion.getTabList @@ -29,6 +30,7 @@ import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound import java.util.function.Supplier import java.util.regex.Pattern +import kotlin.time.Duration.Companion.minutes var lastKnownDisplayStrings: MutableMap<DiscordStatus, String> = mutableMapOf() // if the displayMessageSupplier is ever a placeholder, return from this instead @@ -92,6 +94,8 @@ private fun getVisitingName(): String { return "Someone" } +var beenAfkFor = SimpleTimeMark.now() + enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) { NONE(null), @@ -363,6 +367,11 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) "$floor Kills: $amountKills ($time)" } } + }), + + AFK({ + if (beenAfkFor.passedSince() > 5.minutes) "AFK for ${beenAfkFor.passedSince()} minutes" + else AutoStatus.AFK.placeholderText }) ; @@ -372,11 +381,14 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) } return "" } + } enum class AutoStatus(val placeholderText: String, val correspondingDiscordStatus: DiscordStatus) { CROP_MILESTONES("Not farming!", DiscordStatus.CROP_MILESTONES), SLAYER("Planning to do a slayer quest", DiscordStatus.SLAYER), STACKING("Stacking placeholder (should never be visible)", DiscordStatus.STACKING), - DUNGEONS("Dungeons placeholder (should never be visible)", DiscordStatus.DUNGEONS); + DUNGEONS("Dungeons placeholder (should never be visible)", DiscordStatus.DUNGEONS), + AFK("This person is not afk (should never be visible)", DiscordStatus.AFK), + ; }
\ No newline at end of file |