Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helpful command argument descriptions #4057

Merged
merged 14 commits into from
May 10, 2021

Conversation

JRoy
Copy link
Member

@JRoy JRoy commented Mar 15, 2021

Information

Improves command usage strings by providing a detailed explanation of all possible arguments which shows where old usages showed as well as in the essentials help command

Att #3892

Details

Command instance creations are now cached and kept throughout the lifecycle of the plugin rather than be created for each command execution. This is a performance optimization but also allows for us to cache formatted command usage strings (also helping performance).

Upon command instance creation, the command will brute force search translations with the naming <command>CommandUsage<ascending number> and <command>CommandUsage<ascending number>Description and will stop brute forcing when it doesn't see any new usages.

/~https://github.com/JRoy/Essentials-PR/blob/c1490fc686854b70d9e8c696fc2c88d1b538fc2c/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsCommand.java#L58-L67

These translation lines are then formatted with colors for required an optional parameters.

/~https://github.com/JRoy/Essentials-PR/blob/c1490fc686854b70d9e8c696fc2c88d1b538fc2c/Essentials/src/main/java/com/earth2me/essentials/commands/EssentialsCommand.java#L70-L79

These, now formatted usages are stored in the usage cache and will be displayed as such when a NotEnoughArgumentsException has occurred.

/~https://github.com/JRoy/Essentials-PR/blob/c1490fc686854b70d9e8c696fc2c88d1b538fc2c/Essentials/src/main/java/com/earth2me/essentials/Essentials.java#L722-L732

Demonstration:

yte954.mp4

@JRoy JRoy added the type: enhancement Features and feature requests. label Mar 15, 2021
@JRoy JRoy added this to the 2.19.0 milestone Mar 15, 2021
@JRoy JRoy requested a review from mdcfe March 15, 2021 17:17
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Essentials/src/main/resources/messages.properties Outdated Show resolved Hide resolved
Co-authored-by: triagonal <10545540+triagonal@users.noreply.github.com>
@JRoy
Copy link
Member Author

JRoy commented May 10, 2021

man this is gonna break a pr or two

@JRoy JRoy changed the title Implement advanced command argument descriptions Add helpful command argument descriptions May 10, 2021
@JRoy JRoy enabled auto-merge (squash) May 10, 2021 18:35
@mdcfe
Copy link
Member

mdcfe commented May 10, 2021

or twelve

@JRoy JRoy merged commit 8b23c2c into EssentialsX:2.x May 10, 2021
@JRoy JRoy deleted the feature/improved-usage-strings branch May 10, 2021 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Features and feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants