问题描述:

I am having an issue with a game I'm making, the thing is that I want it to be able

to update without going to a website to download the new version and that you would need to login (it will cost about $3) to play. The thing is that I want the jar to not be runnable unless you run it via the game launcher. I want it so it checks for updates and uses login sessions.

I also want to be able to debug the game while building it and then set the jar so you cannot run it without starting the launcher and loging then clicking a button to start it but what I don't know is how do you make it so the game jar can only start with the launcher and the launcher to send the login session to the jar so it knows the username and knows the game was not stolen?

网友答案:

A quick and easy way (but possibly not the best one):

You can simply save the session data on a database or encrypted file. When the launcher exits, it should also destroy the session from the database

When the jar file is ran, it will read from the database, aborting if it doesn't find an active session in there.

You can also prevent the jar from being ran from outside the program (even if the launcher is already running in the background), by making it receive some sort of random encryption key that has to meet some criteria (also, database can be used here). The user would then have to know the key to be able to launch it manually

网友答案:

You could use a ProcessBuilder and start a new JVM.

Something like this maybe:

ProcessBuilder pb = new ProcessBuilder("/path/to/java", "-jar", "your.jar");
pb.directory(new File("preferred/working/directory"));
Process p = pb.start();

Hope it helps

相关阅读:
Top