PhilippvK / playforia-minigolf

Client & Server for Minigolf Game known from Playforia/Playray/Appeli. Written in Java.
84 stars 31 forks source link

Save last used IP for client #75

Open pehala opened 3 years ago

pehala commented 3 years ago

We should save somewhere the last IP that the client connected to to show instead of placeholder 127.0.0.1.

PhilippvK commented 3 years ago

Shall we use java.util.prefs.Preferences as it seems to manage the OS-dependent stuff?

PhilippvK commented 3 years ago

Is there anything else except the launcher options which should be saved in a persistent way as well? (f.e. last username,...)

pehala commented 3 years ago

Username, port, ip, maybe even settings for the new lobby. But that all can be done iteratively, for now I would do only IP, port and username.

PhilippvK commented 3 years ago

At a later point we could also add a dropdown to choose the language in the launcher. But as a prerequisite we might have to scan which language actually do exist or hardcode them anywhere.

pehala commented 3 years ago

Agree, we have them hardcoded in one Enum and we have ability to choose it with CLI options so actually only thing missing is adding it a a dropdown to the menu.

pehala commented 3 years ago

I am not sure if the languages are actually used in the UI but I guess thats entirely different issue

pehala commented 3 years ago

Shall we use java.util.prefs.Preferences as it seems to manage the OS-dependent stuff?

We could use it but preferences are backend neutral (at least thats what I have learn from a quick google) so we will probably have to write the file saving/loading code at least partially ourselves

PhilippvK commented 3 years ago

Shall we use java.util.prefs.Preferences as it seems to manage the OS-dependent stuff?

We could use it but preferences are backend neutral (at least thats what I have learn from a quick google) so we will probably have to write the file saving/loading code at least partially ourselves

I found this post about the Preferences API and it looks that it would be very easy to implement like in the example:

https://www.vogella.com/tutorials/JavaPreferences/article.html

pehala commented 3 years ago

We could definitely try doing PoC

PhilippvK commented 3 years ago

Should only the last used ip+port in the launcher window be remembered or the --server or --port input of the command line as well?

pehala commented 3 years ago

Ideally the command line as well

PhilippvK commented 3 years ago

Saving the currently chosen preferences can happen just after submitting the dialog? Alternatively we could only save the setting if the following server connection was successful but this would be a bit harder.

pehala commented 3 years ago

After submitting dialog is fine

PhilippvK commented 3 years ago

@pehala I have a quick question regarding your ManifestVersionProvider:

If I run new ManifestVersionProvider().getVersion() it returns: ${COMMAND-FULL-NAME} 2.1.0.0-BETA

Is that intended? If yes, how can I get just the 2.1.0.0-BETA part?

pehala commented 3 years ago

Yes, it is intended, it is used by the picocli library in CLI. I fetch the version (2.1.0.0-BETA) in that class with this <yourclass>.class.getPackage().getImplementationVersion(); (for this to works it requires building through Maven so it might not work in development environment but should work with generated jars).

PhilippvK commented 3 years ago

Thank you very much for clarification, I will try it out later.

I want to save the client version together with the preferences to have the ability to perform migrations when the preferences-concept somehow changes.

Do you have an idea on how to integrate the preferences management into the tests?

pehala commented 3 years ago

Thank you very much for clarification, I will try it out later.

I want to save the client version together with the preferences to have the ability to perform migrations when the preferences-concept somehow changes.

Good idea!

Do you have an idea on how to integrate the preferences management into the tests?

You should design the implementation in a way that would allow you to use mocked preferences in test, so you could check the methods and stuff.

PhilippvK commented 3 years ago

Okay. I never used Mockito before and am currently not able to complete the tests. (Mostly the handling of dismissing/accepting the ServerSettings-Dialog is missing at the moment)

Would you mind if I just push my current state so that you can help me getting the tests to work?

pehala commented 3 years ago

Of course, go for it

PhilippvK commented 3 years ago

@pehala I am out of ideas. It seems like my replacement for the showSettingDialog never gets called...

pehala commented 3 years ago

Just create PR and I will look at it