Last active
May 22, 2020 08:25
-
-
Save riftrsps/b192bd05c5f97213c6a81aa3b964db14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import net.arikia.dev.drpc.DiscordEventHandlers; | |
| import net.arikia.dev.drpc.DiscordRPC; | |
| import net.arikia.dev.drpc.DiscordRichPresence; | |
| public class DiscordPresence { | |
| public final String APPLICATION_ID = "REDACTED"; | |
| public final String PARTY_ID = "REDACTED"; | |
| public final int PARTY_MAX_SIZE = 500; | |
| public final String PARTY_JOIN_SECRET ="REDACTED"; | |
| public final String PARTY_SPECTATE_SECRET = "REDACTED"; | |
| public final String WEBSITE = "http://fluxious-rsps.com/"; | |
| private String gameName; | |
| private String version; | |
| public DiscordPresence(String gameName, String version) { | |
| this.gameName = gameName; | |
| this.version = version; | |
| } | |
| public static DiscordPresenceOld launch(String name) { | |
| DiscordPresenceOld presence = new DiscordPresenceOld(name); | |
| new Thread(presence::run).start(); | |
| return presence; | |
| } | |
| public void sendRichPresence(String state, String details, String[] bigImage, String[] smallImage) { | |
| DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder(state); | |
| presence.setStartTimestamps(System.currentTimeMillis() / 1000); | |
| presence.setDetails(details); | |
| presence.setBigImage(bigImage[0], bigImage[1]); | |
| presence.setSmallImage(smallImage[0], smallImage[1]); | |
| presence.setParty(PARTY_ID, 0, PARTY_MAX_SIZE); | |
| presence.setSecrets(PARTY_JOIN_SECRET, PARTY_SPECTATE_SECRET); | |
| DiscordRPC.discordUpdatePresence(presence.build()); | |
| } | |
| private void initDiscord() { | |
| DiscordEventHandlers handlers = new DiscordEventHandlers.Builder() | |
| .setReadyEventHandler(user -> System.out.println("Welcome " + user.username + "#" + user.discriminator + ".")) | |
| .build(); | |
| DiscordRPC.discordInitialize(APPLICATION_ID, handlers, true); | |
| } | |
| private void run(){ | |
| DiscordRPC.discordRunCallbacks(); | |
| initDiscord(); | |
| sendRichPresence("At login screen", WEBSITE, new String[] {"icon", gameName +" v"+version}, new String[] {"icon", "At login screen"}); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment