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 /unlimited with changing stack sizes #4877

Merged

Conversation

Deltric
Copy link
Contributor

@Deltric Deltric commented Mar 30, 2022

Information

This PR fixes #4819 .

Details

Proposed fix:

Clones the ItemStack with a new quantity of 1 to readd to their inventory.
This causes no net gain in items.

Before doing so it checks if the stack is not air which is caused by the player trying to place a block with a stack size of one.
This is done to avoid an exception from setting stack size on empty and might avoid unnecessary updates.
Additionally feature behavior is unaltered as previously you still needed more than 1 block in an unlimited stack.

Environments tested:

OS: Windows 11

Java version: 17.0.1

  • Most recent Paper version (1.XX.Y, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

Before (Tested with EssentialsX 2.19.4 and 2.20.0-dev+4-4bd1b3c)
https://user-images.githubusercontent.com/25653276/160824043-5b329258-7938-4c22-8fdd-0de0049a1edf.mp4

After (Tested by using the compiled version with this commit)
https://user-images.githubusercontent.com/25653276/160824285-9be61d3e-0238-4647-b8e2-440fc32b569b.mp4

Clones the stack with a single amount instead of readding what they have left to their inventory. When the stack size is above 2 it caused a net gain in stack size which could easily fill your inventory.
@pop4959 pop4959 added type: bugfix PRs that fix bugs in EssentialsX. module: main Issues or PRs for the main Essentials module labels May 21, 2022
@JRoy JRoy self-requested a review July 5, 2022 16:49
@JRoy JRoy self-requested a review July 5, 2022 16:54
JRoy
JRoy previously approved these changes Jul 5, 2022
@JRoy JRoy changed the title Fixes stack multiplication with unlimited placement Fix /unlimited with changing stack sizes Jul 5, 2022
@JRoy JRoy enabled auto-merge (squash) July 5, 2022 16:59
@JRoy JRoy merged commit 2bba577 into EssentialsX:2.x Jul 5, 2022
@JRoy
Copy link
Member

JRoy commented Jul 5, 2022

Thanks for the contribution!

JRoy added a commit that referenced this pull request Jul 7, 2022
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
@mdcfe mdcfe added this to the 2.19.5 milestone Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: main Issues or PRs for the main Essentials module type: bugfix PRs that fix bugs in EssentialsX.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/unlimited broken
4 participants