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

feat: Help command alphabetization #1575

Conversation

Tiernan-Alderman
Copy link
Contributor

feat: Command Organization

Description: Changed CommandInfos to be a map rather than a vector, which allows for easy alphabetization of the different commands available when running /help.

Motivation and Context: Found it hard to sort through the list of commands as it was, so this should be helpful for users to find the commands they are looking for.

How Has This Been Tested?: Running my server and using the help command, for it to show the resulting command list in alphabetical order

Changed /help command to now be sorted alphabetically, as well as have different pages
@Tiernan-Alderman Tiernan-Alderman changed the title Hellp alphabetization Help alphabetization May 14, 2024
Copy link
Collaborator

@EmosewaMC EmosewaMC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format these files. We use tabs and define a tab as 4 spaces


// Inserting into CommandInfos using the first alias as the key
if (!command.aliases.empty()) {
CommandInfos.insert(std::make_pair(command.aliases[0], command));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CommandInfos.insert(std::make_pair(command.aliases[0], command));
CommandInfos[command.aliases[0]] = command;

Comment on lines +871 to +886
.handle = [](Entity* entity, const SystemAddress& sysAddr, const std::string& args) {
std::ostringstream feedback;
feedback << "----- Commands -----";

// Loop through CommandInfos and display commands the player can access
for (const auto& [alias, command] : CommandInfos) {
if (command.requiredLevel <= entity->GetGMLevel()) {
LOG("Help command: %s", alias.c_str());
feedback << "\n/" << alias << ": " << command.help;
}
}

// Send feedback text
const auto feedbackStr = feedback.str();
if (!feedbackStr.empty()) GameMessages::SendSlashCommandFeedbackText(entity, GeneralUtils::ASCIIToUTF16(feedbackStr));
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this back to being its own function

// Loop through CommandInfos and display commands the player can access
for (const auto& [alias, command] : CommandInfos) {
if (command.requiredLevel <= entity->GetGMLevel()) {
LOG("Help command: %s", alias.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG("Help command: %s", alias.c_str());

@aronwk-aaron aronwk-aaron changed the title Help alphabetization feat: Help command alphabetization May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants