From 8473a5030c7e9bed6f7a25533a797361898ab47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Le=C3=B3n?= <58715544+JavierLeon9966@users.noreply.github.com> Date: Fri, 16 Feb 2024 08:15:53 +0000 Subject: [PATCH] Fixed crash when writing an incomplete command with variable span length (#19) * Updated to pm5 * Changed signature of Runnable->getPermission() to match PM5's signature * Added typehint to getPermissions() method * Update SimplePacketHandler virion * Fixed crash when writing an incomplete command with variable span length --- src/CortexPE/Commando/traits/ArgumentableTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CortexPE/Commando/traits/ArgumentableTrait.php b/src/CortexPE/Commando/traits/ArgumentableTrait.php index ed04419..42fd22d 100644 --- a/src/CortexPE/Commando/traits/ArgumentableTrait.php +++ b/src/CortexPE/Commando/traits/ArgumentableTrait.php @@ -96,6 +96,7 @@ public function parseArguments(array $rawArgs, CommandSender $sender): array { ]; } $offset = 0; + $argOffset = 0; if(count($rawArgs) > 0) { foreach($this->argumentList as $pos => $possibleArguments) { // try the one that spans more first... before the others @@ -128,6 +129,7 @@ public function parseArguments(array $rawArgs, CommandSender $sender): array { $required--; } $offset += $len; + ++$argOffset; $parsed = true; break; } @@ -136,7 +138,7 @@ public function parseArguments(array $rawArgs, CommandSender $sender): array { } } if(!$parsed && !($optional && empty($arg))) { // we tried every other possible argument type, none was satisfied - $expectedArgs = $this->argumentList[$offset]; + $expectedArgs = $this->argumentList[$argOffset]; $expected = ""; foreach($expectedArgs as $expectedArg){ $expected .= $expectedArg->getTypeName() . "|";