diff options
author | syeyoung <cyong06@naver.com> | 2021-08-08 18:21:51 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-08-08 22:02:06 +0900 |
commit | eaaac61857654f7f629fa9ada669f40301009e31 (patch) | |
tree | 98189a04dcb1cd351d8ab30e31e932e65ad9454d /src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java | |
parent | a6eb8b879e8bad88aa334c3e681067e314723c59 (diff) | |
download | Skyblock-Dungeons-Guide-eaaac61857654f7f629fa9ada669f40301009e31.tar.gz Skyblock-Dungeons-Guide-eaaac61857654f7f629fa9ada669f40301009e31.tar.bz2 Skyblock-Dungeons-Guide-eaaac61857654f7f629fa9ada669f40301009e31.zip |
- GameSDK Binding
Welp it was painful writing a tool to generating these bindings, then manually correcting classes
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java | 128 |
1 files changed, 63 insertions, 65 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java index d1175563..abecd8a7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java @@ -27,8 +27,6 @@ import kr.syeyoung.dungeonsguide.party.PartyJoinRequest; import kr.syeyoung.dungeonsguide.party.PartyManager; import kr.syeyoung.dungeonsguide.stomp.StompHeader; import kr.syeyoung.dungeonsguide.stomp.StompPayload; -import net.arikia.dev.drpc.*; -import net.arikia.dev.drpc.callbacks.*; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.json.JSONObject; @@ -40,65 +38,65 @@ public class RichPresenceManager implements Runnable { public RichPresenceManager() { t.start(); - Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC::discordShutdown)); +// Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC::discordShutdown)); } public void setup() { - DiscordRPC.discordInitialize("816298079732498473", new DiscordEventHandlers.Builder() - .setReadyEventHandler(new ReadyCallback() { - @Override - public void apply(DiscordUser user) { - updatePresence(); - } - }).setJoinRequestEventHandler(request -> { - PartyJoinRequest partyJoinRequest = new PartyJoinRequest(); - partyJoinRequest.setDiscordUser(request); - partyJoinRequest.setExpire(System.currentTimeMillis() + 30000); - - PartyInviteViewer.INSTANCE.joinRequests.add(partyJoinRequest); - }).setJoinGameEventHandler(joinSecret -> { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().method(StompHeader.SEND) - .header("destination", "/app/party.askedtojoin") - .payload(new JSONObject().put("token", joinSecret).toString())); - }).setErroredEventHandler((errorCode, message) -> { - System.out.println("ERROR! "+errorCode+ " - "+message); - t.interrupt(); - (t = new Thread(this)).start(); - }).setDisconnectedEventHandler((errorCode, message) -> { - System.out.println("ERROR! "+errorCode+ " - "+message); - t.interrupt(); - (t = new Thread(this)).start(); - }).build(), true); +// DiscordRPC.discordInitialize("816298079732498473", new DiscordEventHandlers.Builder() +// .setReadyEventHandler(new ReadyCallback() { +// @Override +// public void apply(DiscordUser user) { +// updatePresence(); +// } +// }).setJoinRequestEventHandler(request -> { +// PartyJoinRequest partyJoinRequest = new PartyJoinRequest(); +// partyJoinRequest.setDiscordUser(request); +// partyJoinRequest.setExpire(System.currentTimeMillis() + 30000); +// +// PartyInviteViewer.INSTANCE.joinRequests.add(partyJoinRequest); +// }).setJoinGameEventHandler(joinSecret -> { +// DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().method(StompHeader.SEND) +// .header("destination", "/app/party.askedtojoin") +// .payload(new JSONObject().put("token", joinSecret).toString())); +// }).setErroredEventHandler((errorCode, message) -> { +// System.out.println("ERROR! "+errorCode+ " - "+message); +// t.interrupt(); +// (t = new Thread(this)).start(); +// }).setDisconnectedEventHandler((errorCode, message) -> { +// System.out.println("ERROR! "+errorCode+ " - "+message); +// t.interrupt(); +// (t = new Thread(this)).start(); +// }).build(), true); } private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); public void updatePresence() { - if (!skyblockStatus.isOnHypixel() || !FeatureRegistry.ADVANCED_RICHPRESENCE.isEnabled() || (!skyblockStatus.isOnSkyblock() && FeatureRegistry.ADVANCED_RICHPRESENCE.<Boolean>getParameter("disablenotskyblock").getValue())) { - DiscordRPC.discordClearPresence(); - } else { - String name = skyblockStatus.getDungeonName(); - if (name.trim().equals("Your Island")) name = "Private Island"; - DiscordRichPresence.Builder richPresenceBuilder = new DiscordRichPresence.Builder(name); - richPresenceBuilder.setBigImage("mort", "mort") - .setParty(PartyManager.INSTANCE.getPartyID(), PartyManager.INSTANCE.getMemberCount(), PartyManager.INSTANCE.getMaxParty()); - - if (skyblockStatus.getContext() != null) { - DungeonContext dungeonContext = skyblockStatus.getContext(); - long init = dungeonContext.getInit(); - richPresenceBuilder.setStartTimestamps(init); - - if (dungeonContext.getBossfightProcessor() != null) { - richPresenceBuilder.setDetails("Fighting "+dungeonContext.getBossfightProcessor().getBossName()+": "+dungeonContext.getBossfightProcessor().getCurrentPhase()); - } else { - richPresenceBuilder.setDetails("Clearing rooms"); - } - } - if (PartyManager.INSTANCE.isAllowAskToJoin()) - richPresenceBuilder.setSecrets(PartyManager.INSTANCE.getAskToJoinSecret(), null); - richPresenceBuilder.setDetails("Dungeons Guide"); - DiscordRPC.discordUpdatePresence(richPresenceBuilder.build()); - } +// if (!skyblockStatus.isOnHypixel() || !FeatureRegistry.ADVANCED_RICHPRESENCE.isEnabled() || (!skyblockStatus.isOnSkyblock() && FeatureRegistry.ADVANCED_RICHPRESENCE.<Boolean>getParameter("disablenotskyblock").getValue())) { +// DiscordRPC.discordClearPresence(); +// } else { +// String name = skyblockStatus.getDungeonName(); +// if (name.trim().equals("Your Island")) name = "Private Island"; +// DiscordRichPresence.Builder richPresenceBuilder = new DiscordRichPresence.Builder(name); +// richPresenceBuilder.setBigImage("mort", "mort") +// .setParty(PartyManager.INSTANCE.getPartyID(), PartyManager.INSTANCE.getMemberCount(), PartyManager.INSTANCE.getMaxParty()); +// +// if (skyblockStatus.getContext() != null) { +// DungeonContext dungeonContext = skyblockStatus.getContext(); +// long init = dungeonContext.getInit(); +// richPresenceBuilder.setStartTimestamps(init); +// +// if (dungeonContext.getBossfightProcessor() != null) { +// richPresenceBuilder.setDetails("Fighting "+dungeonContext.getBossfightProcessor().getBossName()+": "+dungeonContext.getBossfightProcessor().getCurrentPhase()); +// } else { +// richPresenceBuilder.setDetails("Clearing rooms"); +// } +// } +// if (PartyManager.INSTANCE.isAllowAskToJoin()) +// richPresenceBuilder.setSecrets(PartyManager.INSTANCE.getAskToJoinSecret(), null); +// richPresenceBuilder.setDetails("Dungeons Guide"); +// DiscordRPC.discordUpdatePresence(richPresenceBuilder.build()); +// } } @@ -119,17 +117,17 @@ public class RichPresenceManager implements Runnable { @Override public void run() { - try { - Thread.sleep(300L); - setup(); - while(!Thread.interrupted()) { - DiscordRPC.discordRunCallbacks(); - if (skyblockStatus.isOnSkyblock() && !lastLoc.equalsIgnoreCase(skyblockStatus.getDungeonName())) { - lastLoc = skyblockStatus.getDungeonName()+""; - } - updatePresence(); - Thread.sleep(300L); - } - } catch (Exception e) {e.printStackTrace();} +// try { +// Thread.sleep(300L); +// setup(); +// while(!Thread.interrupted()) { +// DiscordRPC.discordRunCallbacks(); +// if (skyblockStatus.isOnSkyblock() && !lastLoc.equalsIgnoreCase(skyblockStatus.getDungeonName())) { +// lastLoc = skyblockStatus.getDungeonName()+""; +// } +// updatePresence(); +// Thread.sleep(300L); +// } +// } catch (Exception e) {e.printStackTrace();} } } |