-
Notifications
You must be signed in to change notification settings - Fork 173
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
feat: Help command alphabetization #1575
Conversation
Changed /help command to now be sorted alphabetically, as well as have different pages
There was a problem hiding this 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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommandInfos.insert(std::make_pair(command.aliases[0], command)); | |
CommandInfos[command.aliases[0]] = command; |
.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)); | ||
}, |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG("Help command: %s", alias.c_str()); |
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