Merge branch 'major-next' into inventory-rework

This commit is contained in:
Dylan T. 2024-11-26 11:45:52 +00:00 committed by GitHub
commit 5a35c25ad4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 21 deletions

View File

@ -11,8 +11,7 @@ on:
- opened
- reopened
- ready_for_review
pull_request_review:
types: dismissed
- synchronize
jobs:
dispatch:
@ -36,4 +35,4 @@ jobs:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.repository_owner }}/RestrictedActions
event-type: auto_approve_collaborator_pr
client-payload: '{"repo": "${{ github.repository }}", "pull_request_id": "${{ github.event.pull_request.number }}", "reviewer_id": "${{ github.event.review.user.id || 0 }}" }'
client-payload: '{"repo": "${{ github.repository }}", "pull_request_id": "${{ github.event.pull_request.number }}", "reviewer_id": "0" }'

View File

@ -112,6 +112,9 @@ class InventoryTransaction{
if(!isset($this->actions[$hash = spl_object_id($action)])){
$this->actions[$hash] = $action;
$action->onAddToTransaction($this);
if($action instanceof SlotChangeAction && !isset($this->inventoryWindows[$inventoryId = spl_object_id($action->getInventoryWindow())])){
$this->inventoryWindows[$inventoryId] = $action->getInventoryWindow();
}
}else{
throw new \InvalidArgumentException("Tried to add the same action to a transaction twice");
}
@ -130,16 +133,6 @@ class InventoryTransaction{
$this->actions = $actions;
}
/**
* @internal This method should not be used by plugins, it's used to add tracked inventories for InventoryActions
* involving inventories.
*/
public function addInventoryWindow(InventoryWindow $inventoryWindow) : void{
if(!isset($this->inventoryWindows[$hash = spl_object_id($inventoryWindow)])){
$this->inventoryWindows[$hash] = $inventoryWindow;
}
}
/**
* @param Item[] $needItems
* @param Item[] $haveItems

View File

@ -60,6 +60,7 @@ abstract class InventoryAction{
/**
* Called when the action is added to the specified InventoryTransaction.
* @deprecated
*/
public function onAddToTransaction(InventoryTransaction $transaction) : void{

View File

@ -25,7 +25,6 @@ namespace pocketmine\inventory\transaction\action;
use pocketmine\inventory\Inventory;
use pocketmine\inventory\SlotValidatedInventory;
use pocketmine\inventory\transaction\InventoryTransaction;
use pocketmine\inventory\transaction\TransactionValidationException;
use pocketmine\item\Item;
use pocketmine\player\InventoryWindow;
@ -87,13 +86,6 @@ class SlotChangeAction extends InventoryAction{
}
}
/**
* Adds this action's target inventory to the transaction's inventory list.
*/
public function onAddToTransaction(InventoryTransaction $transaction) : void{
$transaction->addInventoryWindow($this->inventoryWindow);
}
/**
* Sets the item into the target inventory.
*/

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\permission;
use pocketmine\Server;
use pocketmine\utils\Utils;
use function count;
use function spl_object_id;
@ -71,6 +72,10 @@ class PermissionManager{
}
}
/**
* @deprecated Superseded by server chat broadcast channels
* @see Server::subscribeToBroadcastChannel()
*/
public function subscribeToPermission(string $permission, PermissibleInternal $permissible) : void{
if(!isset($this->permSubs[$permission])){
$this->permSubs[$permission] = [];
@ -78,6 +83,10 @@ class PermissionManager{
$this->permSubs[$permission][spl_object_id($permissible)] = $permissible;
}
/**
* @deprecated Superseded by server chat broadcast channels
* @see Server::unsubscribeFromBroadcastChannel()
*/
public function unsubscribeFromPermission(string $permission, PermissibleInternal $permissible) : void{
if(isset($this->permSubs[$permission][spl_object_id($permissible)])){
if(count($this->permSubs[$permission]) === 1){
@ -88,6 +97,10 @@ class PermissionManager{
}
}
/**
* @deprecated Superseded by server chat broadcast channels
* @see Server::unsubscribeFromAllBroadcastChannels()
*/
public function unsubscribeFromAllPermissions(PermissibleInternal $permissible) : void{
foreach(Utils::promoteKeys($this->permSubs) as $permission => $subs){
if(count($subs) === 1 && isset($subs[spl_object_id($permissible)])){
@ -99,6 +112,8 @@ class PermissionManager{
}
/**
* @deprecated Superseded by server chat broadcast channels
* @see Server::getBroadcastChannelSubscribers()
* @return PermissibleInternal[]
*/
public function getPermissionSubscriptions(string $permission) : array{