From d7bd34e7a35c8908f1ed8dd1bb934cf36993789c Mon Sep 17 00:00:00 2001 From: Brady Date: Sat, 27 Apr 2024 08:04:42 -0230 Subject: Add SkyCrypt button to RPC (#1526) --- CONTRIBUTING.md | 5 +---- build.gradle.kts | 3 ++- .../skyhanni/config/features/misc/DiscordRPCConfig.java | 5 +++++ .../features/misc/discordrpc/DiscordRPCManager.kt | 15 ++++++++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a58d0b64..28142d32b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -148,10 +148,7 @@ folder for how to properly do this. You also may have to disable repo auto updat ### Discord IPC DiscordIPC is a service that SkyHanni uses to send information from SkyBlock to Discord in Rich Presence.
-Specifically, we use [NetheriteMiner's Fork](https://github.com/NetheriteMiner/DiscordIPC) of a fork of a fork of a fork of -the [original](https://github.com/jagrosh/DiscordIPC). -For info on usage, look -at [DiscordRPCManager.kt](https://github.com/hannibal002/SkyHanni/blob/beta/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt) +For info on usage, look at [DiscordRPCManager.kt](https://github.com/hannibal002/SkyHanni/blob/beta/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt) ### Auto Updater diff --git a/build.gradle.kts b/build.gradle.kts index 5261ab200..9bb903744 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,6 +51,7 @@ repositories { maven("https://repo.nea.moe/releases") maven("https://maven.notenoughupdates.org/releases") maven("https://repo.hypixel.net/repository/Hypixel/") + maven("https://maven.teamresourceful.com/repository/thatgravyboat/") } val shadowImpl: Configuration by configurations.creating { @@ -79,7 +80,7 @@ dependencies { forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") // Discord RPC client - shadowImpl("com.github.NetheriteMiner:DiscordIPC:3106be5") { + shadowImpl("com.jagrosh:DiscordIPC:0.5") { exclude(module = "log4j") because("Different version conflicts with Minecraft's Log4J") exclude(module = "gson") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/DiscordRPCConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/DiscordRPCConfig.java index 53def7ffb..71bddc4ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/DiscordRPCConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/DiscordRPCConfig.java @@ -92,6 +92,11 @@ public class DiscordRPCConfig { @ConfigEditorDropdown public Property auto = Property.of(NOTHING); + @Expose + @ConfigOption(name = "Show Button for SkyCrypt", desc = "Adds a button to the RPC that opens your SkyCrypt profile.") + @ConfigEditorBoolean + public Property showSkyCryptButton = Property.of(true); + public enum LineEntry implements HasLegacyId { NOTHING("Nothing", 0), LOCATION("Location", 1), 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 606dd7480..2f8b40212 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 @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.SkyHanniMod.Companion.feature import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.DiscordRPCConfig.LineEntry import at.hannibal2.skyhanni.config.features.misc.DiscordRPCConfig.PriorityEntry +import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.jsonobjects.repo.StackingEnchantData import at.hannibal2.skyhanni.data.jsonobjects.repo.StackingEnchantsJson import at.hannibal2.skyhanni.events.ConfigLoadEvent @@ -26,6 +27,7 @@ import com.google.gson.JsonObject import com.jagrosh.discordipc.IPCClient import com.jagrosh.discordipc.IPCListener import com.jagrosh.discordipc.entities.RichPresence +import com.jagrosh.discordipc.entities.RichPresenceButton import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.network.FMLNetworkEvent @@ -134,13 +136,20 @@ object DiscordRPCManager : IPCListener { // TODO, change functionality to use enum rather than ordinals secondLine = getStatusByConfigId(config.secondLine.get().ordinal) firstLine = getStatusByConfigId(config.firstLine.get().ordinal) - val presence: RichPresence = RichPresence.Builder() + + var presence = RichPresence.Builder() .setDetails(firstLine.getDisplayString()) .setState(secondLine.getDisplayString()) .setStartTimestamp(startTimestamp!!) .setLargeImage(discordIconKey, location) - .build() - client?.sendRichPresence(presence) + if (config.showSkyCryptButton.get()) { + val skyCryptUrl = "https://sky.shiiyu.moe/stats/${LorenzUtils.getPlayerName()}/${HypixelData.profileName}" + presence = presence.setButtons(arrayOf( + RichPresenceButton(skyCryptUrl, "Open SkyCrypt Profile") + )) + } + + client?.sendRichPresence(presence.build()) } override fun onReady(client: IPCClient) { -- cgit