DataPacketSendEvent: added setPackets()

this is an implicit BC break, since plugins may assume that the packets in this array aren't going to change.
However, in practice, it's not likely to cause any real issues.
This commit is contained in:
Dylan K. Taylor 2022-10-13 17:06:09 +01:00
parent f88ae93897
commit 774df0fa4c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 12 additions and 1 deletions

View File

@ -1359,6 +1359,7 @@ class Server{
return false;
}
$recipients = $ev->getTargets();
$packets = $ev->getPackets();
/** @var PacketBroadcaster[] $broadcasters */
$broadcasters = [];

View File

@ -56,4 +56,11 @@ class DataPacketSendEvent extends ServerEvent implements Cancellable{
public function getPackets() : array{
return $this->packets;
}
/**
* @param ClientboundPacket[] $packets
*/
public function setPackets(array $packets) : void{
$this->packets = $packets;
}
}

View File

@ -436,8 +436,11 @@ class NetworkSession{
if($ev->isCancelled()){
return false;
}
$packets = $ev->getPackets();
$this->addToSendBuffer($packet);
foreach($packets as $evPacket){
$this->addToSendBuffer($evPacket);
}
if($immediate){
$this->flushSendBuffer(true);
}