From bd4859201a31a340103057ad9010df5f63decd22 Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Wed, 15 May 2024 11:28:14 +0100 Subject: [PATCH] feat: ported buttons support --- CHANGELOG.md | 21 ++- README.md | 30 +++- .../src/main/java/com/sunekaer/sdrp/SDRP.java | 5 - .../com/sunekaer/sdrp/config/SDRPConfig.java | 10 ++ .../sdrp/discord/ExtendedRichPresence.java | 170 ++++++++++++++++++ .../com/sunekaer/sdrp/discord/RPClient.java | 8 +- .../java/com/sunekaer/sdrp/discord/State.java | 18 +- .../integration/kubejs/SDRPKubeJSWrapper.java | 17 -- common/src/main/resources/kubejs.plugins.txt | 1 - gradle.properties | 2 +- .../com/sunekaer/sdrp/neoforge/SDRPForge.java | 17 -- .../sunekaer/sdrp/neoforge/SDRPNeoForge.java | 19 ++ .../kubejs/SDRPKubeJSIntegration.java | 3 +- .../neoforge/kubejs/SDRPKubeJSWrapper.java | 17 ++ .../src/main/resources/kubejs.plugins.txt | 1 + 15 files changed, 289 insertions(+), 50 deletions(-) create mode 100644 common/src/main/java/com/sunekaer/sdrp/discord/ExtendedRichPresence.java delete mode 100644 common/src/main/java/com/sunekaer/sdrp/integration/kubejs/SDRPKubeJSWrapper.java delete mode 100644 common/src/main/resources/kubejs.plugins.txt delete mode 100644 neoforge/src/main/java/com/sunekaer/sdrp/neoforge/SDRPForge.java create mode 100644 neoforge/src/main/java/com/sunekaer/sdrp/neoforge/SDRPNeoForge.java rename {common/src/main/java/com/sunekaer/sdrp/integration => neoforge/src/main/java/com/sunekaer/sdrp/neoforge}/kubejs/SDRPKubeJSIntegration.java (97%) create mode 100644 neoforge/src/main/java/com/sunekaer/sdrp/neoforge/kubejs/SDRPKubeJSWrapper.java create mode 100644 neoforge/src/main/resources/kubejs.plugins.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 13cdd8c..dac6514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ -## 86.0.0 +## 86.0.1 ### Changed -- Updated to 1.20.6 +Buttons can be added by adding the following to the mods config file. You can have up to 2 buttons. Each button can have a label up to 32 characters long. + +If you do not want to have buttons, you can leave the buttons array empty. + +```json +{ + "buttons": [ + { + "label": "Google", + "url": "https://www.google.com" + }, + { + "label": "Yahoo", + "url": "https://www.yahoo.com" + } + ] +} +``` diff --git a/README.md b/README.md index 585c9fe..693b2fb 100644 --- a/README.md +++ b/README.md @@ -111,11 +111,39 @@ We omit the `modid` from the dimension name and use the `name` instead. So `mine } ``` +### Config Buttons (6.0.2+) + +Buttons can be added by adding the following to the mods config file. + +**Restrictions** +- You can have up to 2 buttons. +- Each button can have a label up to 32 characters long. + +If you do not want to have buttons, you can leave the buttons array empty. + +```json5 +{ + "...": "See above", // See above + "buttons": [ + { + "label": "Google", + "url": "https://www.google.com" + }, + { + "label": "Yahoo", + "url": "https://www.yahoo.com" + } + ] +} +``` + ## KubeJS Integration > **Note!** > -> KubeJS Support is only support in 3.0.0+ for `1.19.2` and `4.0.3+` for `1.20.1+` +> KubeJS Support is only support in 3.0.0+ for `1.19.2` and `4.0.3+` for `1.20.1+`. +> +> KubeJS no longer supports Forge or Fabric so support for KubeJS as of `1.20.4+` is limited to just the `NeoForge` version of our mod > > Only `KubeJS 6+` is supported! diff --git a/common/src/main/java/com/sunekaer/sdrp/SDRP.java b/common/src/main/java/com/sunekaer/sdrp/SDRP.java index 2cf9738..64893b8 100644 --- a/common/src/main/java/com/sunekaer/sdrp/SDRP.java +++ b/common/src/main/java/com/sunekaer/sdrp/SDRP.java @@ -5,7 +5,6 @@ import com.sunekaer.sdrp.config.SDRPConfig; import com.sunekaer.sdrp.discord.RPClient; import com.sunekaer.sdrp.discord.State; -//import com.sunekaer.sdrp.integration.kubejs.SDRPKubeJSIntegration; import dev.architectury.event.EventResult; import dev.architectury.event.events.client.ClientGuiEvent; import dev.architectury.event.events.client.ClientLifecycleEvent; @@ -43,10 +42,6 @@ public static void init() { EntityEvent.ADD.register(SDRP::clientJoinEvent); ClientGuiEvent.INIT_POST.register(SDRP::screenEvent); - -// if (Platform.isModLoaded("kubejs")) { -// SDRPKubeJSIntegration.setup(); -// } } /** diff --git a/common/src/main/java/com/sunekaer/sdrp/config/SDRPConfig.java b/common/src/main/java/com/sunekaer/sdrp/config/SDRPConfig.java index 6dc83b7..f686f10 100644 --- a/common/src/main/java/com/sunekaer/sdrp/config/SDRPConfig.java +++ b/common/src/main/java/com/sunekaer/sdrp/config/SDRPConfig.java @@ -11,6 +11,8 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; import java.util.Optional; @Config(name = SDRP.MOD_ID + "-common") @@ -30,6 +32,9 @@ public class SDRPConfig implements ConfigData { @Comment("When enabled, the mod will log the current state being sent to Discord") public boolean logState = false; + @Comment("Set custom buttons for the Discord Rich Presences. You can only have 2 buttons, each button has a label and a URL.") + public List