Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variable iterator and EffReplace with items #4627

Merged
merged 7 commits into from
Apr 17, 2022

Conversation

TPGamesNL
Copy link
Member

@TPGamesNL TPGamesNL commented Feb 25, 2022

Description

Fixes Variable#iterator for single variables. The method implementation assumed the variable would be a list variable, and therefore mostly copied code from Variable#variablesIterator. This fix adds an exception to return a single item iterator when the variable is not a list variable, containing the item.

This fix also exposed a bug in EffReplace caught by one of our tests: EffReplace called with inventories and items will not use the right item comparisons to detect which items to replace. In particular, it only matched items with the same item amount. I've fixed this by using ItemType#isSimilar, but the test also said the item amount had to remain the same after replacing, so the new EffReplace implementation also takes care of that.


Target Minecraft Versions: any
Requirements: none
Related Issues: #4154 (non-fixing), #4672 (fixing)

@TPGamesNL TPGamesNL added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Feb 25, 2022
@TPGamesNL TPGamesNL marked this pull request as draft February 25, 2022 13:05
@TPGamesNL TPGamesNL marked this pull request as ready for review February 25, 2022 13:36
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. We discussed how the comparison should be done on Discoed. Checking it again here, the logic looks good 🙂

@AyhamAl-Ali AyhamAl-Ali mentioned this pull request Mar 17, 2022
1 task
@TPGamesNL TPGamesNL marked this pull request as draft March 19, 2022 23:37
@TPGamesNL TPGamesNL marked this pull request as ready for review March 23, 2022 08:38
@TPGamesNL TPGamesNL merged commit 4852ef3 into SkriptLang:master Apr 17, 2022
@TPGamesNL TPGamesNL deleted the fix/variable-iterator branch April 17, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants