mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 19:59:11 +00:00
Don't scan the entire command string looking for literals
we only care if it's in the exact position defined by $offset.
This commit is contained in:
@@ -32,7 +32,6 @@ use pocketmine\command\CommandSender;
|
|||||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||||
use pocketmine\lang\Translatable;
|
use pocketmine\lang\Translatable;
|
||||||
use pocketmine\permission\PermissionManager;
|
use pocketmine\permission\PermissionManager;
|
||||||
use pocketmine\utils\AssumptionFailedError;
|
|
||||||
use function array_key_last;
|
use function array_key_last;
|
||||||
use function count;
|
use function count;
|
||||||
use function get_class;
|
use function get_class;
|
||||||
@@ -40,7 +39,7 @@ use function implode;
|
|||||||
use function is_string;
|
use function is_string;
|
||||||
use function preg_match;
|
use function preg_match;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
use function strpos;
|
use function substr_compare;
|
||||||
|
|
||||||
final class CommandOverload{
|
final class CommandOverload{
|
||||||
|
|
||||||
@@ -195,7 +194,7 @@ final class CommandOverload{
|
|||||||
if($offset < strlen($commandLine)){
|
if($offset < strlen($commandLine)){
|
||||||
foreach($this->parameters as $parameter){
|
foreach($this->parameters as $parameter){
|
||||||
if(is_string($parameter)){
|
if(is_string($parameter)){
|
||||||
if(strpos($commandLine, $parameter, $offset) === $offset){
|
if(substr_compare($commandLine, $parameter, $offset, strlen($parameter)) === 0){
|
||||||
$offset += strlen($parameter);
|
$offset += strlen($parameter);
|
||||||
$literals++;
|
$literals++;
|
||||||
}else{
|
}else{
|
||||||
|
Reference in New Issue
Block a user