-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Rework command alias handling, step 1 #6685
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
579aecf
First step in restructuring command alias handling
dktapps 084774e
Don't allow registering the same command instance twice
dktapps 7eff658
Add ability to register & unregister specific command aliases for exi…
dktapps 91dad0a
Merge branch 'major-next' into command-alias-handling
dktapps 8035d66
Merge branch 'major-next' into command-alias-handling
dktapps bc54380
CS
dktapps de15737
Merge branch 'major-next' into command-alias-handling
dktapps 9a7d94c
Merge branch 'major-next' into command-alias-handling
dktapps 743e6c8
Merge branch 'major-next' into command-alias-handling
dktapps 9e93c40
Don't register prefixed non-primary aliases
dktapps 02712d0
Revert changes to command name
dktapps b4c5576
Make alias conflicts more sane
dktapps 7eeb436
Fix PHPStan
dktapps a8b6a42
Fixed PluginCommand usage messages
dktapps bdb962b
First look at user-local alias maps and /cmdalias
dktapps 5510e62
Suppress error
dktapps 5ac6f01
Merge branch 'major-next' into command-alias-handling
dktapps 1ba86fc
Put namespace inside Command
dktapps 846bd99
Tidy namespace & name handling & validation
dktapps 84af5df
Merge branch 'major-next' into command-alias-handling
dktapps 5bbd179
UX improvements & localisations
dktapps c41f316
stfu
dktapps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * | ||
| * ____ _ _ __ __ _ __ __ ____ | ||
| * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ | ||
| * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | | ||
| * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ | ||
| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Lesser General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * @author PocketMine Team | ||
| * @link http://www.pocketmine.net/ | ||
| * | ||
| * | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace pocketmine\command; | ||
|
|
||
| use pocketmine\lang\Translatable; | ||
|
|
||
| final class CommandMapEntry{ | ||
|
|
||
| /** | ||
| * @param string[] $aliases | ||
| * @phpstan-param non-empty-list<string> $aliases | ||
| */ | ||
| public function __construct( | ||
| public readonly string $namespace, | ||
| public readonly Command $command, | ||
| public readonly array $aliases | ||
| ){} | ||
|
|
||
| public function getNamespacedName() : string{ | ||
| return $this->namespace . ":" . $this->command->getName(); | ||
| } | ||
|
|
||
| public function getPreferredAlias() : string{ | ||
| return $this->aliases[0]; | ||
| } | ||
|
|
||
| public function getUsage() : Translatable|string{ | ||
| //TODO: usage messages ought to use user-specified alias, not command preferred | ||
| //command-preferred is confusing if the user used a different alias | ||
| return $this->command->getUsage() ?? "/" . $this->getPreferredAlias(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.