SHARE
TWEET

Untitled

a guest May 26th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.obscurfight.integration;
  2.  
  3. import java.util.logging.Logger;
  4.  
  5. import club.minnced.discord.rpc.DiscordEventHandlers;
  6. import club.minnced.discord.rpc.DiscordRPC;
  7. import club.minnced.discord.rpc.DiscordRichPresence;
  8.  
  9. public class Discord<DiscordRPCState> {
  10.  
  11.  
  12.     //private DiscordRPCState state = DiscordRPCState.UNKNOW;
  13.     DiscordRPC lib = DiscordRPC.INSTANCE;
  14.     DiscordRichPresence presence;
  15.     String applicationId = "550492415006343168";
  16.     Logger logger = Logger.getLogger("DiscordRPC");
  17.     boolean running = false;
  18.  
  19.     public Discord(){
  20.         String steamId = "";
  21.         DiscordEventHandlers handlers = new DiscordEventHandlers();
  22.    
  23.         lib.Discord_Initialize(applicationId, handlers, true, steamId);
  24.         presence = new DiscordRichPresence();
  25.         presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
  26.         presence.details = "H4CK3D BY ANTR4X_";
  27.         presence.largeImageKey = "logofordiscordapi";
  28.         presence.smallImageKey = "logo1024";
  29.         lib.Discord_UpdatePresence(presence);
  30.         running = true;
  31.     }
  32.  
  33.     public void gameLoop(){
  34.         lib.Discord_UpdatePresence(presence);
  35.         new Thread(() -> {
  36.             while (!Thread.currentThread().isInterrupted()) {
  37.                 lib.Discord_RunCallbacks();
  38.                 try {
  39.                     Thread.sleep(2000);
  40.                 } catch (InterruptedException ignored) {}
  41.             }
  42.         }, "RPC-Callback-Handler").start();
  43.     }
  44.  
  45.     public void updateDiscordPresence(){
  46.         presence = new DiscordRichPresence();
  47.         presence.details = "www.nds.fr";
  48.         presence.largeImageKey = "logofordiscordapi";
  49.         presence.smallImageKey = "logo1024";
  50.         lib.Discord_UpdatePresence(presence);
  51.     }
  52.  
  53.     public void updateState(DiscordRPCState parState){
  54.         //this.state = parState;
  55.         updateDiscordPresence();
  56.     }
  57.  
  58.     public void stopRPC(){
  59.         logger.info("Shutdown Discord RPC");
  60.         lib.Discord_Shutdown();
  61.         running = false;
  62.     }
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top