Commit Graph

24 Commits

Author SHA1 Message Date
Dylan K. Taylor
50976c20aa Firebombing of commands for the first time in 10 years 2025-10-12 03:30:30 +01:00
Dylan T.
9f9bc5fb1a Rework command alias handling, step 1 (#6685)
This PR started out as an effort to decouple Command and CommandMap, but it's turned into a bit more than that.

A summary of changes:

## UX
- Added `cmdalias create`, `cmdalias delete` and `cmdalias list` commands
- `/help` now shows prefixed names such as `pocketmine:help`
- Prefixed command name (e.g. `pocketmine:help`) are now visible to Minecraft clients
- Permission denied messages are now able to show more useful context when e.g. checking subcommand permissions
- Multiple commands claiming an alias make the alias unusable (an error will be shown when used telling the user to pick from the namespaced names), instead of whichever plugin loaded last getting lucky

## API
- Added `CommandAliasMap`, which handles mapping of aliases to namespaced command IDs
- Added `CommandSender->getCommandAliasMap()` for user-specific aliases
- Added `CommandMap->getAliasMap()` for global fallback aliases
- `Command` no longer tracks its own registered aliases (now the job of `CommandMap`), breaking circular dependency
- Aliases must now be provided to `CommandMap->register()`
- Aliases can now be individually registered and unregistered without re-registering/unregistering the whole command using `CommandAliasMap` APIs
- Aliases are no longer namespaced, only the main command name (e.g. `pocketmine:?` is now gone while `pocketmine:help` still exists)
- `Command` now requires a `$namespace` parameter, which replaces the old `$fallbackPrefix` parameter of `register()`. It should be set to the name of the plugin.

Relevant issues
- #6508 
- #3371 - this PR doesn't implement storage, but allows configuration of per-user aliases during server runtime
2025-10-10 23:34:57 +01:00
Dylan K. Taylor
d1a7c1d453 Constify server.properties references 2023-08-25 12:49:39 +01:00
Dylan K. Taylor
caebe14dab Use an array for command permissions
it doesn't make sense to have to parse the string every time we want to verify permissions, nor to expect that people will somehow know to use ; to separate them without it being documented anywhere...
2023-02-13 14:44:55 +00:00
BrandPVP
9c391a6809 Declare built-in command names inside the constructor (#5487)
This increases code consistency by placing the name in the same place where everything else about the command is defined.
2023-01-09 20:43:08 +00:00
Dylan K. Taylor
7ac6bd79a9 Localized remaining disconnection screens (except one or two that should never actually happen) 2022-12-27 20:05:59 +00:00
Dylan T
8e97e9dcda SimpleCommandMap: Enforce command permissions by default (#4681)
this resolves many security issues, as well as removing a ton of boilerplate code.
It may be desirable to react to permission denied; this can be done by overriding Command->testPermission(), or by using setPermissionMessage() to set a custom permission denied message.
2022-08-15 16:42:51 +01:00
Dylan K. Taylor
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Covered123
ba05b4f024 Whitelist command now kicks non-whitelisted online players (#4774)
closes #3868
2022-03-03 18:15:21 +00:00
Dylan K. Taylor
3b7580688c Stop auto-translating string descriptions/usages for commands
Require usage of Translatable for translations.
2021-09-11 16:46:40 +01:00
Dylan K. Taylor
039c59856d Remove % translation prefixes dotted around all over the place 2021-08-15 20:03:38 +01:00
Dylan K. Taylor
752d1179a1 Do not rely on random translation keys prefixed with % getting translated 2021-08-15 19:05:05 +01:00
Dylan K. Taylor
2293bd948d Added KnownTranslationFactory and use it in as many places as possible
this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
2021-08-10 14:50:40 +01:00
Dylan K. Taylor
bb79797b68 WhitelistCommand: fixed permission checking
closes #4349
2021-08-04 20:34:54 +01:00
Dylan K. Taylor
71c6f69fd3 Command: standardise permission checking
if subcommands had different permissions, the permissionMessage would not be used.
2021-08-04 20:29:07 +01:00
Dylan K. Taylor
94e16f416d Added KnownTranslationKeys (generated) and start using it 2021-06-29 22:46:04 +01:00
Dylan K. Taylor
bf7d69b69e Stop hardcoding permission names everywhere
using strings for permission names is nearly as shitty, but this is at least cross-referencable and statically analysable.
2021-06-26 19:14:51 +01:00
Dylan K. Taylor
5e44d5f75e Do not load playerdata from disk just to op/deop/whitelist/dewhitelist
this is an impressively dumb idea.
the playerdata is not used here in any capacity so it doesn't make sense to load it, especially considering that it takes a significant amount of time.
2020-11-27 18:12:45 +00:00
Dylan K. Taylor
977f9ec497 Merge branch 'stable'
# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/VersionInfo.php
#	src/pocketmine/block/Podzol.php
2020-07-21 11:57:24 +01:00
Dylan K. Taylor
5cf74fc16b Merge commit '3b961d0e5'
# Conflicts:
#	resources/vanilla
2020-07-04 22:25:23 +01:00
Dylan K. Taylor
52fd1a8c1d CommandSender: export getLanguage()
this currently serves as a proxy to the server main language, but it can be used by third party implementations to choose a non-Server language.
2020-06-22 20:05:23 +01:00
Dylan K. Taylor
1f90aa07aa Merge branch 'stable'
# Conflicts:
#	resources/vanilla
#	src/command/defaults/TeleportCommand.php
#	src/pocketmine/event/entity/EntityDespawnEvent.php
#	src/pocketmine/event/entity/EntityInventoryChangeEvent.php
#	src/pocketmine/event/entity/EntityLevelChangeEvent.php
#	src/pocketmine/event/entity/EntitySpawnEvent.php
#	tests/phpstan/configs/actual-problems.neon
2020-06-21 00:30:45 +01:00
Dylan K. Taylor
fe649d8d70 Extract ServerConfigGroup from Server
this API isn't very nice, but it's pretty much the same as the original, and at least this can be _kinda_ unit-tested...
2020-05-24 15:48:03 +01:00
Dylan K. Taylor
5499ac620c Removed pocketmine subdirectory, map PSR-4 style 2019-07-30 19:14:57 +01:00