-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Validate transaction slots #6304
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
Conversation
Each inventory can provide any validator for their transaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be done with closures
src/inventory/transaction/validator/ArmorInventoryValidator.php
Outdated
Show resolved
Hide resolved
src/inventory/transaction/validator/InventoryTransactionValidator.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept looks fine.
However, as previously discussed on Discord, I think that all validators should accept the item in order to allow the transaction to proceed, as opposed to the current behaviour of only one. The current behaviour does not make sense to me - I think it's more likely that people will want to add extra restrictions instead of overriding existing ones
Alright, I think we are done with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, minus a couple of nits and suggestions
Co-authored-by: Dylan T. <[email protected]>
Co-authored-by: ipad54 <[email protected]>
Co-authored-by: ipad54 <[email protected]>
e76f03c
e8adc49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Feel free to merge it
Introduction
At present, we can place an item in any slot in an inventory (except in exceptional cases).
It is now necessary to provide a system for verifying transactions in order to guarantee a stable internal state for each inventory.
To maintain compatibility and avoid changing the Inventory interface. A new interface has been created, introducing a new notion of : "slot safe".
I named an inventory slot safe when we are guaranteed that the internal state is consistent with what it should do. So it's up to the core (for inventory implemented by pmmp) and plugin developers to make sure they implement the right validation logic.
Relevant issues
Changes
API changes
SlotSafeInventory
SlotValidator
Behavioural changes
ArmorInventory
checked now correctly their slots.Backwards compatibility
Enforced by the
SlotSafeInventory
Follow-up
As proof of concept, I only implement the
ArmorInventory
logics. There is many inventory which need to check their slot.