diff options
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();} } } |