InventivetalentDev / AnimatedFrames

Play GIFs in Minecraft
MIT License
188 stars 34 forks source link

Sort frames alphabetically for /aflist #204

Closed livejar closed 3 years ago

livejar commented 3 years ago

Why

It would be nice to have the /aflist output sorted alphabetically.

How

In FrameManager, the AnimatedFrames in frameMap are already sorted because it's a TreeMap ; but it seems that the ordering is lost when doing new HashSet<>(frameMap.values()).

By simply keeping the Collection frameMap.values() (of the TreeMap implementation) it seems to keep the order. I modified the return type of the existing method, which is used at other places but I don't know if they do need a HashSet or are fine with this Collection. Maybe it's better to create a new getSortedFrames() method ?

livejar commented 3 years ago

Btw it partially covers what was suggested in https://github.com/InventivetalentDev/AnimatedFrames/issues/190

InventivetalentDev commented 3 years ago

Yeah please keep the existing method as is and add a new one. Also wrap it in a new array list similar to the existing method - don't want stuff modifying the list directly.