mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Merge branch 'release/3.4'
This commit is contained in:
commit
0028ce0ed2
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\command;
|
||||
|
||||
use pocketmine\lang\TranslationContainer;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
@ -49,11 +48,6 @@ class FormattedCommandAlias extends Command{
|
||||
$commands[] = $this->buildCommand($formatString, $args);
|
||||
}catch(\InvalidArgumentException $e){
|
||||
$sender->sendMessage(TextFormat::RED . $e->getMessage());
|
||||
return false;
|
||||
}catch(\Throwable $e){
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
|
||||
$sender->getServer()->getLogger()->logException($e);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -65,9 +65,7 @@ use pocketmine\command\defaults\VanillaCommand;
|
||||
use pocketmine\command\defaults\VersionCommand;
|
||||
use pocketmine\command\defaults\WhitelistCommand;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\lang\TranslationContainer;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class SimpleCommandMap implements CommandMap{
|
||||
|
||||
@ -258,14 +256,10 @@ class SimpleCommandMap implements CommandMap{
|
||||
$target->execute($sender, $sentCommandLabel, $args);
|
||||
}catch(InvalidCommandSyntaxException $e){
|
||||
$sender->sendMessage($this->server->getLanguage()->translateString("commands.generic.usage", [$target->getUsage()]));
|
||||
}catch(\Throwable $e){
|
||||
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
|
||||
$this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.command.exception", [$commandLine, (string) $target, $e->getMessage()]));
|
||||
$sender->getServer()->getLogger()->logException($e);
|
||||
}finally{
|
||||
$target->timings->stopTiming();
|
||||
}
|
||||
|
||||
$target->timings->stopTiming();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,6 @@ namespace pocketmine\scheduler;
|
||||
use pocketmine\utils\ReversePriorityQueue;
|
||||
|
||||
class TaskScheduler{
|
||||
/** @var \Logger */
|
||||
private $logger;
|
||||
/** @var string|null */
|
||||
private $owner;
|
||||
|
||||
@ -54,9 +52,11 @@ class TaskScheduler{
|
||||
/** @var int */
|
||||
protected $currentTick = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @param \Logger $logger @deprecated
|
||||
* @param null|string $owner
|
||||
*/
|
||||
public function __construct(\Logger $logger, ?string $owner = null){
|
||||
$this->logger = $logger;
|
||||
$this->owner = $owner;
|
||||
$this->queue = new ReversePriorityQueue();
|
||||
}
|
||||
@ -108,11 +108,9 @@ class TaskScheduler{
|
||||
if(isset($this->tasks[$taskId])){
|
||||
try{
|
||||
$this->tasks[$taskId]->cancel();
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->critical("Task " . $this->tasks[$taskId]->getTaskName() . " threw an exception when trying to cancel: " . $e->getMessage());
|
||||
$this->logger->logException($e);
|
||||
}finally{
|
||||
unset($this->tasks[$taskId]);
|
||||
}
|
||||
unset($this->tasks[$taskId]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,26 +196,14 @@ class TaskScheduler{
|
||||
unset($this->tasks[$task->getTaskId()]);
|
||||
continue;
|
||||
}
|
||||
$crashed = false;
|
||||
try{
|
||||
$task->run($this->currentTick);
|
||||
}catch(\Throwable $e){
|
||||
$crashed = true;
|
||||
$this->logger->critical("Could not execute task " . $task->getTaskName() . ": " . $e->getMessage());
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
$task->run($this->currentTick);
|
||||
if($task->isRepeating()){
|
||||
if($crashed){
|
||||
$this->logger->debug("Dropping repeating task " . $task->getTaskName() . " due to exceptions thrown while running");
|
||||
}else{
|
||||
$task->setNextRun($this->currentTick + $task->getPeriod());
|
||||
$this->queue->insert($task, $this->currentTick + $task->getPeriod());
|
||||
continue;
|
||||
}
|
||||
$task->setNextRun($this->currentTick + $task->getPeriod());
|
||||
$this->queue->insert($task, $this->currentTick + $task->getPeriod());
|
||||
}else{
|
||||
$task->remove();
|
||||
unset($this->tasks[$task->getTaskId()]);
|
||||
}
|
||||
|
||||
$task->remove();
|
||||
unset($this->tasks[$task->getTaskId()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user