-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in subcommands #20
Comments
Is |
I did some testing and realized that this is where the sub command parts come into play. public function generateGenericCommandData(string $name, array $aliases, string $description, string $usage, bool $hasPermission = false) : CommandData{
...
...
for($argNumber = 0; $argumentCount >= 0 && $argNumber <= $argumentCount; ++$argNumber){
if($matches[1][$argNumber] === '' || $matches[3][$argNumber] === ''){
$paramName = mb_strtolower($matches[2][$argNumber]);
$softEnums = $this->getSoftEnums();
var_dump($commandString, $paramName);
if(isset($softEnums[$paramName])){
$enum = $softEnums[$paramName];
}else{
$this->addSoftEnum($enum = new CommandEnum($paramName, [$paramName], true), false);
}
$treeOverloads[$argNumber] = CommandParameter::enum($paramName, $enum, CommandParameter::FLAG_FORCE_COLLAPSE_ENUM, false); // collapse and assume required because no $optional identifier exists in usage message
continue;
} var_dump result:
If you look you can see all the sub commands. i think The bug must be here. I will look into it some more |
Update your install. I changed some strings for parsing |
After a long time, I think I found the problem. Enums that will be subcommand must be hardcoded enums Code: public function onDataPacketSendEvent(DataPacketSendEvent $event)
{
$packs = $event->getPackets();
foreach ($packs as $pack) {
if($pack instanceof AvailableCommandsPacket){
$overloads = [];
$overloads[] = new CommandOverload(false, [
0 => (CommandParameter::enum("subcmd", new CommandEnum("subcmd", ["subcmd"]), 0)), //default "isSoft" value is false
1 => (CommandParameter::standard("argumentTest", AvailableCommandsPacket::ARG_TYPE_INT, 0, false))
]);
$pack->commandData = [];
$pack->commandData["testcmd"] = new CommandData("testcmd", "test desc", 0, 1, null, $overloads, []);
}
}
} But if you set the isSoft of CommandEnum in parameter 0 to true: 0 => (CommandParameter::enum("subcmd", new CommandEnum("subcmd", ["subcmd"], true), 0)), //isSoft value is currently true However, since your plugin seemed complicated to me, I could not adapt it. Please take this message into consideration. Thank you from now. |
Does the mentioned commit resolve your issue? |
Issue description
OS and versions
Console error, backtrace or other files
Expected:
Actual:
The text was updated successfully, but these errors were encountered: