feat: Add valid-slots to MenuSpell - #1098
Open
DragonsAscent wants to merge 1 commit into
Open
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.
Comment on lines
+74
to
+76
| 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.