Return array of matches in `Server::getPlayerByPrefix()` (or add an alternative to do so)
dktapps opened this issue · 0 comments
Description
Instead of returning a single target, it should return all the potential matches. This would allow commands to bail out if there's more than one target, preventing most unintended targeting.
Justification
getPlayerByPrefix()
is used by almost all commands. This is dangerous, because the result may suddenly change if a new player joins the server, meaning that reusing a previously-typed command may do something unintended.
This is described here: https://github.com/pmmp/PocketMine-MP/blame/b2aa6396c3cc2cafdd815eacc360e1ad89599899/src/Server.php#L606
Alternative methods
That being said, it's still possible for problems to arise in the example described if SteveJ
quits the server, as commands referring to SteveJ
would then target SteveJobs
as the only online target. So maybe it's better to just get rid of this feature entirely in favour of typing out full player names and/or using command selectors (needs #6519).