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

Don't sort upper player inventories #23

Open
Jikoo opened this issue Jul 12, 2024 · 1 comment
Open

Don't sort upper player inventories #23

Jikoo opened this issue Jul 12, 2024 · 1 comment

Comments

@Jikoo
Copy link

Jikoo commented Jul 12, 2024

Hey, I maintain OpenInv, which is a plugin for opening other people's inventories. I've had a relatively high number of reports of items being deleted due to sorting plugins. I don't think it's clicksort, but you are one of the most popular sorting plugins. My main worry is a sorting plugin trying to put items into nonexistent slots - the player inventory isn't an even multiple of 9, so there's some filler. Previously this was at the end of the inventory, but in newer versions it will be mixed in with some other special slots for legibility. All fake slots drop items they receive at the inventory owner, but it would be better for that to just not happen in the first place - players aren't allowed to insert into these slots internally.

It would be really great if you could exclude upper player inventories from sorting - either checking for InventoryType.PLAYER or instanceof PlayerInventory will work with OpenInv's inventories.

Alternately, if you do want to explicitly include sorting others' inventories as a feature, on 1.21 (when I finish with 5.0.0, at least) InventoryView#getSlotType(int) will also accurately represent what type of slot is at what index. Using that might be preferable to the magic numbers you currently use - OpenInv puts the hotbar in slots 27-35 so that the layout matches the standard player inventory for legibility. I'm not sure how that compares to other inventory editing plugins - I deliberately avoid looking at competitors so I don't accidentally skid ideas or design.
/e: Alternately, Inventory#getStorageContents/setStorageContents accept normally-organized bulk contents where the hotbar is 0-8.

@NewbieOrange
Copy link
Owner

NewbieOrange commented Jul 12, 2024

ClickSort now does trigger InventorySortEvent and plugins can disable sorting on the fake items. (or all items if they cancel the event)

On the next version we should be dropping support for pre-1.21 and will use the new APIs to check sortable slots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants