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

Add ItemStack array serialization methods #10387

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add ItemStack array serialization methods #10387

wants to merge 1 commit into from

Conversation

kennytv
Copy link
Member

@kennytv kennytv commented Apr 4, 2024

Serializing multiple items to bytes isn't trivial, so often beginners fall into the trap of using output IO streams and Bukkit serialization instead, so these provide helpful extra methods to deal with item arrays.

Also kept the serialization methods exposed in API as a sort of textbook example/nudge in the right direction of what should be used instead of object streams

@kennytv kennytv requested a review from a team as a code owner April 4, 2024 15:01
@kashike kashike added the type: feature Request for a new Feature. label Apr 29, 2024
Serializing multiple items to bytes isn't trivial, so often beginners fall into the trap of using output IO streams and Bukkit serialization instead, so these provide helpful extra methods to deal with item arrays.
Copy link
Contributor

@lynxplay lynxplay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brought up in a merge party in VC, but iirc the general notion was to move away from null item stacks in the API as they require a double check of item != null && !item.isEmpty().

Would it make more sense for this method to yield back ItemStack#empty() instead of null if 0 is read?

@kennytv
Copy link
Member Author

kennytv commented May 28, 2024

While the api output still provides null items, I would not enforce air, otherwise you either produce inconsistent results or break easy use from api input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Request for a new Feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants