Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A system to let transactions decide what stuff can go into a particular inventory slot #6262

Open
dktapps opened this issue Feb 19, 2024 · 0 comments
Labels
Category: API Related to the plugin API Type: Change Proposal RFCs (Request for Comments) on change ideas for PocketMine-MP Type: Enhancement Contributes features or other improvements to PocketMine-MP

Comments

@dktapps
Copy link
Member

dktapps commented Feb 19, 2024

Description

This was previously attempted in #4479, but that implementation is limited and has gone stale.

When I originally thought about this, my idea was to have a separate InventorySlotAcceptor unit which would enforce requirements like this, avoiding circular dependencies or needing custom inventory classes, as well as being more flexible.

It would have a method something like

function accept(Inventory $inventory, Item $item) : bool

where the return value would indicate whether the item can be put into that slot or not.

Maybe it can even just be done with an Inventory::getSlotAcceptors() : ObjectSet<Closure(Inventory, Item) : bool> instead.

A system like this would allow any Inventory to receive new acceptors at any time, allowing plugins to introduce their own logic and potentially override builtin logic.

Justification

Slots for armour and offhand aren't currently validated.

Alternative methods

@dktapps dktapps added Category: API Related to the plugin API Type: Change Proposal RFCs (Request for Comments) on change ideas for PocketMine-MP Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Type: Change Proposal RFCs (Request for Comments) on change ideas for PocketMine-MP Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

No branches or pull requests

1 participant