mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
Player: move sendAllInventories() to network layer
This commit is contained in:
parent
85718e2750
commit
33d1203bfd
@ -2594,7 +2594,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
$this->sendData($this->getViewers());
|
||||
|
||||
$this->networkSession->syncAdventureSettings($this);
|
||||
$this->sendAllInventories();
|
||||
$this->networkSession->syncAllInventoryContents();
|
||||
|
||||
$this->spawnToAll();
|
||||
$this->scheduleUpdate();
|
||||
@ -2878,10 +2878,11 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
}
|
||||
}
|
||||
|
||||
public function sendAllInventories(){
|
||||
foreach($this->windowIndex as $networkId => $inventory){
|
||||
$inventory->sendContents($this);
|
||||
}
|
||||
/**
|
||||
* @return Inventory[]
|
||||
*/
|
||||
public function getAllWindows() : array{
|
||||
return $this->windowIndex;
|
||||
}
|
||||
|
||||
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{
|
||||
|
@ -819,6 +819,12 @@ class NetworkSession{
|
||||
}
|
||||
}
|
||||
|
||||
public function syncAllInventoryContents() : void{
|
||||
foreach($this->player->getAllWindows() as $inventory){
|
||||
$this->syncInventoryContents($inventory);
|
||||
}
|
||||
}
|
||||
|
||||
public function syncInventoryData(Inventory $inventory, int $propertyId, int $value) : void{
|
||||
$windowId = $this->player->getWindowId($inventory);
|
||||
if($windowId !== ContainerIds::NONE){
|
||||
|
@ -158,7 +158,7 @@ class InGameSessionHandler extends SessionHandler{
|
||||
|
||||
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
|
||||
if($this->player->isSpectator()){
|
||||
$this->player->sendAllInventories();
|
||||
$this->session->syncAllInventoryContents();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ class InGameSessionHandler extends SessionHandler{
|
||||
if($packet->trData instanceof NormalTransactionData){
|
||||
$result = $this->handleNormalTransaction($packet->trData);
|
||||
}elseif($packet->trData instanceof MismatchTransactionData){
|
||||
$this->player->sendAllInventories();
|
||||
$this->session->syncAllInventoryContents();
|
||||
$result = true;
|
||||
}elseif($packet->trData instanceof UseItemTransactionData){
|
||||
$result = $this->handleUseItemTransaction($packet->trData);
|
||||
@ -178,7 +178,7 @@ class InGameSessionHandler extends SessionHandler{
|
||||
}
|
||||
|
||||
if(!$result){
|
||||
$this->player->sendAllInventories();
|
||||
$this->session->syncAllInventoryContents();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class PreSpawnSessionHandler extends SessionHandler{
|
||||
$this->player->sendPotionEffects($this->player);
|
||||
$this->player->sendData($this->player);
|
||||
|
||||
$this->player->sendAllInventories();
|
||||
$this->session->syncAllInventoryContents();
|
||||
$this->player->getInventory()->sendCreativeContents();
|
||||
$this->player->getInventory()->sendHeldItem($this->player);
|
||||
$this->session->queueCompressed($this->server->getCraftingManager()->getCraftingDataPacket());
|
||||
|
Loading…
x
Reference in New Issue
Block a user