mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 15:49:54 +00:00
Added AsyncTask::onCompletion()
This commit is contained in:
parent
f9d9d2b0e5
commit
80aebf2932
@ -1142,7 +1142,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
foreach($this->server->getOnlinePlayers() as $p){
|
||||
if($p !== $this and strtolower($p->getName()) === strtolower($this->getName())){
|
||||
if($p->kick("logged in from another location") === false){
|
||||
$this->close($this->getName() . " has left the game", "already logged in");
|
||||
$this->close($this->getName() . " has left the game", "Already logged in");
|
||||
|
||||
return;
|
||||
}else{
|
||||
@ -1190,11 +1190,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
parent::__construct($this->getLevel()->getChunkAt($nbt["Pos"][0], $nbt["Pos"][2], true), $nbt);
|
||||
$this->loggedIn = true;
|
||||
|
||||
if(($this->gamemode & 0x01) === 0x01){
|
||||
$this->inventory->setHeldItemSlot(0);
|
||||
$this->inventory->setItemInHand(Item::get(Item::STONE, 0, 1));
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
|
||||
if($ev->isCancelled()){
|
||||
$this->close($ev->getKickMessage(), "Plugin reason");
|
||||
@ -1202,6 +1197,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
if(($this->gamemode & 0x01) === 0x01){
|
||||
$this->inventory->setHeldItemSlot(0);
|
||||
$this->inventory->setItemInHand(Item::get(Item::STONE, 0, 1));
|
||||
}
|
||||
|
||||
$pk = new LoginStatusPacket;
|
||||
$pk->status = 0;
|
||||
$this->directDataPacket($pk);
|
||||
|
@ -1635,7 +1635,7 @@ class Server{
|
||||
$this->pluginManager->disablePlugins();
|
||||
|
||||
foreach($this->players as $player){
|
||||
$player->close($this->getProperty("settings.shutdown-message", "Server closed"), "server closed");
|
||||
$player->close($player->getName() . " has left the game", $this->getProperty("settings.shutdown-message", "Server closed"));
|
||||
}
|
||||
|
||||
foreach($this->getLevels() as $level){
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\scheduler;
|
||||
use pocketmine\Server;
|
||||
|
||||
/**
|
||||
* Class used to run async tasks in other threads.
|
||||
@ -91,4 +92,13 @@ abstract class AsyncTask extends \Threaded{
|
||||
*/
|
||||
public abstract function onRun();
|
||||
|
||||
/**
|
||||
* Actions to execute when completed (on main thread)
|
||||
*
|
||||
* @param Server $server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public abstract function onCompletion(Server $server);
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\ReversePriorityQueue;
|
||||
|
||||
class ServerScheduler{
|
||||
@ -216,7 +217,7 @@ class ServerScheduler{
|
||||
$this->asyncPool->collect(function (AsyncTask $task){
|
||||
if($task->isCompleted() or ($task->isFinished() and !$task->hasResult())){
|
||||
--$this->asyncTasks;
|
||||
|
||||
$task->onCompletion(Server::getInstance());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user