mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Fixed kicking players not working properly
This commit is contained in:
parent
6828ce66b6
commit
17e4f45e97
@ -1768,8 +1768,9 @@ class Server{
|
|||||||
* @param Player[] $players
|
* @param Player[] $players
|
||||||
* @param DataPacket[]|string $packets
|
* @param DataPacket[]|string $packets
|
||||||
* @param bool $forceSync
|
* @param bool $forceSync
|
||||||
|
* @param bool $immediate
|
||||||
*/
|
*/
|
||||||
public function batchPackets(array $players, array $packets, $forceSync = false){
|
public function batchPackets(array $players, array $packets, $forceSync = false, bool $immediate = false){
|
||||||
Timings::$playerNetworkTimer->startTiming();
|
Timings::$playerNetworkTimer->startTiming();
|
||||||
|
|
||||||
$pk = new BatchPacket();
|
$pk = new BatchPacket();
|
||||||
@ -1786,25 +1787,34 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$forceSync and $this->networkCompressionAsync){
|
if(!$forceSync and $this->networkCompressionAsync){
|
||||||
$task = new CompressBatchedTask($pk, $targets, $this->networkCompressionLevel);
|
$task = new CompressBatchedTask($pk, $targets, $this->networkCompressionLevel, $immediate);
|
||||||
$this->getScheduler()->scheduleAsyncTask($task);
|
$this->getScheduler()->scheduleAsyncTask($task);
|
||||||
}else{
|
}else{
|
||||||
$pk->compress($this->networkCompressionLevel);
|
$pk->compress($this->networkCompressionLevel);
|
||||||
$this->broadcastPacketsCallback($pk, $targets);
|
$this->broadcastPacketsCallback($pk, $targets, $immediate);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timings::$playerNetworkTimer->stopTiming();
|
Timings::$playerNetworkTimer->stopTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function broadcastPacketsCallback(BatchPacket $pk, array $identifiers){
|
public function broadcastPacketsCallback(BatchPacket $pk, array $identifiers, bool $immediate){
|
||||||
$pk->encode();
|
$pk->encode();
|
||||||
$pk->isEncoded = true;
|
$pk->isEncoded = true;
|
||||||
|
|
||||||
foreach($identifiers as $i){
|
if($immediate){
|
||||||
if(isset($this->players[$i])){
|
foreach($identifiers as $i){
|
||||||
$this->players[$i]->dataPacket($pk);
|
if(isset($this->players[$i])){
|
||||||
|
$this->players[$i]->directDataPacket($pk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
foreach($identifiers as $i){
|
||||||
|
if(isset($this->players[$i])){
|
||||||
|
$this->players[$i]->dataPacket($pk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,11 +31,13 @@ class CompressBatchedTask extends AsyncTask{
|
|||||||
public $data;
|
public $data;
|
||||||
public $final;
|
public $final;
|
||||||
public $targets;
|
public $targets;
|
||||||
|
public $immediate = false;
|
||||||
|
|
||||||
public function __construct(BatchPacket $data, array $targets, $level = 7){
|
public function __construct(BatchPacket $data, array $targets, $level = 7, bool $sendImmediate = false){
|
||||||
$this->data = serialize($data);
|
$this->data = serialize($data);
|
||||||
$this->targets = $targets;
|
$this->targets = $targets;
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
$this->immediate = $sendImmediate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onRun(){
|
public function onRun(){
|
||||||
@ -51,6 +53,6 @@ class CompressBatchedTask extends AsyncTask{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onCompletion(Server $server){
|
public function onCompletion(Server $server){
|
||||||
$server->broadcastPacketsCallback(unserialize($this->final), (array) $this->targets);
|
$server->broadcastPacketsCallback(unserialize($this->final), (array) $this->targets, $this->immediate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user