JnCrMx / discord-game-sdk4j

Java bindings for Discord's Game SDK
MIT License
122 stars 23 forks source link

Not having discord open crashes application #30

Closed NathanKassab closed 3 years ago

NathanKassab commented 3 years ago

If you kill discord in task manager and proceed to run an application with rich presence the program will crash when calling params.setFlags(CreateParams.getDefaultFlags());. There is no stack trace so I assume this is meant to be this way? I'm mainly worried about people who don't have discord not being able to run my application

JnCrMx commented 3 years ago

This seems to be an intentional choice by Discord. It is supposed to close the game if Discord is not available and restart it over Discord.

You can use CreateParams.Flags.NO_REQUIRE_DISCORD (see https://discord.com/developers/docs/game-sdk/discord#data-models-createflags-enum) to avoid this behavoir. Creating the Core will still fail (latest point of failure being the runCallbacks function), but it will not terminate the program and instead throw a normal Java exception.

To be honest I really dislike the choice Discord has made here, because it is such a weird and unexpected behaviour (terminating an application from within a library is kinda ugh in my opinion). But it seems like we need to deal with it.

If this does not fix your issue (I am a bit worried, because of it crashing at CreateParams.setFlags already), please reply and provide some system information (OS, Architecture, Discord version).

NathanKassab commented 3 years ago

Ok, thank you for the help