diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java index 969da396..7f02d69a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java @@ -69,7 +69,13 @@ public class RichPresenceManager implements Runnable { callbacks = new IDiscordActivityEvents.ByReference(); callbacks.OnActivityInvite = (eventData, type, user, activity) -> { + PartyJoinRequest partyJoinRequest = new PartyJoinRequest(); + partyJoinRequest.setDiscordUser(user); + partyJoinRequest.setExpire(System.currentTimeMillis() + 30000); + partyJoinRequest.setInvite(true); + PartyInviteViewer.INSTANCE.joinRequests.add(partyJoinRequest); + System.out.println("Received Join Request from "+user.id.longValue()+" ("+partyJoinRequest.getUsername()+"#"+partyJoinRequest.getDiscriminator()+")"); }; callbacks.OnActivityJoin = (eventData, secret) -> {DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().method(StompHeader.SEND) .header("destination", "/app/party.askedtojoin") @@ -105,8 +111,13 @@ public class RichPresenceManager implements Runnable { activityManager = iDiscordCore.GetActivityManager.getActivityManager(iDiscordCore); latestDiscordActivity = new DiscordActivity(); latestDiscordActivity.assets = new DiscordActivityAssets(); + latestDiscordActivity.secrets = new DiscordActivitySecrets(); + latestDiscordActivity.party = new DiscordActivityParty(); + latestDiscordActivity.party.discordActivityParty = new DiscordPartySize(); + latestDiscordActivity.timestamps = new DiscordActivityTimestamps(); GameSDK.writeString(latestDiscordActivity.assets.large_image, "mort"); GameSDK.writeString(latestDiscordActivity.assets.large_text, "mort"); + return true; } @@ -120,12 +131,16 @@ public class RichPresenceManager implements Runnable { }); } + public void accept(DiscordSnowflake userID) { + activityManager.AcceptInvite.acceptInvite(activityManager, userID, Pointer.NULL, (callbackData, result) -> { + System.out.println("Discord Returned "+result+" For Accepting invite from "+userID.longValue()+"L"); + }); + } public void updatePresence() { if (!skyblockStatus.isOnHypixel() || !FeatureRegistry.ADVANCED_RICHPRESENCE.isEnabled() || (!skyblockStatus.isOnSkyblock() && FeatureRegistry.ADVANCED_RICHPRESENCE.<Boolean>getParameter("disablenotskyblock").getValue())) { activityManager.ClearActivity.clearActivity(activityManager, Pointer.NULL, new NativeGameSDK.DiscordCallback() { @Override public void callback(Pointer callbackData, EDiscordResult result) { - System.out.println("Discord Returned "+result+" For Clearing RPC"); } }); } else { @@ -135,21 +150,13 @@ public class RichPresenceManager implements Runnable { GameSDK.writeString(latestDiscordActivity.state, name); - if (PartyManager.INSTANCE.getPartyID() != null) { - if (latestDiscordActivity.party == null) latestDiscordActivity.party = new DiscordActivityParty(); - GameSDK.writeString(latestDiscordActivity.party.id, PartyManager.INSTANCE.getPartyID()); - if (latestDiscordActivity.party.discordActivityParty == null) latestDiscordActivity.party.discordActivityParty = new DiscordPartySize(); + GameSDK.writeString(latestDiscordActivity.party.id, PartyManager.INSTANCE.getPartyID() == null ? "" : PartyManager.INSTANCE.getPartyID()); latestDiscordActivity.party.discordActivityParty.current_size = new Int32(PartyManager.INSTANCE.getMemberCount()); latestDiscordActivity.party.discordActivityParty.max_size = new Int32(PartyManager.INSTANCE.getMaxParty()); - } else { - latestDiscordActivity.party = null; - } - GameSDK.writeString(latestDiscordActivity.state, name); + if (skyblockStatus.getContext() != null) { DungeonContext dungeonContext = skyblockStatus.getContext(); long init = dungeonContext.getInit(); - if (latestDiscordActivity.timestamps == null) - latestDiscordActivity.timestamps = new DiscordActivityTimestamps(); latestDiscordActivity.timestamps.start = new DiscordTimestamp(init); if (dungeonContext.getBossfightProcessor() != null) { @@ -158,20 +165,17 @@ public class RichPresenceManager implements Runnable { GameSDK.writeString(latestDiscordActivity.details, "Clearing Rooms"); } } else { - latestDiscordActivity.timestamps = null; + latestDiscordActivity.timestamps.start = new DiscordTimestamp(0); GameSDK.writeString(latestDiscordActivity.details, "Dungeons Guide"); } if (PartyManager.INSTANCE.isAllowAskToJoin()) { - if (latestDiscordActivity.secrets == null) - latestDiscordActivity.secrets = new DiscordActivitySecrets(); GameSDK.writeString(latestDiscordActivity.secrets.join, PartyManager.INSTANCE.getAskToJoinSecret()); } else { - latestDiscordActivity.secrets = null; + GameSDK.writeString(latestDiscordActivity.secrets.join, ""); } activityManager.UpdateActivity.updateActivity(activityManager, latestDiscordActivity, Pointer.NULL, new NativeGameSDK.DiscordCallback() { @Override public void callback(Pointer callbackData, EDiscordResult result) { - System.out.println("Discord Returned "+result+" For Setting new RPC"); } }); } @@ -182,9 +186,9 @@ public class RichPresenceManager implements Runnable { setupSuccessful = setup(); if (!setupSuccessful) return; while(!Thread.interrupted()) { - iDiscordCore.RunCallbacks.runCallbacks(iDiscordCore); - updatePresence(); try { + iDiscordCore.RunCallbacks.runCallbacks(iDiscordCore); + updatePresence(); Thread.sleep(300L); } catch (Exception e) {e.printStackTrace();} } |