hydrate-reminder icon indicating copy to clipboard operation
hydrate-reminder copied to clipboard

Display a special welcome message when the plugin is first installed

Open jmakhack opened this issue 1 year ago • 4 comments

Feature Reasoning

It would be nice to have an initial message displayed when first downloading and installing the plugin on how to get started with using the plugin.

Feature Description

When the plugin is first installed, there should be a special welcome message displayed to the user in the form of a chat game message.

It should be something like: Welcome and thanks for installing the RuneLite Hydrate Reminder plugin v2.0.0! Adjust settings in the plugin configuration menu and type "::hr help" in chat to view available commands.

If the user installs the plugin before actually logging in the OSRS, the logic should wait until the user logs in before displaying the chat message.

Possible Alternatives

Any alternatives to the suggested install message can be suggested and implemented.

Additional Context

In order to get this to work and only display when the plugin is first installed, a flag should be added within hydrateReminderStats.json: installMessageFlag. This flag should be set to 0 by default and then set to 1 after the message has been displayed. As long as the flag is set to 1, the user should never see the install message ever again.

Please refer to CONTRIBUTING.md for info on how to setup, build, run, and test this project.

jmakhack avatar Nov 16 '22 12:11 jmakhack

This could be implemented pretty easy. I'm having trouble however figuring out how to keep people with the plugin already installed from having the default flag once changes are released. How do we tell if the person is a fresh install or a returning user?

dcechano avatar Dec 09 '22 04:12 dcechano

Hi @dcechano, this is a good point. There may be some method in the RuneLite API to determine if this is a fresh install or an upgrade for a returning user.

However since this next release is going to be a major v2.0 release, I wouldn't mind displaying a message for both situations. We can just adjust the message accordingly to be something like: Welcome and thanks for installing or upgrading to the RuneLite Hydrate Reminder plugin v2.0.0!

jmakhack avatar Dec 10 '22 01:12 jmakhack

Hi @jmakhack, I've been working on a solution but I am having a lot of trouble coming up with a valid test. The issue is that I read and write from the hydrateReminderStats.json but the testing environment does not have access to this file. I tried mocking the file but Mockito cant Mock java.nio.file.Path and throws a org.mockito.exceptions.base.MockitoException. I created a couple Gists. Can you take a look?

HydrateWelcomeMessageDictionary.java HydrateWelcomeMessageDictionaryTest.java

dcechano avatar Dec 13 '22 17:12 dcechano

Hi @dcechano, sorry for such a late reply. If mockito is giving you issues with mocking the java.nio.file.Path methods then it will be tricky to write tests for the newly added isFreshInstall method.

In this case, I'll open a new issue to investigate how to best write unit tests for cases similar to this. You can open a pull request with the new code and for now, we can just test this functionality manually.

jmakhack avatar Dec 31 '22 11:12 jmakhack