feat: Add sorting options for menu items in MenuSpell - #1106
feat: Add sorting options for menu items in MenuSpell#1106DragonsAscent wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The changes are localized and consistent with existing behavior, with only a minor improvement suggested around surfacing invalid config values.
Pull request overview
Adds a new sort-mode option for MenuSpell menu entries to control how an item is placed into configured slots when some are already occupied, enabling “fill first available” or “fill last available” behavior.
Changes:
- Parse a new
sort-modeconfig option per menu option (none/first/last). - Update inventory placement logic to support FIRST/LAST behaviors in addition to the existing “fill all empty defined slots” behavior.
File summaries
| File | Description |
|---|---|
| core/src/main/java/com/nisovin/magicspells/spells/MenuSpell.java | Adds SortMode parsing/storage and updates slot-filling logic to support first/last placement modes. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| FIRST, | ||
| LAST; | ||
|
|
||
| private static SortMode fromConfigValue(String value) { |
There was a problem hiding this comment.
I'd probably get rid of this, and use a normal Util#enumValueSafe. Unfortunately, you still have to uppercase, but feel free to change that.
This is not just to reduce redundancy, and localise the "default/fallback" value, but because it simplifies it too. Ignore the AI suggestion because that's even more of a roundabout way. Even a simple try/catch to parse the enum would've been enough.
Keep the config default, pass it to enumValueSafe, check if null was returned, then report that it was invalid and have it fall back to none.
Add
sort-modeto Menu Spell options allowingfirstorlastwhich sorts the item in the first available slot that isnt occupied starting from the first slot or from the last slot.