mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 05:15:13 +00:00
Server: cleanup setting up of console
This commit is contained in:
parent
c143834632
commit
cf43f479df
@ -198,9 +198,6 @@ class Server{
|
|||||||
/** @var ResourcePackManager */
|
/** @var ResourcePackManager */
|
||||||
private $resourceManager;
|
private $resourceManager;
|
||||||
|
|
||||||
/** @var ConsoleCommandSender */
|
|
||||||
private $consoleSender;
|
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $maxPlayers;
|
private $maxPlayers;
|
||||||
|
|
||||||
@ -1539,10 +1536,22 @@ class Server{
|
|||||||
|
|
||||||
$this->doTitleTick = ((bool) $this->getProperty("console.title-tick", true)) && Terminal::hasFormattingCodes();
|
$this->doTitleTick = ((bool) $this->getProperty("console.title-tick", true)) && Terminal::hasFormattingCodes();
|
||||||
|
|
||||||
|
|
||||||
|
$consoleSender = new ConsoleCommandSender();
|
||||||
|
PermissionManager::getInstance()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $consoleSender);
|
||||||
|
|
||||||
$consoleNotifier = new SleeperNotifier();
|
$consoleNotifier = new SleeperNotifier();
|
||||||
$this->console = new CommandReader($consoleNotifier);
|
$this->console = new CommandReader($consoleNotifier);
|
||||||
$this->tickSleeper->addNotifier($consoleNotifier, function() : void{
|
$this->tickSleeper->addNotifier($consoleNotifier, function() use ($consoleSender) : void{
|
||||||
$this->checkConsole();
|
Timings::$serverCommandTimer->startTiming();
|
||||||
|
while(($line = $this->console->getLine()) !== null){
|
||||||
|
$ev = new ServerCommandEvent($consoleSender, $line);
|
||||||
|
$ev->call();
|
||||||
|
if(!$ev->isCancelled()){
|
||||||
|
$this->dispatchCommand($ev->getSender(), $ev->getCommand());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Timings::$serverCommandTimer->stopTiming();
|
||||||
});
|
});
|
||||||
$this->console->start(PTHREADS_INHERIT_NONE);
|
$this->console->start(PTHREADS_INHERIT_NONE);
|
||||||
|
|
||||||
@ -1618,7 +1627,6 @@ class Server{
|
|||||||
Timings::init();
|
Timings::init();
|
||||||
TimingsHandler::setEnabled((bool) $this->getProperty("settings.enable-profiling", false));
|
TimingsHandler::setEnabled((bool) $this->getProperty("settings.enable-profiling", false));
|
||||||
|
|
||||||
$this->consoleSender = new ConsoleCommandSender();
|
|
||||||
$this->commandMap = new SimpleCommandMap($this);
|
$this->commandMap = new SimpleCommandMap($this);
|
||||||
|
|
||||||
Entity::init();
|
Entity::init();
|
||||||
@ -1635,7 +1643,6 @@ class Server{
|
|||||||
$this->resourceManager = new ResourcePackManager($this->getDataPath() . "resource_packs" . DIRECTORY_SEPARATOR, $this->logger);
|
$this->resourceManager = new ResourcePackManager($this->getDataPath() . "resource_packs" . DIRECTORY_SEPARATOR, $this->logger);
|
||||||
|
|
||||||
$this->pluginManager = new PluginManager($this, $this->commandMap, ((bool) $this->getProperty("plugins.legacy-data-dir", true)) ? null : $this->getDataPath() . "plugin_data" . DIRECTORY_SEPARATOR);
|
$this->pluginManager = new PluginManager($this, $this->commandMap, ((bool) $this->getProperty("plugins.legacy-data-dir", true)) ? null : $this->getDataPath() . "plugin_data" . DIRECTORY_SEPARATOR);
|
||||||
PermissionManager::getInstance()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
|
||||||
$this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20);
|
$this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20);
|
||||||
$this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader));
|
$this->pluginManager->registerInterface(new PharPluginLoader($this->autoloader));
|
||||||
$this->pluginManager->registerInterface(new ScriptPluginLoader());
|
$this->pluginManager->registerInterface(new ScriptPluginLoader());
|
||||||
@ -1934,18 +1941,6 @@ class Server{
|
|||||||
$this->pluginManager->disablePlugins();
|
$this->pluginManager->disablePlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkConsole(){
|
|
||||||
Timings::$serverCommandTimer->startTiming();
|
|
||||||
while(($line = $this->console->getLine()) !== null){
|
|
||||||
$ev = new ServerCommandEvent($this->consoleSender, $line);
|
|
||||||
$ev->call();
|
|
||||||
if(!$ev->isCancelled()){
|
|
||||||
$this->dispatchCommand($ev->getSender(), $ev->getCommand());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Timings::$serverCommandTimer->stopTiming();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command from a CommandSender
|
* Executes a command from a CommandSender
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user