LocalMultiplayerAgent icon indicating copy to clipboard operation
LocalMultiplayerAgent copied to clipboard

Does not work with Java Jars

Open tylerhasman opened this issue 5 years ago • 7 comments

My server is written in Java and I want to launch it like so: "StartGameCommand": "C:/Assets/jre/bin/java.exe -jar C:/Assets/gameserver.jar",

However, the second C:/Assets/ does not get replaced by the proper folder and as such, does not launch the jar file.

tylerhasman avatar May 01 '19 18:05 tylerhasman

So I managed to get it to work by launching the jar from my computer with an absolute path as so: "StartGameCommand": "C:/Assets/jre/bin/java.exe -jar C:/Users/user/Documents/GitHub/WizardGame/out/artifacts/gameserver_jar/gameserver.jar",

Then I ran into another road block. There is a bug with the Java SDK for the game server. You need to initialize the "Build Metadata" in "JsonFileConfiguration", otherwise it throws a NPE. I detected it in the game server by loading in the config file, checking if its null, then setting it to an initialized value and resaving the file to the disc.

        JsonFileConfiguration jsonFileConfiguration = new JsonFileConfiguration();

        if(jsonFileConfiguration.getBuildMetadata() == null){
            logger.warn("Detected build metadata is null!");
            jsonFileConfiguration.setBuildMetadata(new HashMap<>());
            jsonFileConfiguration.save();
            logger.warn("Saved new json stuff");
        }

tylerhasman avatar May 01 '19 22:05 tylerhasman

@tylerhasman , thanks for reporting these issues. We will take a look and fix them and report back here.

ravarnamsft avatar May 02 '19 18:05 ravarnamsft

@tylerhasman , I can see how the arguments were not converted properly when running outside of the container, but did you see the same issue while running it within a container as well?

Regarding the JsonFileConfiguration, were you trying to access the buildMetadata (when it was null) or are you suggesting that the serialization itself fails if the buildMetadata is null? I don't get the "Save" part above, did you update the file directly?

ravarnamsft avatar May 10 '19 17:05 ravarnamsft

Yes I had to overwrite the file with valid data

tylerhasman avatar May 21 '19 03:05 tylerhasman

hi @tylerhasman, any further questions/help needed towards this issue? If not, we can close it.

dgkanatsios avatar Sep 05 '19 00:09 dgkanatsios

I don't believe the issue has actually been fixed. I had to use essentially java reflection to fix it.

tylerhasman avatar Sep 09 '19 23:09 tylerhasman

thanks for mentioning that, will keep the issue open. Can you share your workaround so other users can potentially benefit while we're working on the fix?

dgkanatsios avatar Sep 30 '19 02:09 dgkanatsios