Skip to content

Conversation

@sovdeeth
Copy link
Member

@sovdeeth sovdeeth commented Jun 3, 2025

Problem

There was no easy way to detect the first empty slot in an inventory without looping over all the slots manually. Bukkit provides a easy firstEmpty() expression that avoids this nonsense, so there was room for improvement.

Solution

Adds an expression that uses firstEmpty() to get the first empty slot in an inventory.
[the] first empty slot in %inventories%, along with the typical property expression patterns.

Testing Completed

ExprFirstEmptySlot.sk tests basic inventory behavior, some manual testing was done to confirm it doesn't return armor slots for players.

Supporting Information


Completes: none
Related: none

@sovdeeth sovdeeth requested a review from a team as a code owner June 3, 2025 19:31
@sovdeeth sovdeeth added the feature Pull request adding a new feature. label Jun 3, 2025
@sovdeeth sovdeeth requested review from Burbulinis and removed request for a team June 3, 2025 19:31
@sovdeeth sovdeeth requested a review from TheMug06 June 3, 2025 19:31
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Jun 3, 2025
@sovdeeth sovdeeth moved this to Needs Reviews in 2.12 Releases Jun 3, 2025
@skriptlang-automation skriptlang-automation bot added feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. and removed needs reviews A PR that needs additional reviews labels Jun 3, 2025
@Burbulinis Burbulinis moved this from Needs Reviews to Awaiting Merge in 2.12 Releases Jun 3, 2025
@erenkarakal erenkarakal merged commit 133952d into SkriptLang:dev/feature Jun 5, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done in 2.12 Releases Jun 5, 2025
@jurajplayercze
Copy link

jurajplayercze commented Jul 9, 2025

Is the optional [s] there on purpose? I mean, it always returns the first empty slot anyway
patterns.add("[the] first empty slot[s] in %inventories%");

@erenkarakal
Copy link
Member

Is the optional [s] there on purpose? I mean, it always returns the first empty slot anyway patterns.add("[the] first empty slot[s] in %inventories%");

it's because the pattern supports multiple inventories

@jurajplayercze
Copy link

it's because the pattern supports multiple inventories

Yeah silly me didn't notice the plural

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Pull request adding a new feature. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.

Projects

Status: Done - Released

Development

Successfully merging this pull request may close these issues.

5 participants