mfnalex / ChestSort

Best sorting plugin for Minecraft / Spigot 1.14+
https://www.chestsort.de
GNU General Public License v3.0
90 stars 35 forks source link

Added strict sorting for sortInventory(inv, startSlot, endSlot) #6

Closed ghost closed 5 years ago

ghost commented 5 years ago

I noticed what you meant about items not stacking when using setItem. So my only solution would to be stacking the items before sorting.

At first I was going to create my own method of stacking items but figured I wouldn't reinvent the wheel because Inventory.addItem already does exactly that.

So I ended up using Bukkit.createInventory to create a temp inventory with a null holder and a size of 54 (which should fit most needs) and returning the contents of that inventory to be using in the sorting.

I still end up using setItem because we want it to stay within the startSlot and endSlot range.

I tested this multiple times and didn't have problems.

A fix for https://github.com/JEFF-Media-GbR/Spigot-ChestSort/issues/5

mfnalex commented 5 years ago

Thanks, sounds very promising! I will test this tomorrow if I have time. Thank you very much, this will be very helpful for other plugin authors :)

mfnalex commented 5 years ago

I took a quick look into your changes and it seems like a brilliant idea. I will post a resource update in a few days, thanks again

mfnalex commented 5 years ago

I am not sure if we should create a new method for this or just update the existing method. Suggestions?

ghost commented 5 years ago

That's totally up to you. If you do use the existing method you would need to split everything after this line into their own methods because it's different.

mfnalex commented 5 years ago

Thanks for the great help, it will make the API much more useful. I will be happy to mention your contribution in the next changelog/update notes at SpigotMC. Please tell your account URL if you would like me to link your profile in the next update notes.

ghost commented 5 years ago

I don't use my Spigot account often but you can mention my GitHub link if you'd like or a link to the issue.

mfnalex commented 5 years ago

Alright, I'll post the update tomorrow or in a few days.

mfnalex commented 5 years ago

Thanks, it's now integrated in the existing function