185 Commits

Author SHA1 Message Date
Dylan K. Taylor
99996b62d6
Align PhpDoc @param tags according to PHP-CS-Fixer 2022-12-06 13:21:20 +00:00
Dylan K. Taylor
ff2391e74a
FormattedCommandAlias: use new string for description 2022-11-15 15:26:55 +00:00
Dylan K. Taylor
cdbdcb5d67
Merge branch 'stable' into next-minor 2022-11-04 20:44:28 +00:00
Dylan K. Taylor
bfd1b2c635
PHPStan 1.9.1 2022-11-04 18:28:07 +00:00
Dylan K. Taylor
1671405cd0
Merge branch 'stable' into next-minor 2022-11-02 16:03:30 +00:00
Dylan K. Taylor
1572b31b8d
FormattedCommandAlias: do not fill empty strings for missing placeholder arguments
this is pretty much always going to cause unexpected behaviour, as most execute() implementations don't expect empty strings, and it can also pad the args with dummy entries, breaking argument count requirements (e.g. aliasing say  and using the alias with no arguments will confuse the target command).

Instead:
- Drop arguments that cannot be resolved (leave them unspecified)
- If they are at the end of the argument sequence, this is OK - it will behave the same as if some optional arguments weren't specified.
- If they are in the middle of the argument sequence, this will generate an error - this is preferable to having the target invoked with an empty string, which might cause unexpected behaviour.

fixes #5379
2022-11-02 15:02:29 +00:00
Dylan K. Taylor
b6f6671a81
Merge branch 'stable' into next-minor 2022-10-31 15:34:24 +00:00
Eren A. Akyol
fb31e6085e
StatusCommand: fix condition order for TPS colour (#5366) 2022-10-26 23:26:55 +01:00
Dylan K. Taylor
d74824c8d5
Correctly use Command->getLabel() instead of Command->getName()
getName() essentially serves as an ID for the command for CommandExecutors. It has no other sane use case.

Since it's not unique (multiple commands with the same name may be registered, and the fallback alias will be used on conflict), it cannot be used for array indexing. It's also not correct to use it for any display purpose, since the command may not be able to be invoked by its 'name' if there was a conflict.

There is an open debate about what to do with getName() and the wider CommandExecutor ecosystem, but that's a topic for another discussion.

closes #5344
2022-10-18 19:34:12 +01:00
Dylan K. Taylor
7bcc663b60
Migrate core code to using symfony/filesystem
webmozart/path-util is retained for plugin compatibility, but is dropped in 5.0
2022-10-14 21:51:29 +01:00
Dylan K. Taylor
0c7f8470b9
Avoid repeated strtolower usages in a couple of places 2022-09-28 21:30:06 +01:00
Dylan T
b87e4d8bd3
Introduce and use TextFormat::addBase() (#5268)
This function adds "base" format to a string. The given formats are inserted directly after any RESET code in the sequence.

An example of where this is needed is in the logger.

Without this change, the following code:
$logger->notice("I'm a " . TextFormat::RED . "special" . TextFormat::RESET . " cookie");

causes the "cookie" part of the message to show as grey, instead of the expected aqua for NOTICE level messages.

There are also many workarounds for this problem throughout the server, mostly in command outputs, being forced to use WHITE instead of RESET to avoid breaking the logger output.
2022-09-28 16:13:11 +01:00
Dylan K. Taylor
cfb0cad7e0
Console commands now write to stdout directly, instead of being fed through the logger
this has a number of implications:
- Console command outputs are now (obviously) not logged. This is consistent with every other type of command sender, be it RCON, players, or anything else.
- The assumption that the console command sender must be able to see the logger output is now broken, since the command sender can receive output separately from the logs.

In the future, it might be desirable to send the console command output to stderr instead of stdout, so that stdout can be silenced while still allowing commands to be used.

closes #2543
2022-09-27 21:03:03 +01:00
Dylan T
83e5b0adb6
ConsoleCommandSender is no longer responsible for forwarding broadcast messages to the logger (#5311)
This is a step towards implementing #2543.
2022-09-27 20:58:33 +01:00
Dylan K. Taylor
7f175b47e6
Fix CS 2022-08-25 18:19:22 +01:00
Dylan K. Taylor
0e73ffe555
CrashDump: Added JIT mode to data
this is necessary for identifying JIT-specific bugs, which, unfortunately, are very common.
2022-08-25 17:39:40 +01:00
Dylan K. Taylor
5cb77c8365
GiveCommand: fix CS 2022-08-22 00:55:17 +01:00
IvanCraft623
bf8befc40b
Remove dead comment on GiveCommand (#5241) 2022-08-22 00:49:22 +01:00
Dylan K. Taylor
d144832928
GiveCommand: limit max amount in line with vanilla 2022-08-21 21:19:16 +01:00
Dylan K. Taylor
af2babec23
GiveCommand: do not accept negative amounts 2022-08-21 20:28:39 +01:00
Dylan K. Taylor
becbd562d6
FormattedCommandAlias: fixed incorrect arguments array being passed to the target 2022-06-07 19:47:45 +01:00
NoClip
e12e4e8fb8
StatusCommand: fixed output of global memory limit (#5090)
Fix incorrect "Maximum memory (manager)" output
2022-06-04 17:41:55 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
a38a5c67f1
GiveCommand: show the search term in audit message, instead of the ID
this is more useful in the longer term.
2022-05-21 15:49:17 +01:00
Dylan K. Taylor
d4b7f66e15
Promote some constructors 2022-05-17 22:34:58 +01:00
Dylan K. Taylor
3e1246acff
FormattedCommandAlias: Invoke commands directly with pre-parsed arguments
this resolves a range of issues with quoted arguments when using placeholders, as well as improving performance (no redundant combine -> re-parse needed).
2022-05-10 16:03:09 +01:00
Dylan K. Taylor
4c29f98292
"Fix CS" are going to be my final words ... 2022-05-10 15:39:44 +01:00
Dylan K. Taylor
5cc0d92eff
Fixed PHPStan errors 2022-05-10 15:38:26 +01:00
Dylan K. Taylor
a5ebbf8adb
Fix CS again 2022-05-10 15:23:55 +01:00
Dylan K. Taylor
217385efb9
CommandStringHelper::parse() returns a non-empty list of strings 2022-05-10 15:22:46 +01:00
Dylan K. Taylor
f70c36baf9
SimpleCommandMap: parse config-defined commands according to the same rules as manually typed commands 2022-05-10 15:21:39 +01:00
Dylan K. Taylor
d2e421c424
CommandStringHelper: fixed backslashes not being removed from escaped quotes
this time, without breaking eval commands ... stripslashes likes to strip ALL backslashes, whether they are actually escaping something or not, which is super annoying.
2022-05-10 15:09:57 +01:00
Dylan K. Taylor
72cfea3a63
SimpleCommandMap: extract command string parsing code into its own unit 2022-05-01 22:05:38 +01:00
Dylan K. Taylor
a353872327
FormattedCommandAlias: match placeholders using regex 2022-05-01 21:16:13 +01:00
Dylan K. Taylor
f4d71d0b48
FormattedCommandAlias: reduce complexity of buildCommand() 2022-05-01 21:04:38 +01:00
Dylan K. Taylor
dca457b1e0
Modernize property declarations in pocketmine\command namespace 2022-04-25 13:09:14 +01:00
Dylan K. Taylor
453bf6d73b
fix build 2022-04-10 21:37:10 +01:00
Dylan K. Taylor
3353a00641
List command aliases in /help <commandName> 2022-04-10 21:32:46 +01:00
Dylan K. Taylor
ab93135b84
Merge branch 'stable' into next-minor 2022-03-22 15:49:58 +00:00
Dylan K. Taylor
b4e1edaa64
CommandSender: provide more detailed types for getScreenLineHeight() and setScreenLineHeight() 2022-03-09 17:17:51 +00: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
d60dba2de0
DumpMemoryCommand: fixed memory dump dir 2022-02-20 20:39:53 +00:00
Dylan K. Taylor
2f32bd877a
Replace disallowed operators in src/command/ 2022-01-20 16:49:58 +00:00
Dylan K. Taylor
661848c5e7
fix more EOF newlines 2022-01-07 20:39:43 +00:00
Dylan K. Taylor
16fd5456aa
Merge branch 'stable' into next-minor 2021-12-18 00:39:58 +00:00
Alexey
93caf72f34
KickCommand: Add missing space
closes #4660
closes #4661
2021-12-17 21:09:14 +00:00
Matthew Jordan
a41404bd8a
Allow gamemode strings for gamemode property in server.properties (#4638)
closes #2692
2021-12-14 22:56:22 +00:00
Dylan K. Taylor
a94b88424e
Merge branch 'stable' into next-minor 2021-12-10 19:15:57 +00:00
Dylan K. Taylor
448f26cefc
SimpleCommandMap: do not strip backslashes from unquoted command arguments 2021-12-10 18:27:49 +00:00
Matthew Jordan
f8ed23cc1e
ClearCommand: Add OffHandInventory to $inventories (#4631) 2021-12-09 11:19:33 +00:00