Skip to content

Commit

Permalink
Fixed crash when writing an incomplete command with variable span len…
Browse files Browse the repository at this point in the history
…gth (#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
  • Loading branch information
JavierLeon9966 authored Feb 16, 2024
1 parent f5c8fcf commit 8473a50
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/CortexPE/Commando/traits/ArgumentableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -128,6 +129,7 @@ public function parseArguments(array $rawArgs, CommandSender $sender): array {
$required--;
}
$offset += $len;
++$argOffset;
$parsed = true;
break;
}
Expand All @@ -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() . "|";
Expand Down

0 comments on commit 8473a50

Please sign in to comment.