mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
Transition to spl_object_id()
This commit is contained in:
@@ -37,7 +37,7 @@ use function array_slice;
|
||||
use function count;
|
||||
use function max;
|
||||
use function min;
|
||||
use function spl_object_hash;
|
||||
use function spl_object_id;
|
||||
|
||||
abstract class BaseInventory implements Inventory{
|
||||
|
||||
@@ -420,11 +420,11 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
|
||||
public function onOpen(Player $who) : void{
|
||||
$this->viewers[spl_object_hash($who)] = $who;
|
||||
$this->viewers[spl_object_id($who)] = $who;
|
||||
}
|
||||
|
||||
public function onClose(Player $who) : void{
|
||||
unset($this->viewers[spl_object_hash($who)]);
|
||||
unset($this->viewers[spl_object_id($who)]);
|
||||
}
|
||||
|
||||
public function onSlotChange(int $index, Item $before, bool $send) : void{
|
||||
|
@@ -34,6 +34,7 @@ use function count;
|
||||
use function get_class;
|
||||
use function min;
|
||||
use function spl_object_hash;
|
||||
use function spl_object_id;
|
||||
|
||||
/**
|
||||
* This InventoryTransaction only allows doing Transaction between one / two inventories
|
||||
@@ -85,7 +86,7 @@ class InventoryTransaction{
|
||||
* @param InventoryAction $action
|
||||
*/
|
||||
public function addAction(InventoryAction $action) : void{
|
||||
if(!isset($this->actions[$hash = spl_object_hash($action)])){
|
||||
if(!isset($this->actions[$hash = spl_object_id($action)])){
|
||||
$this->actions[$hash] = $action;
|
||||
$action->onAddToTransaction($this);
|
||||
}else{
|
||||
@@ -100,7 +101,7 @@ class InventoryTransaction{
|
||||
* @param Inventory $inventory
|
||||
*/
|
||||
public function addInventory(Inventory $inventory) : void{
|
||||
if(!isset($this->inventories[$hash = spl_object_hash($inventory)])){
|
||||
if(!isset($this->inventories[$hash = spl_object_id($inventory)])){
|
||||
$this->inventories[$hash] = $inventory;
|
||||
}
|
||||
}
|
||||
@@ -188,7 +189,7 @@ class InventoryTransaction{
|
||||
}
|
||||
|
||||
foreach($list as $action){
|
||||
unset($this->actions[spl_object_hash($action)]);
|
||||
unset($this->actions[spl_object_id($action)]);
|
||||
}
|
||||
|
||||
if(!$targetItem->equalsExact($sourceItem)){
|
||||
|
@@ -27,7 +27,7 @@ use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\transaction\InventoryTransaction;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Player;
|
||||
use function spl_object_hash;
|
||||
use function spl_object_id;
|
||||
|
||||
/**
|
||||
* Represents an action causing a change in an inventory slot.
|
||||
@@ -110,7 +110,7 @@ class SlotChangeAction extends InventoryAction{
|
||||
*/
|
||||
public function onExecuteSuccess(Player $source) : void{
|
||||
$viewers = $this->inventory->getViewers();
|
||||
unset($viewers[spl_object_hash($source)]);
|
||||
unset($viewers[spl_object_id($source)]);
|
||||
$this->inventory->sendSlot($this->inventorySlot, $viewers);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user