-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed as not planned
Closed as not planned
Copy link
Labels
Category: APIRelated to the plugin APIRelated to the plugin APIResolution: ObsoleteSuperseded by other changesSuperseded by other changesType: EnhancementContributes features or other improvements to PocketMine-MPContributes features or other improvements to PocketMine-MP
Description
Problem description
Currently, SimpleCommandMap hardcoded the handling of command line when parsing them to args and there is not a non-hacky way to handle the raw inputs data without messing too much with PMMP internal.
Proposed solution
Allow command itself to dispatch/parse command line to args by itself via an internal method that can be overridden. The SimpleCommandMap only take the first token from the command line to find the command entry.
<?php
class Command{
...
public function parseCommandLine(string $commandLine) : array{
return CommandHelper::parseQuoteAware($commandLine);
}
...
}
class CustomCommand extends Command{
public function parseCommandLine(string $commandLine) : array{
// Custom parse
}
}
class SimpleCommandMap{
...
public function dispatch(CommandSender $sender, string $commandLine) : bool{
$sentCommandLabel = "";
$parts = preg_split('/\s+/u', $commandLine, 2);
if($parts !== false) {
$sentCommandLabel = $parts[0];
if ($target = $this->getEntry($sentCommandLabel)) !== null){
$args = $target->command->handleCommandLine($parts[1]);
// Command execute and stuff
}
}
...
}Alternative solutions or workarounds
A plugin can create an extend of SimpleComamndMap, move over the data and then use reflection API/Closure bind to change the commandMap in Server instance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Category: APIRelated to the plugin APIRelated to the plugin APIResolution: ObsoleteSuperseded by other changesSuperseded by other changesType: EnhancementContributes features or other improvements to PocketMine-MPContributes features or other improvements to PocketMine-MP
Type
Projects
Status
Abandoned