44    private array $enumConstraintIndex = [];
 
   50    private array $linkedEnumCache = [];
 
   55    private array $linkedChainedSubCommandDataCache = [];
 
   61    private array $unusedHardEnumValues;
 
   66    private array $unusedPostfixes;
 
   72    private array $unusedHardEnumRawData;
 
   77    private array $unusedSoftEnums;
 
   82    private array $unusedChainedSubCommandRawData;
 
   87    private array $unusedChainedSubCommandValues;
 
   90        $this->packet = $packet;
 
   91        $this->unusedHardEnumValues = $packet->enumValues;
 
   92        $this->unusedHardEnumRawData = $packet->enums;
 
   93        $this->unusedSoftEnums = $packet->softEnums;
 
   94        $this->unusedPostfixes = $packet->postfixes;
 
   95        $this->unusedChainedSubCommandRawData = $packet->chainedSubCommandData;
 
   96        $this->unusedChainedSubCommandValues = $packet->chainedSubCommandValues;
 
  100        $result = 
new self($packet);
 
  103        $repeatedEnumConstraints = [];
 
  104        foreach($packet->enumConstraints as $index => $rawConstraintData){
 
  105            $enumIndex = $rawConstraintData->getEnumIndex();
 
  106            $affectedValueIndex = $rawConstraintData->getAffectedValueIndex();
 
  107            if(isset($result->enumConstraintIndex[$enumIndex][$affectedValueIndex])){
 
  108                $repeatedEnumConstraints[$index] = $rawConstraintData;
 
  110                $result->enumConstraintIndex[$rawConstraintData->getEnumIndex()][$rawConstraintData->getAffectedValueIndex()] = $rawConstraintData;
 
  114        $unusedCommandData = [];
 
  115        foreach($packet->commandData as $rawData){
 
  116            $unusedCommandData[] = $result->processCommandData($rawData);
 
  118        $unusedHardEnums = [];
 
  119        foreach($result->unusedHardEnumRawData as $index => $rawData){
 
  120            $unusedHardEnums[$index] = $result->lookupHardEnum($index);
 
  122        $unusedChainedSubCommandData = [];
 
  123        foreach($result->unusedChainedSubCommandRawData as $index => $rawData){
 
  124            $unusedChainedSubCommandData[$index] = $result->lookupChainedSubCommandData($index);
 
  129            $result->unusedHardEnumValues,
 
  130            $result->unusedPostfixes,
 
  132            $result->unusedSoftEnums,
 
  133            $unusedChainedSubCommandData,
 
  134            $result->unusedChainedSubCommandValues,
 
  135            $repeatedEnumConstraints
 
  142    private function lookupHardEnumValue(
int $index) : 
string{
 
  143        $value = $this->packet->enumValues[$index] ?? 
throw new PacketDecodeException(
"No such enum value index $index");
 
  144        unset($this->unusedHardEnumValues[$index]);
 
  152        if(!isset($this->linkedEnumCache[$index])){
 
  153            $rawEnum = $this->packet->enums[$index] ?? 
throw new PacketDecodeException(
"No such enum index $index");
 
  156            foreach($rawEnum->getValueIndexes() as $valueIndex){
 
  157                $value = $this->lookupHardEnumValue($valueIndex);
 
  159                $rawConstraint = $this->enumConstraintIndex[$index][$valueIndex] ?? 
null;
 
  160                if($rawConstraint !== 
null){
 
  163                    $enumValues[] = $value;
 
  167            $this->linkedEnumCache[$index] = 
new CommandHardEnum($rawEnum->getName(), $enumValues);
 
  168            unset($this->unusedHardEnumRawData[$index]);
 
  171        return $this->linkedEnumCache[$index];
 
  179        return $this->packet->softEnums[$index] ?? 
throw new PacketDecodeException(
"No such soft enum index $index");
 
  185    private function lookupChainedSubCommandValue(
int $index) : 
string{
 
  186        $value = $this->packet->chainedSubCommandValues[$index] ?? 
throw new PacketDecodeException(
"No such chained subcommand value index $index");
 
  187        unset($this->unusedChainedSubCommandValues[$index]);
 
  195        if(!isset($this->linkedChainedSubCommandDataCache[$index])){
 
  196            $rawData = $this->packet->chainedSubCommandData[$index] ?? 
throw new PacketDecodeException(
"No such chained subcommand index $index");
 
  199            foreach($rawData->getValueData() as $rawValueData){
 
  200                $valueName = $this->lookupChainedSubCommandValue($rawValueData->getNameIndex());
 
  204            $this->linkedChainedSubCommandDataCache[$index] = 
new ChainedSubCommandData($rawData->getName(), $values);
 
  205            unset($this->unusedChainedSubCommandRawData[$index]);
 
  208        return $this->linkedChainedSubCommandDataCache[$index];
 
  214    private function lookupPostfix(
int $index) : 
string{
 
  215        $value = $this->packet->postfixes[$index] ?? 
throw new PacketDecodeException(
"No such postfix index $index");
 
  216        unset($this->unusedPostfixes[$index]);
 
  221        $aliasesIndex = $rawData->getAliasEnumIndex();
 
  222        $aliasesEnum = $aliasesIndex === -1 ? null : $this->lookupHardEnum($aliasesIndex);
 
  224        $chainedSubCommandData = [];
 
  225        foreach($rawData->getChainedSubCommandDataIndexes() as $dataIndex){
 
  226            $chainedSubCommandData[] = $this->lookupChainedSubCommandData($dataIndex);
 
  230        foreach($rawData->getOverloads() as $overloadIndex => $rawOverloadData){
 
  232            foreach($rawOverloadData->getParameters() as $parameterIndex => $rawParameterData){
 
  233                $typeInfo = $rawParameterData->getTypeInfo();
 
  234                $flags = $typeInfo & (
 
  236                    AvailableCommandsPacket::ARG_FLAG_SOFT_ENUM |
 
  243                $highLevelTypeInfo = 0;
 
  246                    $enum = $this->lookupHardEnum($index);
 
  249                    $enum = $this->lookupSoftEnum($index);
 
  252                    $postfix = $this->lookupPostfix($index);
 
  256                    throw new PacketDecodeException(
"Unrecognized arg flag combination $typeInfo for command " . $rawData->getName() . 
", overload $overloadIndex, parameter $parameterIndex");
 
  260                    paramName: $rawParameterData->getName(),
 
  261                    paramType: $highLevelTypeInfo,
 
  262                    isOptional: $rawParameterData->isOptional(),
 
  263                    flags: $rawParameterData->getFlags(),
 
  269            $overloads[] = 
new CommandOverload($rawOverloadData->isChaining(), $parameters);
 
  273            name: $rawData->getName(),
 
  274            description: $rawData->getDescription(),
 
  275            flags: $rawData->getFlags(),
 
  276            permission: $rawData->getPermission(),
 
  277            aliases: $aliasesEnum,
 
  278            overloads: $overloads,
 
  279            chainedSubCommandData: $chainedSubCommandData