Code Monkey home page Code Monkey logo

discord-rpc's People

Contributors

ceikry avatar dejaydev avatar dragovorn avatar kcinnajlol avatar nickgal avatar rdna123 avatar soni801 avatar spikatrix avatar tylerhasman avatar vatuu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-rpc's Issues

Master fails to build

Describe the bug
Fails to build.

Error

discord-rpc\src\main\java\net\arikia\dev\drpc\DiscordRPC.java:182:21
java: cannot find symbol
  symbol:   variable f
  location: class net.arikia.dev.drpc.DiscordRPC

Versions (Must be completed):

  • OS Ver: Windows 10
  • Java Version: 17.0.3
  • Library Version: Master branch

Additional info
Looks like commit 1fd4d69 broke this.

ExceptionInInitializerError (winx64)

Heyho,

i've saw that the issue i have isn't new. So i opened a new issue.

This happens when i call the initialize Method:
Caused by: java.lang.NullPointerException at net.arikia.dev.drpc.DiscordRPC.copyFile(DiscordRPC.java:204) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:144) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:16) ... 48 more

I've deleted all discord-rpc files and directories in my temp folder.
Thanks for help

Joining game with invite doesn't fire any events

Here is my handler for it

.setJoinGameEventHandler(new JoinGameCallback() {
 @Override
 public void apply(String secret) {
  WizardGame.instance.getClient().sendMessage(new DiscordJoinGameMessage(secret));
  Gdx.app.log("DiscordJoinGame", "Secret " + secret);
 }
})

This is my initialization code:

String appId = "XXXXXXXXX";

DiscordRPC.discordInitialize(appId, handlers, true);

doDiscordEvents();

DiscordRPC.discordClearPresence();
DiscordRPC.discordUpdatePresence(new DiscordRichPresence());

discordThread = new Thread(new Runnable() {
 @Override
 public void run() {
  while (!Thread.currentThread().isInterrupted()) {
   try {
    DiscordRPC.discordRunCallbacks();
    Gdx.app.log("discordEvents", "Polling...");
    Thread.sleep(2000);
   } catch (InterruptedException e) {}
  }
 }
}, "Discord-Event-Poll");
discordThread.setDaemon(true);
discordThread.start();

Why isn't the event firing?

JNI issue

Contact me VIA discord please Phil#0004

Don't working anymore | Windows 11

Hello. I am using the new version and i am on windows 11
but oftenen my discord rpc dont show up. I also use the example

package at.eruxmod.utils.application.discord;

import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;

import javax.swing.*;
import java.awt.*;
import java.util.Scanner;

public class DiscordRP {

    private static boolean ready = false;

    public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        JFrame frame = new JFrame("Test");
        JLabel text = new JLabel("Now goto Discord and set your active game to: '" + frame.getTitle() + "'");
        GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        int width = gd.getDisplayMode().getWidth();
        int height = gd.getDisplayMode().getHeight();

        frame.getContentPane().setLayout(new FlowLayout());
        frame.getContentPane().setBackground(new Color(114, 137, 218));
        frame.getContentPane().add(text, SwingConstants.CENTER);

        frame.setResizable(true);
        frame.setSize(width/4, height/4);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        frame.setVisible(true);

        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            System.out.println("Closing Discord hook.");
            DiscordRPC.discordShutdown();
        }));

        initDiscord();

        int score = 0;
        System.out.println("Running callbacks...");

        while (true) {
            DiscordRPC.discordRunCallbacks();

            if(!ready)
                continue;

            System.out.print("> ");
            Scanner in = new Scanner(System.in);
            String input = in.nextLine();

            if (!input.equalsIgnoreCase("shutdown")) {
                if (input.equalsIgnoreCase("test")) {
                    score++;
                    DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder("Score: ");
                    presence.setDetails("Running Test");
                    DiscordRPC.discordUpdatePresence(presence.build());
                } else {
                    System.out.println("Unknown Command: " +
                            "\n\nAvailable Commands:" +
                            "\ntest - Test.\nshutdown - End this test peacefully.");
                }
            } else {
                frame.dispose();
                System.exit(0);
            }
        }
    }

    private static void initDiscord() {
        DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
            DiscordRP.ready = true;
            System.out.println("Welcome " + user.username + "#" + user.discriminator + ".");
            DiscordRichPresence.Builder presence = new DiscordRichPresence.Builder("Score: ");
            presence.setDetails("Running Test");
            DiscordRPC.discordUpdatePresence(presence.build());
        }).build();
        DiscordRPC.discordInitialize("415885161457123338", handlers, false);
        DiscordRPC.discordRegister("415885161457123338", "");
    }


}

No Errors

Cannot invoke "java.io.InputStream.read(byte[])" because "input" is null

Describe the bug

when loading discord rpc the program crashes

Source

    // initialize Discord Rich Presence
    DiscordEventHandlers handlers = new DiscordEventHandlers();
    DiscordRPC.discordInitialize("968887179994624100", handlers, true);
    DiscordRichPresence presence = new DiscordRichPresence();

Error

Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "input" is null

Versions (Must be completed):

  • OS Ver: Linux
  • Java Version: openjdk version "18" 2022-03-22 OpenJDK Runtime Environment 22.3 (build 18+37) OpenJDK 64-Bit Server VM 22.3 (build 18+37, mixed mode, sharing)
  • Library Version: 1.5.0

Additional info

32-bit DLL is in wrong location.

finalPath = is64bit ? "/win-x64/discord-rpc.dll" : "/lib/win-x32/discord-rpc.dll";

but it's not in the latest download I got.

Current layout

Win x64 dll in release JAR seems to be corrupt

It seems way too small and refuses to load with the error Exception in thread "main" java.lang.UnsatisfiedLinkError: F:\Sean\AppData\Local\Temp\discord-rpc.jar\discord-rpc.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

how to add button

is that possible to add button to the status? for example button to youtube link

DiscordRPC mod broke my game! Scary error message inside! ๐Ÿ˜ฑ๐ŸŽฎ

๐Ÿ› Describe the bug
Uh oh! ๐Ÿ˜ฑ Whenever I try to run my Minecraft Fabric 1.19.3 game with my cool DiscordRPC mod, it crashes and gives me a super scary error message! ๐Ÿ˜ญ The error says java.lang.RuntimeException: Could not execute entrypoint stage 'main' due to errors, provided by 'neon'!, and then there's some stuff about java.lang.UnsatisfiedLinkError: 'java.lang.String com.mod.shadow.com.sun.jna.Native.getNativeVersion()' which I don't really understand... but basically, my mod is broken and I can't play my game with DiscordRPC.

๐Ÿ“ Source

public class DiscordRPCManager {
    private static final String APPLICATION_ID = "your_application_id_here";
    private static final DiscordRichPresence presence = new DiscordRichPresence();

    private static DiscordRPC rpc;
    private static String currentDetails = "";
    private static String currentServer = "";
    private static long startTime = 0;

    public static void init() {
        Euphoria.LOGGER.info("Launching DiscordRPC");

        rpc = new DiscordRPC();
        rpc.discordInitialize(APPLICATION_ID, new DiscordEventHandlers(), true, "");
        presence.largeImageKey = "";
        presence.largeImageText = "";

        updatePresence();
    }

    public static void shutdown() {
        rpc.discordShutdown();
    }

      
    public static void updateTimestamps() {
        startTime = System.currentTimeMillis() / 1000;
        presence.startTimestamp = startTime;

        rpc.discordUpdatePresence(presence);
    }
}

๐Ÿšจ Error
Here's the error message I get when I try to run my game with the mod:

java.lang.RuntimeException: Could not execute entrypoint stage 'main' due to errors, provided by 'neon'!
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.lambda$invoke0$0(EntrypointUtils.java:51)
at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:49)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35)
at net.fabricmc.loader.impl.game.minecraft.Hooks.startClient(Hooks.java:52)
at net.minecraft.class_310.<init>(class_310.java:465)
at net.minecraft.client.main.Main.method_44604(Main.java:205)
at net.minecraft.client.main.Main.main(Main.java:51)
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:462)
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
Caused by: java.lang.UnsatisfiedLinkError: 'java.lang.String com.mod.shadow.com.sun.jna.Native.getNativeVersion()'
at com.mod.shadow.com.sun.jna.Native.getNativeVersion(Native Method)
at com.mod.shadow.com.sun.jna.Native.<clinit>(Native.java:192)
at com.mod.shadow.com.sun.jna.Pointer.<clinit>(Pointer.java:54)
at com.mod.shadow.com.sun.jna.Structure.<clinit>(Structure.java:2130)
at com.mod.elements.discord.DiscordRPCManager.<clinit>(DiscordRPCManager.java:11)
at com.mod.Mod.<clinit>(Mod.java:65)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:50)
at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:117)
at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53)
at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47)
... 8 more

๐Ÿ“‹ Versions (Must be completed):

OS Ver: Windows 11
Java Version: 17
Library Version: 1.6.2

๐Ÿ“ Additional info
I'm not sure if this is relevant, but I'm using the latest version of the DiscordRPC library. Thanks for your help, and I hope we can get this fixed soon so I can show off my cool mod to all my friends! ๐Ÿ˜Ž

๐Ÿค” So, I reached out to Vatuu about the issue you're having with their DiscordRPC library, and they've confirmed that they're currently working on a fix for it! ๐Ÿ› ๏ธ. That's great news, right? ๐ŸŽ‰ In the meantime, why not take a break and play some Minecraft without the DiscordRPC mod? ๐ŸŽฎ It might not be as cool, but at least you won't have to deal with that pesky error message! ๐Ÿ˜œ. Keep an eye out for updates from Vatuu on when the fix will be available. Hopefully, it won't be too long before you can start showing off your awesome mod to your friends again! ๐Ÿคž

Shading of jar does not work

I am not an expert on this, but here is my problem.

My app uses jna version 5.0.0.
Discord-rpc uses version 4.5.1

When running my app it loads the jna lib from the discord library making it crash with NoSuchMethodError.

The solution to the issue is the library using the shade plusgin as described here https://labs.spotify.com/2015/09/01/java-linking/ .

If I look into your maven pom.xml then I see you use that plug-in

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
</plugin>

So there should not be any problems but the classes are never the less normally included in the discord-rpc jar and i would expect them to be under net.arikia.dev path or something so my app does not load them as jna. I do admit I got not much of an idea of this shading plugin...

Maybe I will have a look into it, but would be cool if somebody of u could do it I have a really hard time reading into that shade-plugin docu.

The ReadyEventHandlerยดs user parameter can be null?

Describe the bug

When this library calls the ReadyEvent from the discordEventHandlers the DiscordUser can return null. I used this code:

builder.setReadyEventHandler((usr)->{
	DRPCLog.Info("READY! Logged in as "+usr.username);
});

This causes this error:

[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:123]: JNA: Callback de.erdbeerbaerlp.discordrpc.Discord$$Lambda$52/1650171715@7a4764bb threw the following exception:
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: java.lang.NullPointerException
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at de.erdbeerbaerlp.discordrpc.Discord.lambda$0(Discord.java:57)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at java.lang.reflect.Method.invoke(Method.java:498)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at com.sun.jna.Native.invokeVoid(Native Method)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at com.sun.jna.Function.invoke(Function.java:408)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at com.sun.jna.Function.invoke(Function.java:354)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at com.sun.jna.Library$Handler.invoke(Library.java:244)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at net.arikia.dev.drpc.$Proxy28.Discord_RunCallbacks(Unknown Source)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at net.arikia.dev.drpc.DiscordRPC.discordRunCallbacks(DiscordRPC.java:96)
[20:36:59] [Discord Update Thread/INFO] [STDERR]: [com.sun.jna.Native$1:uncaughtException:124]: 	at de.erdbeerbaerlp.discordrpc.Discord$1.run(Discord.java:30)

Source

https://github.com/ErdbeerbaerLP/DiscordRichPresence/blob/1.12/src/main/java/de/erdbeerbaerlp/discordrpc/Discord.java#L56

Versions (Must be completed):

  • OS Ver: Windows 10
  • Java Version:
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
  • Library Version: 1.6.2

Additional info

Minecraft Version: 1.12.2
Forge Version: 14.23.4.2705

Special Characters (like รครถรผ or japaneese characters) wonยดt show up

Describe the bug

All special characters will be displayed as a question mark
Example (with a japaneese level name as an UTF-8 String):
image

Versions (Must be completed):

  • OS Ver: Windows 10 Insider Preview (Build 18898.1000)
  • Java Version: java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
  • Library Version: 1.6.2

SIGSEGV when running multiple instances

I have integrated Discord RPC functionality in my game using the jar file from the releases page (v1.6.2). It works just fine, but when I launch two instances of my game, the old instance crashes with a SIGSEGV. When I remove the Discord RPC related code, the game doesn't crash when launching multiple instances so it's something related to this.

This is basically what my code looks like:

DiscordRPC.discordInitialize(applicationID, null, false);
richPresence = new DiscordRichPresence.Builder("")
        .setBigImage("logo", "v0.0.1")
        .setStartTimestamps(System.currentTimeMillis())
        .build();
richPresence.state = stateStr;
DiscordRPC.discordUpdatePresence(richPresence);

Versions:

  • OS: Linux
  • Java Version: openjdk version "1.8.0_252"
  • Library Version: v1.6.2

Gradle Support

Would it be possible to set this up to work with gradle?

Try / catch ignored?

Hi, first off thank you for this amazing rpc :)

But I have seem to encountered an issue, when people launch a second instance of the application, it will throw an error process already in use (this also happens if discord rpc is in use by something else right now).
No issues there, but it throws a FileNotFoundException which I attempted to catch to neatly print that the RPC is disabled opposed to the stacktrace, and also disable usage for it later down the road.
java.io.FileNotFoundException: C:\Users\Alex\AppData\Local\Temp\discord-rpc\discord-rpc.dll (The process cannot access the file because it is being used by another process) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at net.arikia.dev.drpc.DiscordRPC.openOutputStream(DiscordRPC.java:186) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:152) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:21) at com.runescape.Client.main(Client.java:4126)

Ive tried using a normal Try/Catch for FileNotFoundException but then Eclipse will tell me that this code will never throw this exception (except it already did), so instead I setup a general Exception clause, which seems completely ignored (the error message is never printed)

`try {
DiscordEventHandlers handlers = new DiscordEventHandlers();
DiscordRPC.discordInitialize("123", handlers, true);

				DiscordRichPresence rich = new DiscordRichPresence.Builder("At login screen").build();
				DiscordRPC.discordUpdatePresence(rich);
				
				Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
				    @Override
				    public void run() {
				    	DiscordRPC.discordShutdown();
				    }
				}));
			} catch (Exception e) {
				System.out.println("Failed connecting to discord: "+ e.getClass());
			}`

java.lang.NullPointerException

java.lang.NullPointerException
at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:158)
at net.arikia.dev.drpc.DiscordRPC.(DiscordRPC.java:26)

Inputstream is null, how should I initialise it?

java.lang.NoClassDefFoundError on line 10

Describe the bug
I am making adding RPC to my minecraft client. When I run in debug the RPC works but when I implement to the launcher i get all those errors and I can't figure out why. Any help is appreciated.

Source
package EfeClient;

public class Client {

private static final Client INSTANCE = new Client();
public static final Client getInstance() {
    return INSTANCE;
}

private DiscordRP discordRP = new DiscordRP();

public void init() {
    discordRP.start();
}

public void shutdown() {
    discordRP.shutdown();
}

public DiscordRP getDiscordRP() {
    return discordRP;
}

}

Error

Versions (Must be completed):
java.lang.NoClassDefFoundError: net/arikia/dev/drpc/callbacks/ReadyCallback
at EfeClient.Client.(Client.java:10)
at EfeClient.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)
Caused by: java.lang.ClassNotFoundException: net.arikia.dev.drpc.callbacks.ReadyCallback
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head --
Stacktrace:
at EfeClient.Client.(Client.java:10)
at EfeClient.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)

-- System Details --
Details:
Minecraft Version: 1.8.8
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 87987328 bytes (83 MB) / 167772160 bytes (160 MB) up to 2147483648 bytes (2048 MB)
JVM Flags: 8 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
Launched Version: EfeClient
LWJGL: 2.9.4
OpenGL: ERROR RuntimeException: No OpenGL context found in the current thread.
GL Caps:
Using VBOs: ERROR NullPointerException: null
Is Modded: Very likely; Jar signature invalidated
Type: Client (map_client.txt)
Resource Packs: ERROR NullPointerException: null
Current Language: ERROR NullPointerException: null
Profiler Position: N/A (disabled)
CPU:

Additional info

Problem

java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) Caused by: java.lang.UnsatisfiedLinkError: /media/storage/Programming/PersonalProjects/KingTux/null/discord-rpc.jar/discord-rpc.so: /media/storage/Programming/PersonalProjects/KingTux/null/discord-rpc.jar/discord-rpc.so: failed to map segment from shared object at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:106) at net.arikia.dev.drpc.DiscordRPC.<clinit>(DiscordRPC.java:21) at me.kingtux.kingtux.Main.main(Main.java:30) ... 11 more Exception running application me.kingtux.kingtux.Main
Code

package me.kingtux.kingtux;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import net.arikia.dev.drpc.callbacks.ReadyCallback;
import javafx.stage.Stage;

import java.util.Scanner;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("window.fxml"));
        primaryStage.setTitle("KingTux.jar");
        primaryStage.setScene(new Scene(root, 600, 275));
        primaryStage.show();
    }


    public static void main(String[] args) {
        System.out.println("Check2");
        DiscordEventHandlers handler = new DiscordEventHandlers();
        handler.ready = new DiscordPresense();
        DiscordRPC.DiscordInitialize("400851884899827714", handler, true);
        DiscordRPC.DiscordRunCallbacks();
        Scanner scanner = new Scanner(System.in);
        launch(args);

    }
}

How to use an authorization code?

I may be just really bad at reading, but I don't believe that there's a way to use an authorization code in this wrapper. Is this true? If not how can I use an oAuth code to use RPC?

What about a wrapper of the game sdk?

Discord Rich Presence is deprecated and was replaced with the game sdk. Would it not be an easy to to the same with that in the way you did it here with Discord Rich Presence sdk.

Confused about Discord's Rich Presence and "self-botting" rules

Apologies if this isn't the right place (or person) to ask.

I'm interested in making a "bridge" app in Java that hooks into various 3rd-party apps/games to provide rich presence in Discord. Something similar to SimplePresence but my own spin on it (I know noting about JavaScript but enough about JNA).

But I am concerned about Discord's stance on "self-botting" and how it's a bannable offense.

Is Rich Presence something that only game/app developers are allowed to use for their own applications? Or is Rich Presence via RPC not considered "self-botting" at all? What do you think?

I've tried to research this as best I can, but am surprised that nobody has really looked into it. Closest thing I found was a request for Rich Presence support in a python.py request, but it was shot-down by someone for being self-botting.

Thanks for any advice you have.

Make end time of game nullable

If I wanna set start and end time of a game. I am forced to set start and end time by the parameters being long and not Long. Our game https://faforever.com/ does not have a fixed end time, so I want to be able to only set a start time but no end time.

Suggestion: Move native libs into separate directory in jar

Suggestion: Move native libs into a separate directory in .jar
For now, jar application with extracted discord-rpc library seems unstructured (we have few dirs with single files).
Maybe just put all libs into one directory called natives?

java.lang.NullPointerException

Here is the error:

Error Exception in thread "Client thread" java.lang.ExceptionInInitializerError
at bedless.RPC.start(RPC.java:24)
at net.minecraft.client.Minecraft.(Minecraft.java:384)
at net.minecraft.client.main.Main.main(Main.java:113)
Caused by: java.lang.NullPointerException
at net.arikia.dev.drpc.DiscordRPC.copyFile(DiscordRPC.java:165)
at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:153)
at net.arikia.dev.drpc.DiscordRPC.(DiscordRPC.java:21)
... 3 more

Here is the code

package bedless;

import java.util.Date;

import com.ibm.icu.text.SimpleDateFormat;

import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import net.arikia.dev.drpc.DiscordUser;
import net.arikia.dev.drpc.callbacks.ReadyCallback;

public class RPC extends Client {
	
	DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(new ReadyCallback() {
		@Override
		public void apply(DiscordUser user) {
		      
		  }
	}).build();

	public void start() {
		
		  DiscordRPC.discordInitialize("858420957680762881", handlers, true);

		  DiscordRichPresence rich = new DiscordRichPresence.Builder("Idle").setBigImage("bedlessmain", "bedlessmain").setStartTimestamps(System.currentTimeMillis()).build();			  
		  DiscordRPC.discordUpdatePresence(rich);
	}
	
	public void stop() {
		
		DiscordRPC.discordShutdown();
	}
	
	public void joinServer() {
		DiscordRichPresence rich = new DiscordRichPresence.Builder("Idle").setBigImage("bedlessmain", "bedlessmain").build();
		DiscordRPC.discordUpdatePresence(rich);
	}
}

ExceptionInInitializerError - Linux (KDE neon)

  • [17:24:39 ERROR] java.lang.ExceptionInInitializerError
  • [17:24:39 ERROR] at de.cubeprogramms.cubemanager.core.discord.richpresence.RichPresenceManager.bootstrap(RichPresenceManager.java:48)
  • [17:24:39 ERROR] at de.cubeprogramms.cubemanager.core.discord.DiscordIntegration.bootstrap(DiscordIntegration.java:38)
  • [17:24:39 ERROR] at java.base/java.lang.Thread.run(Thread.java:844)
  • [17:24:39 ERROR] Caused by: java.lang.NullPointerException
  • [17:24:39 ERROR] at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2314)
  • [17:24:39 ERROR] at org.apache.commons.io.IOUtils.copy(IOUtils.java:2270)
  • [17:24:39 ERROR] at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2291)
  • [17:24:39 ERROR] at org.apache.commons.io.IOUtils.copy(IOUtils.java:2246)
  • [17:24:39 ERROR] at net.arikia.dev.drpc.DiscordRPC.loadDLL(DiscordRPC.java:150)
  • [17:24:39 ERROR] at net.arikia.dev.drpc.DiscordRPC.(DiscordRPC.java:22)
  • [17:24:39 ERROR] ... 3 more

RichPresenceManager l. 48:
DiscordRPC.discordInitialize("- id -", eventHandlers, true);

OS: Linux 4.13.0-45-generic (KDE neon) | Java: 10.0.1

Can not share my presence

Made a simple Console app RPC, It works for me but not for everyone else, whitelisted my friend in the project page, but still not working for him

Please reply ASAP

Crashes with java.lang.UnsatisfiedLinkError on Windows

Describe the bug
On Windows, the build from the recent commit (1f82937) crashes with a java.lang.UnsatisfiedLinkError. I'm using api 'com.github.Vatuu:discord-rpc:1f82937' in gradle. The crash occurs when running a single instance of my game itself.

Using a version before #49 was merged works without any issues. For instance, api 'com.github.Vatuu:discord-rpc:0293d57' works without crashing for a single instance of the game.

Source
DiscordRPC.discordInitialize(applicationID, null, false);

Error
(Trimmed to exclude uneccessary information)

Exception in thread "Game Application" java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': Native library (win32-x86-64/discord-rpc.dll) not found in resource path ([file:/C:/Users/jas/Downloads/Game.jar])
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:303)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427)
        at com.sun.jna.Library$Handler.<init>(Library.java:179)
        at com.sun.jna.Native.loadLibrary(Native.java:569)
        at com.sun.jna.Native.loadLibrary(Native.java:544)
        at net.arikia.dev.drpc.DiscordRPC$DLL.<clinit>(DiscordRPC.java:222)
        at net.arikia.dev.drpc.DiscordRPC.discordInitialize(DiscordRPC.java:32)

Versions (Must be completed):

  • OS Ver: Windows
  • Java Version:
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

Additional info
This issue happens only on Windows. On Linux, both the recent commit and the older one works without crashing for a single instance.

Documentation is not comprehensive

The documentation provided in the READ ME is not very comprehensive and is not up-to-date.
Apparently DiscordEventHandler is not in existence, so I cannot get very far.

Mac lib not found

As seen in #5 , i'm still getting that same error, even using the latest discord and discord-rpc version.
I'm using maven by the way.

Typo in README

Describe the bug
Typo in README

Source
Readme

Error

public void startup(){
  DiscordEventHandlers handlers = new DiscordEventHandler.Build().setReadyEventHandler((user) -> {
      System.out.println("Welcome " + user.username + "#" + user.discriminator + "!");
  }).build();
  DiscordRPC.initialize("1234567890", handler, true);
}

->

public void startup(){
  DiscordEventHandlers handlers = new DiscordEventHandler.Build().setReadyEventHandler((user) -> {
      System.out.println("Welcome " + user.username + "#" + user.discriminator + "!");
  }).build();
  DiscordRPC.initialize("1234567890", handlers, true);
}

or

public void startup(){
  DiscordEventHandlers handler = new DiscordEventHandler.Build().setReadyEventHandler((user) -> {
      System.out.println("Welcome " + user.username + "#" + user.discriminator + "!");
  }).build();
  DiscordRPC.initialize("1234567890", handler, true);
}

Versions (Must be completed):

  • OS Ver: No
  • Java Version: No
  • Library Version: Master branch

Additional info
Typo in readme

Update readme

DiscordRPC.initialize() no longer exists in newest version

Callback and RPC not running.

So I'm trying to log the user username + tag (given my the readme), but it's not running the callback and it's not making my profile show I'm playing something

public void check(Logger LOGGER)
{
    LOGGER.info("Getting USER.");
    DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler((user) -> {
        LOGGER.info("Got USER.");
        LOGGER.info("Welcome " + user.username + "#" + user.discriminator + "!");
    }).build();
    DiscordRPC.discordInitialize( client ID of the bot , handlers, true);
    DiscordRPC.discordRegister( client ID of the bot , "");
}
public DiscordRichPresence createRPC(Logger LOGGER)
{
    DiscordRichPresence rich = new DiscordRichPresence.Builder("This is the current state.").setDetails("These are some details.").build();
    return rich;
}
public void updateRPC(Logger LOGGER, DiscordRichPresence rich)
{
    DiscordRPC.discordRunCallbacks();
    DiscordRPC.discordUpdatePresence(rich);
}

Each function is called from top to bottom, what am I doing wrong?

Edit*: I made the RP work, but the ".setReadyEventListener()" isn't work, here's the event code now (and I do have a thread that loops, and runs "DiscordRPC.discordRunCallbacks();"):

DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(new ReadyCallback() {
    @Override
    public void apply(DiscordUser user) {
        LOGGER.info("DiscordManager: Got user" + user.username + "#" + user.discriminator);
    }
}).build();

NoClassDefFoundError when running Minecraft Client 1.8.8

Describe the bug

Source

Error

Versions (Must be completed):

  • OS Ver:
  • Java Version: Change this to the output of java -version
  • Library Version: What version of discord-rpc are you using?

Additional info

---- Minecraft Crash Report ----
// You're mean.

Time: 3/5/22, 12:37 PM
Description: Initializing game

java.lang.NoClassDefFoundError: net/arikia/dev/drpc/callbacks/ReadyCallback
at Lucky.Client.(Client.java:10)
at Lucky.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)
at Start.main(Start.java:11)
Caused by: java.lang.ClassNotFoundException: net.arikia.dev.drpc.callbacks.ReadyCallback
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 6 more

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head --
Stacktrace:
at Lucky.Client.(Client.java:10)
at Lucky.Client.(Client.java:5)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:401)
at net.minecraft.client.main.Main.main(Main.java:113)
at Start.main(Start.java:11)

-- System Details --
Details:
Minecraft Version: 1.8.8
Operating System: Windows 10 (amd64) version 10.0
CPU:
Java Version: 17.0.2, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode, sharing), Oracle Corporation
Memory: 868831744 bytes (828 MB) / 1073741824 bytes (1024 MB) up to 1073741824 bytes (1024 MB)
JVM Flags: 3 total; -XX:+ShowCodeDetailsInExceptionMessages -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
Launched Version: mcp
LWJGL: 2.9.4
OpenGL: ERROR RuntimeException: No OpenGL context found in the current thread.
GL Caps:
Using VBOs: ERROR NullPointerException: Cannot read field "useVbo" because "this.this$0.gameSettings" is null
Is Modded: Very likely; Jar signature invalidated
Type: Client (map_client.txt)
Resource Packs: ERROR NullPointerException: Cannot read field "resourcePacks" because "this.this$0.gameSettings" is null
Current Language: ERROR NullPointerException: Cannot invoke "net.minecraft.client.resources.LanguageManager.getCurrentLanguage()" because the return value of "net.minecraft.client.Minecraft.access$3(net.minecraft.client.Minecraft)" is null
Profiler Position: N/A (disabled)
CPU:

java.lang.NullPointerException

I keep getting a null pointer exception from the copyFile function
image_2021-05-28_192322
I don't really know what to do here.
this is my code

package me.neo.rpc;

import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import net.arikia.dev.drpc.DiscordUser;
import net.arikia.dev.drpc.callbacks.ReadyCallback;

import java.util.Date;

public class Discord {
    private long time;
    private String id;
    public Discord(String id) {
        System.out.println(System.mapLibraryName("discord-rpc"));
        DiscordRichPresence.Builder rich = new DiscordRichPresence.Builder("Playing Minecraft");
        DiscordEventHandlers handlers = new DiscordEventHandlers.Builder().setReadyEventHandler(new ReadyCallback() {
            @Override
            public void apply(DiscordUser user) {
                System.out.printf("Discord: User %s%s has logged into Discord", user.username, user.discriminator);
                time = new Date().getTime();
                rich.setStartTimestamps(time);
                rich.setDetails("Currently in the menu");
                DiscordRPC.discordUpdatePresence(rich.build());
            }
        }).build();

        this.id = id;

        DiscordRPC.discordInitialize(this.id, handlers, false);
        DiscordRPC.discordRegister(this.id, "");

        new Thread(() -> {
            while (true) {
                DiscordRPC.discordRunCallbacks();
            }
        });

        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            DiscordRPC.discordShutdown();
        }));
    }
}

(macOS) dylib load error

After importing the library, when I try to run my app I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': dlopen(libdiscord-rpc.dylib, 9): image not found at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163) at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236) at com.sun.jna.Library$Handler.<init>(Library.java:140) at com.sun.jna.Native.loadLibrary(Native.java:379) at com.sun.jna.Native.loadLibrary(Native.java:364) at net.arikia.dev.drpc.DiscordRPC$DLL.<clinit>(DiscordRPC.java:114) at net.arikia.dev.drpc.DiscordRPC.discordInitialize(DiscordRPC.java:33) at com.relic.sfs2x.Relic.init(Relic.java:65) at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:303) at com.smartfoxserver.v2.entities.managers.SFSZoneManager.createRoom(SFSZoneManager.java:719) at com.smartfoxserver.v2.entities.managers.SFSZoneManager.createZone(SFSZoneManager.java:412) at com.smartfoxserver.v2.entities.managers.SFSZoneManager.initializeZones(SFSZoneManager.java:239) at com.smartfoxserver.v2.SmartFoxServer.start(SmartFoxServer.java:292) at com.smartfoxserver.v2.Main.main(Main.java:14)

I'm running 10.13.3 Beta. Is there another way I can include the rpc binaries? Nothing I try seems to behave.

DLL Location in jar is not the same in code

Hello,
The library jar has windows 32bits dll in "win-x86" inside the jar. But line 120 in DiscordRPC.java it is looking for "win-x32" if the system is 32bits which gives an error.
Could you fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.