Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunekaer committed Jun 19, 2024
2 parents aeb3472 + bd48592 commit fbf6524
Show file tree
Hide file tree
Showing 21 changed files with 334 additions and 94 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
!contains(github.event.head_commit.message, '[ciskip]')
uses: nanite/workflows/.github/workflows/[email protected]
with:
java-version: 17
java-version: 21
changelog-file: "./CHANGELOG.md"
release-to-github: false
secrets:
nanite-token: ${{ secrets.NANITE_DEPLOY }}
curse-token: ${{ secrets.CURSE_DEPLOY }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
## 6.0.0
## 86.0.1

### Changed

- Updated to 1.20.4
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"
}
]
}
```
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
52 changes: 26 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4.151"
id "dev.architectury.loom" version "1.4.373" apply false
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}

Expand Down Expand Up @@ -56,7 +56,7 @@ allprojects {

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}

java {
Expand Down Expand Up @@ -90,11 +90,11 @@ publishMods {
modLoaders.add("fabric")
}

def forgeOptions = publishOptions {
file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "[FORGE][${minecraft_version}] ${project.name} ${mod_version}"
modLoaders.add("forge")
}
// def forgeOptions = publishOptions {
// file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
// displayName = "[FORGE][${minecraft_version}] ${project.name} ${mod_version}"
// modLoaders.add("forge")
// }

def neoforgeOptions = publishOptions {
file = project.provider { project(":neoforge").tasks.remapJar }.flatMap { it.archiveFile }
Expand Down Expand Up @@ -127,15 +127,15 @@ publishMods {
}
}

curseforge("curseforgeForge") {
from(curseForgeOptions, forgeOptions)
requires {
slug = "cloth-config"
}
requires {
slug = "architectury-api"
}
}
// curseforge("curseforgeForge") {
// from(curseForgeOptions, forgeOptions)
// requires {
// slug = "cloth-config"
// }
// requires {
// slug = "architectury-api"
// }
// }

curseforge("curseforgeNeoforge") {
from(curseForgeOptions, neoforgeOptions)
Expand All @@ -162,15 +162,15 @@ publishMods {
}
}

modrinth("modrinthForge") {
from(modrinthOptions, forgeOptions)
requires {
slug = "cloth-config"
}
requires {
slug = "architectury-api"
}
}
// modrinth("modrinthForge") {
// from(modrinthOptions, forgeOptions)
// requires {
// slug = "cloth-config"
// }
// requires {
// slug = "architectury-api"
// }
// }

modrinth("modrinthNeoforge") {
from(modrinthOptions, neoforgeOptions)
Expand Down
5 changes: 0 additions & 5 deletions common/src/main/java/com/sunekaer/sdrp/SDRP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
// }
}

/**
Expand Down
10 changes: 10 additions & 0 deletions common/src/main/java/com/sunekaer/sdrp/config/SDRPConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<Button> buttons = new ArrayList<>();

@Override
public void validatePostLoad() {
var oldConfig = SDRPCrossPlatform.getConfigDirectory().resolve("sdrp.json");
Expand Down Expand Up @@ -60,4 +65,9 @@ public static final class OldConfigEntry<T> {
private @Nullable T value;
private String comment;
}

public static final class Button {
public String label;
public String url;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package com.sunekaer.sdrp.discord;

import com.jagrosh.discordipc.entities.RichPresence;
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;

import java.time.OffsetDateTime;

public class ExtendedRichPresence extends RichPresence {
public @Nullable String button_label_1;
public @Nullable String button_url_1;
public @Nullable String button_label_2;
public @Nullable String button_url_2;

public ExtendedRichPresence(String state, String details, OffsetDateTime startTimestamp, OffsetDateTime endTimestamp, String largeImageKey, String largeImageText, String smallImageKey, String smallImageText, String partyId, int partySize, int partyMax, String matchSecret, String joinSecret, String spectateSecret, boolean instance) {
super(state, details, startTimestamp, endTimestamp, largeImageKey, largeImageText, smallImageKey, smallImageText, partyId, partySize, partyMax, matchSecret, joinSecret, spectateSecret, instance);
}

public ExtendedRichPresence(String state, String details, OffsetDateTime startTimestamp, OffsetDateTime endTimestamp, String largeImageKey, String largeImageText, String smallImageKey, String smallImageText, String partyId, int partySize, int partyMax, String matchSecret, String joinSecret, String spectateSecret, boolean instance, @Nullable String button_label_1, @Nullable String button_url_1, @Nullable String button_label_2, @Nullable String button_url_2) {
super(state, details, startTimestamp, endTimestamp, largeImageKey, largeImageText, smallImageKey, smallImageText, partyId, partySize, partyMax, matchSecret, joinSecret, spectateSecret, instance);
this.button_label_1 = button_label_1;
this.button_url_1 = button_url_1;
this.button_label_2 = button_label_2;
this.button_url_2 = button_url_2;
}

@Override
public JSONObject toJson() {
var jsonObject = super.toJson();
var buttonsObj = new JSONArray();
if (button_label_1 != null && button_url_1 != null) {
var btn1 = new JSONObject();
btn1.put("label", button_label_1);
btn1.put("url", button_url_1);
buttonsObj.put(btn1);
}
if (button_label_2 != null && button_url_2 != null) {
var btn2 = new JSONObject();
btn2.put("label", button_label_2);
btn2.put("url", button_url_2);
buttonsObj.put(btn2);
}
if (!buttonsObj.isEmpty()) {
jsonObject.put("buttons", buttonsObj);
if (jsonObject.has("secrets")) {
jsonObject.remove("secrets");
}
}
return jsonObject;
}

public static class ExtendedBuilder {
private String state;
private String details;
private OffsetDateTime startTimestamp;
private OffsetDateTime endTimestamp;
private String largeImageKey;
private String largeImageText;
private String smallImageKey;
private String smallImageText;
private String partyId;
private int partySize;
private int partyMax;
private String matchSecret;
private String joinSecret;
private String spectateSecret;
private boolean instance;

private String button_label_1;
private String button_url_1;
private String button_label_2;
private String button_url_2;

public ExtendedBuilder setState(String state) {
this.state = state;
return this;
}

public ExtendedBuilder setDetails(String details) {
this.details = details;
return this;
}

public ExtendedBuilder setStartTimestamp(OffsetDateTime startTimestamp) {
this.startTimestamp = startTimestamp;
return this;
}

public ExtendedBuilder setEndTimestamp(OffsetDateTime endTimestamp) {
this.endTimestamp = endTimestamp;
return this;
}

public ExtendedBuilder setLargeImage(String largeImageKey, String largeImageText) {
this.largeImageKey = largeImageKey;
this.largeImageText = largeImageText;
return this;
}

public ExtendedBuilder setLargeImage(String largeImageKey) {
return setLargeImage(largeImageKey, null);
}

public ExtendedBuilder setSmallImage(String smallImageKey, String smallImageText) {
this.smallImageKey = smallImageKey;
this.smallImageText = smallImageText;
return this;
}

public ExtendedBuilder setSmallImage(String smallImageKey) {
return setSmallImage(smallImageKey, null);
}

public ExtendedBuilder setParty(String partyId, int partySize, int partyMax) {
this.partyId = partyId;
this.partySize = partySize;
this.partyMax = partyMax;
return this;
}

public ExtendedBuilder setMatchSecret(String matchSecret) {
this.matchSecret = matchSecret;
return this;
}

public ExtendedBuilder setJoinSecret(String joinSecret) {
this.joinSecret = joinSecret;
return this;
}

public ExtendedBuilder setSpectateSecret(String spectateSecret) {
this.spectateSecret = spectateSecret;
return this;
}

public ExtendedBuilder setInstance(boolean instance) {
this.instance = instance;
return this;
}

public ExtendedBuilder setButton1(String label, String url) {
// If the label is greater than 32 characters, it will be truncated.
if (label.length() > 32) {
// This is a failsafe
label = label.substring(0, 32);
}

this.button_label_1 = label;
this.button_url_1 = url;
return this;
}

public ExtendedBuilder setButton2(String label, String url) {
// If the label is greater than 32 characters, it will be truncated.
if (label.length() > 32) {
// This is a failsafe
label = label.substring(0, 32);
}

this.button_label_2 = label;
this.button_url_2 = url;
return this;
}

public ExtendedRichPresence build() {
return new ExtendedRichPresence(state, details, startTimestamp, endTimestamp, largeImageKey, largeImageText, smallImageKey, smallImageText, partyId, partySize, partyMax, matchSecret, joinSecret, spectateSecret, instance, button_label_1, button_url_1, button_label_2, button_url_2);
}
}
}
Loading

0 comments on commit fbf6524

Please sign in to comment.