mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 19:37:17 +00:00
Cleaned up batching checks
This commit is contained in:
parent
4d897b824b
commit
bf9b8722c9
@ -57,6 +57,9 @@ class BatchPacket extends DataPacket{
|
|||||||
*/
|
*/
|
||||||
public function addPacket($packet){
|
public function addPacket($packet){
|
||||||
if($packet instanceof DataPacket){
|
if($packet instanceof DataPacket){
|
||||||
|
if(!$packet->canBeBatched()){
|
||||||
|
throw new \InvalidArgumentException(get_class($packet) . " cannot be put inside a BatchPacket");
|
||||||
|
}
|
||||||
if(!$packet->isEncoded){
|
if(!$packet->isEncoded){
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
}
|
}
|
||||||
@ -93,9 +96,10 @@ class BatchPacket extends DataPacket{
|
|||||||
while(!$this->feof()){
|
while(!$this->feof()){
|
||||||
$buf = $this->getString();
|
$buf = $this->getString();
|
||||||
$pk = $network->getPacket(ord($buf{0}));
|
$pk = $network->getPacket(ord($buf{0}));
|
||||||
/*if(!$pk->canBeBatched()){
|
|
||||||
|
if(!$pk->canBeBatched()){
|
||||||
throw new \InvalidArgumentException("Received invalid " . get_class($pk) . " inside BatchPacket");
|
throw new \InvalidArgumentException("Received invalid " . get_class($pk) . " inside BatchPacket");
|
||||||
}*/
|
}
|
||||||
|
|
||||||
$pk->setBuffer($buf, 1);
|
$pk->setBuffer($buf, 1);
|
||||||
$session->handleDataPacket($pk);
|
$session->handleDataPacket($pk);
|
||||||
|
@ -44,10 +44,6 @@ class LoginPacket extends DataPacket{
|
|||||||
|
|
||||||
public $clientData = [];
|
public $clientData = [];
|
||||||
|
|
||||||
public function canBeBatched() : bool{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function canBeSentBeforeLogin() : bool{
|
public function canBeSentBeforeLogin() : bool{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user