NewbieOrange / clicksort

Minecraft Bukkit plugin to sort inventories with a simple mouse click
https://dev.bukkit.org/projects/clicksort
Other
13 stars 5 forks source link

Don't sort upper player inventories #23

Open Jikoo opened 2 months ago

Jikoo commented 2 months ago

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 commented 2 months ago

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.