feat: add shulker box support for item storage and buying#18
Draft
ZvandeKamp wants to merge 19 commits into
Draft
feat: add shulker box support for item storage and buying#18ZvandeKamp wants to merge 19 commits into
ZvandeKamp wants to merge 19 commits into
Conversation
…ontents returns a non-nullable Array<ItemStack?> in this API version.
Author
|
@TheBjoRedCraft ich möchte einmal Anmerken dass das Plugin zwar Baut ich aber keine Testumgebung hatte um alle neuen Features ordentlich durch zu testen. |
There was a problem hiding this comment.
Pull request overview
This PR adds Shulker Box-based bulk operations to the shop UI, enabling high-volume workflows by letting players deposit, withdraw, and buy items using Shulker Boxes as containers.
Changes:
- Add Shulker Box withdrawal support in the storage removal view (fill an empty Shulker Box from shop stock).
- Add Shulker Box insertion support in the storage insert view (deposit a Shulker Box’s contents into shop stock).
- Add Shulker Box purchase option in the buy view (buy up to 27 stacks into an empty Shulker Box).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/menu/edit/storage/ItemStorageRemoveView.kt | Adds UI slot + logic to withdraw shop stock into an empty Shulker Box. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/menu/edit/storage/ItemStorageInsertView.kt | Adds logic to bulk-insert items from a Shulker Box into shop storage. |
| surf-shop-paper/src/main/kotlin/dev/slne/surf/shop/paper/menu/buy/BuyShopItemView.kt | Adds a Shulker Box buy interaction that packages purchased items into a Shulker Box. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+141
to
+149
| withContext(plugin.entityDispatcher(context.player)) { | ||
| val toRemove = currentShop.item.clone().apply { | ||
| amount = boughtAmount | ||
| } | ||
| val notRemoved = | ||
| context.player.inventory.removeItem(toRemove) | ||
| val removedAmount = | ||
| boughtAmount - notRemoved.values.sumOf { it.amount } | ||
|
|
| line { | ||
| appendSpace() | ||
| appendBlob() | ||
| shopColored("wird die Box teilweise befullt.") |
| context: me.devnatan.inventoryframework.context.SlotClickContext, | ||
| shulkerItem: ItemStack | ||
| ) = withContext(plugin.entityDispatcher(context.player)) { | ||
| val emptyShulker = ItemStack(shulkerItem.type) |
Comment on lines
+93
to
+111
| for (slotItem in contents) { | ||
| if (slotItem == null || slotItem.type.isAir) { | ||
| click.player.sendActionBar(buildText { | ||
| appendErrorPrefix() | ||
| error("Die Shulker-Box muss voll sein.") | ||
| }) | ||
| click.player.playNoSound() | ||
| return | ||
| } | ||
| if (!slotItem.isSimilar(shop.item)) { | ||
| click.player.sendActionBar(buildText { | ||
| appendErrorPrefix() | ||
| error("Die Shulker-Box enthält unterschiedliche Item-Typen.") | ||
| }) | ||
| click.player.playNoSound() | ||
| return | ||
| } | ||
| totalItems += slotItem.amount | ||
| } |
| click.isCancelled = false | ||
| click.clickOrigin.currentItem = ItemStack.empty() | ||
|
|
||
| val emptyShulker = ItemStack(item.type) |
| player.sendText { | ||
| appendErrorPrefix() | ||
| error("Der Shop existiert nicht mehr.") | ||
| } |
Comment on lines
+391
to
+408
| withContext(plugin.entityDispatcher(player)) { | ||
| val emptyShulker = ItemStack(shulkerType) | ||
| val leftover = player.inventory.addItem(emptyShulker) | ||
| if (leftover.isNotEmpty()) { | ||
| leftover.values.forEach { rest -> | ||
| val dropped = player.world.dropItem( | ||
| player.location, rest | ||
| ) | ||
| dropped.owner = player.uniqueId | ||
| } | ||
| } | ||
| } | ||
| return@launch | ||
| } | ||
|
|
||
| val filledShulker = createFilledShulker( | ||
| shulkerType, updatedShop.item, toRemove | ||
| ) |
| import org.bukkit.inventory.ItemStack | ||
| import org.bukkit.inventory.meta.BlockStateMeta | ||
| import kotlin.math.max | ||
| import kotlin.math.min |
| )) { | ||
| is Deal.DealResult.Success -> { | ||
| val boughtAmount = result.deal.amount | ||
|
|
… fork/ZvandeKamp/feat/AddShulkerSupport
…y) removed dupes on failure
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.
Summary
This PR introduces the ability for players to use Shulker Boxes to bulk-insert, bulk-withdraw, and bulk-buy items within the shop system. This significantly improves the user experience for high-volume traders by reducing the need for manual stack handling.
Key Changes
BuyShopItemViewthat allows players to buy items directly into an empty Shulker Box (up to 27 stacks).ItemStorageInsertViewto allow players to deposit the entire contents of a Shulker Box into their shop storage in one click.ItemStorageRemoveViewto allow shop owners to withdraw items directly into an empty Shulker Box.