feat: Add valid-slots to MenuSpell - #1098
Conversation
…one of those slots is empty.
There was a problem hiding this comment.
🟡 Changes recommended
Using valid-slots without slots/slot currently logs a spurious out-of-bounds error due to adding the legacy default -1 slot value.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends MenuSpell inventory placement logic by introducing a new valid-slots configuration option, enabling “first available slot” placement to support dynamically filled menu sections (e.g., shop layouts).
Changes:
- Added parsing/validation for
options.<name>.valid-slots. - Split option placement into fixed
slots(place in all) vsvalidSlots(place in first empty). - Stored
validSlotsonMenuOptionand applied it during inventory population.
File summaries
| File | Description |
|---|---|
| core/src/main/java/com/nisovin/magicspells/spells/MenuSpell.java | Adds valid-slots parsing and uses it to place option items into the first empty configured slot. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| List<Integer> configuredSlots = getConfigIntList(path + "slots", new ArrayList<>()); | ||
| if (configuredSlots.isEmpty()) configuredSlots.add(getConfigInt(path + "slot", -1)); | ||
| List<Integer> configuredValidSlots = getConfigIntList(path + "valid-slots", new ArrayList<>()); |
| List<Integer> slots = new ArrayList<>(); | ||
| for (int slot : configuredSlots) { | ||
| if (slot < 0 || slot > 53) { | ||
| MagicSpells.error("MenuSpell '" + internalName + "' a slot defined which is out of bounds for '" + optionName + "': " + slot); |
|
This is the same as the |
Sorts items into one of the defined valid slots as long as the slot is empty allowing dynamic "filled" sections which is good for shops or to eliminate wasted space without complex modifiers.