mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-17 04:06:54 +00:00
Move command timings to Timings::
this avoids duplicate timings entries when command labels are changed and changed back, or if multiple command maps are in use. In addition, it also solves some PHPStan issues :)
This commit is contained in:
@@ -68,6 +68,7 @@ use pocketmine\command\utils\CommandStringHelper;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use function array_shift;
|
||||
use function count;
|
||||
@@ -199,7 +200,8 @@ class SimpleCommandMap implements CommandMap{
|
||||
|
||||
$sentCommandLabel = array_shift($args);
|
||||
if($sentCommandLabel !== null && ($target = $this->getCommand($sentCommandLabel)) !== null){
|
||||
$target->timings->startTiming();
|
||||
$timings = Timings::getCommandDispatchTimings($target->getLabel());
|
||||
$timings->startTiming();
|
||||
|
||||
try{
|
||||
if($target->testPermission($sender)){
|
||||
@@ -208,7 +210,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
}catch(InvalidCommandSyntaxException $e){
|
||||
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($target->getUsage())));
|
||||
}finally{
|
||||
$target->timings->stopTiming();
|
||||
$timings->stopTiming();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user