Skip to content

Commit

Permalink
Fix bug shop tonneau (#21)
Browse files Browse the repository at this point in the history
* Fix bug shop tonneau

* Fix import

---------

Co-authored-by: Anthony DECOURCELLES <[email protected]>
  • Loading branch information
GroleDev and Anthony DECOURCELLES authored Jun 6, 2024
1 parent 127216b commit b2a9b35
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.List;
import java.util.stream.Stream;

import org.bukkit.block.Chest;
import org.bukkit.block.Container;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -47,7 +47,7 @@ private void onShopPurchase(ShopPurchaseEvent event) {
}

Player purchaser = event.getPurchaser().getBukkitPlayer().get();
Chest chest = (Chest) shop.getLocation().getBlock().getState();
Container container = (Container) shop.getLocation().getBlock().getState();
final double total = event.getTotal();

if ((int) total == 0) {
Expand All @@ -58,7 +58,7 @@ private void onShopPurchase(ShopPurchaseEvent event) {
List<ItemStack> stacks = getItemsForPrice((int) total);

// If out of space
if (isGoingToOverflow(chest.getInventory(), stacks)) {
if (isGoingToOverflow(container.getInventory(), stacks)) {
QuickShop.getInstance().text().of(purchaser, "purchase-out-of-space", qOwner.getUsername()).send();
event.setCancelled(true, "Shop is out of space");
return;
Expand All @@ -72,9 +72,9 @@ private void onShopPurchase(ShopPurchaseEvent event) {
return;
}

// Add the corresponding items to the chest
// Add the corresponding items to the container
for (ItemStack stack : stacks) {
chest.getInventory().addItem(stack);
container.getInventory().addItem(stack);
}

// ""Cancel"" the transaction to the owner's inventory by setting total to 0
Expand Down

0 comments on commit b2a9b35

Please sign in to comment.