mfnalex / ChestSort

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

ItemJoin #100

Closed MrFreasy closed 3 years ago

MrFreasy commented 3 years ago

Used ChestSort version 8.17.7

Used Spigot version This server is running Yatopia version git-Yatopia-"94afff9" (MC: 1.16.3) (Implementing API version 1.16.3-R0.1-SNAPSHOT)

Other plugin used ItemsAdder

Describe the bug Items that have been added to item adder that cannot be moved are moved when sorting inventory

Expected behavior Items that have been added to itemadder should not be moved when reordering inventory.

mfnalex commented 3 years ago

ItemAdder is a premium plugin, I don't have access to it. You can ask the ItemAdder author if they can implement the ChestSortAPI to prevent those items from being moved.

MrFreasy commented 3 years ago

Sorry I got confused. The plugin in question is ItemJoin and not ItemsAdder

mfnalex commented 3 years ago

Can you give me an example on what exactly I have to do to get one of those "not moveable" items using ItemJoiner?

MrFreasy commented 3 years ago

With item join you can create an item that is given when you join into the server and has several properties, including that of not being able to move it in the inventory.

mfnalex commented 3 years ago

Can you give me an example on what exactly I have to do to get one of those "not moveable" items using ItemJoiner?

MrFreasy commented 3 years ago

Use this items.yml: https://pastebin.com/mkPf7eBg

TheRobLP commented 3 years ago

Hello guys. I am Administrator at CraftationGaming (the Discord server for ItemJoin). A few users have asked us about CHestSort, so I would like to quote a solution from the developer, RockinChaos:

So this is the exact same issue reported by a previous user a week or so ago. I can't find the logs so I'll try to summarize as best as I can.

While he is not wrong with the ChestSortEvent, the issue is that the event he provides doesn't have the ability to prevent an ItemStack from being moved. The only option that I can do via ItemJoin is prevent the movement of ALL items which is not the desired outcome, rather it should sort the items that are allowed. This is further confirmed by his API page where it states you can prevent a specific Inventory from being cleared not a specific item. https://github.com/JEFF-Media-GbR/Spigot-ChestSort/blob/master/HOW_TO_USE_API.md#custom-chestsort-event

What I would suggest is opening a feature request with ChestSort to add the following methods to the ChestSortEvent; event.ignoreItem(ItemStack) and event.ignoreItem(List) so that way I can define a single item or a list of items that should be ignored by the event.

I personally have no idea about Java programming, but I hope it makes more sense to you.

mfnalex commented 3 years ago

Hello guys. I am Administrator at CraftationGaming (the Discord server for ItemJoin). A few users have asked us about CHestSort, so I would like to quote a solution from the developer, RockinChaos:

So this is the exact same issue reported by a previous user a week or so ago. I can't find the logs so I'll try to summarize as best as I can. While he is not wrong with the ChestSortEvent, the issue is that the event he provides doesn't have the ability to prevent an ItemStack from being moved. The only option that I can do via ItemJoin is prevent the movement of ALL items which is not the desired outcome, rather it should sort the items that are allowed. This is further confirmed by his API page where it states you can prevent a specific Inventory from being cleared not a specific item. https://github.com/JEFF-Media-GbR/Spigot-ChestSort/blob/master/HOW_TO_USE_API.md#custom-chestsort-event What I would suggest is opening a feature request with ChestSort to add the following methods to the ChestSortEvent; event.ignoreItem(ItemStack) and event.ignoreItem(List) so that way I can define a single item or a list of items that should be ignored by the event.

I personally have no idea about Java programming, but I hope it makes more sense to you.

The API will be improved in the next week or two, allowing to excempt certain ItemStacks from being moved :)

mfnalex commented 3 years ago

The 1.1.0 version of the API now includes the following new methods:

    public void setUnmovable(int slot)

    public void setUnmovable(ItemStack itemStack)

    public void removeUnmovable(int slot)

    public void removeUnmovable(ItemStack itemStack)

    public boolean isUnmovable(int slot)

    public boolean isUnmovable(ItemStack itemStack)

ChestSort 8.19.0-SNAPSHOT already implements the new API in case you want to test it: http://repo.jeff-media.de/maven2/de/jeff_media/ChestSort/8.19.0-SNAPSHOT/ChestSort-8.19.0-20210102.203351-1.jar (Please note that this version is totally untested because I am moving my test server to a new VPS right now, I don't have access to it until in a few hours)

Please let me know if everything works as expected. Both the API and the 8.19.0-SNAPSHOT release are available in my maven repo (https://repo.jeff-media.de)

The API docs now also include those new methods. However, the javadocs are still to be updated. Javadocs for the updated ChestSortEvent class can be found here: http://repo.jeff-media.de/javadocs/ChestSortAPI/de/jeff_media/ChestSortAPI/ChestSortEvent.html

RockinChaos commented 3 years ago

New features work perfectly, thanks!

There is one issue though, when executing the /chestsort:inventorysort command and listening for the event, for some reason event.getPlayer() always returns null so I am currently getting the player from the event inventory using (Player) event.getInventory().getViewers().get(0) to resolve this.

mfnalex commented 3 years ago

Thanks for the reply.

Please try this version: http://repo.jeff-media.de/maven2/de/jeff_media/ChestSort/8.19.0-SNAPSHOT/ChestSort-8.19.0-20210103.182414-3.jar

It should properly include the Players (as HumanEntity) now. ChestSortAPI version implemented by that one is 2.0.0

RockinChaos commented 3 years ago

Works perfectly, thanks!

mfnalex commented 3 years ago

Perfect :) This has now been released as ChestSort 9.0.0