Skip to content

Commit

Permalink
Bug fix and bad debug removal
Browse files Browse the repository at this point in the history
- Removed temporary debug code that was missed
- Fix NPE error from clone in ShopItemStack
  • Loading branch information
KillerOfPie committed Nov 22, 2021
1 parent e0bfee8 commit 35eb533
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public void onBlockInteract(PlayerInteractEvent e) {
return;
case INCOMPLETE:
Message.SHOP_EMPTY.sendMessage(buyer);
buyer.sendMessage("incomplete?");
case OUT_OF_STOCK:
if (shop.getShopType() == ShopType.BITRADE && e.getAction() == Action.LEFT_CLICK_BLOCK) {
Message.SHOP_INSUFFICIENT_ITEMS.sendMessage(buyer, new Tuple<>("{ITEM}", costName), new Tuple<>("{AMOUNT}", String.valueOf(amountCost)));
Expand Down Expand Up @@ -248,7 +247,6 @@ private boolean tradeAllItems(Shop shop, int multiplier, PlayerInteractEvent eve

for (ItemStack item : productItems) {
playerInventory.addItem(item);
buyer.sendMessage("Item Traded: \n" + item.toString());
}

Bukkit.getPluginManager().callEvent(new PlayerSuccessfulTradeEvent(buyer, costItems, productItems, shop, event.getClickedBlock(), event.getBlockFace()));
Expand Down Expand Up @@ -295,7 +293,6 @@ private boolean tradeAllItems(Shop shop, int multiplier, PlayerInteractEvent eve
Message.SHOP_INSUFFICIENT_ITEMS.sendMessage(buyer,
new Tuple<>("{ITEM}", item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : item.getType().toString()),
new Tuple<>("{AMOUNT}", String.valueOf(item.getAmount() * multiplier)));
buyer.sendMessage("3");
return false;
}

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/shanerx/tradeshop/objects/ShopItemStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ private void buildMap() {
}

public ShopItemStack clone() {
return new ShopItemStack(itemStack.clone(), shopSettings);
try {
ShopItemStack clone = (ShopItemStack) super.clone();
if (itemStack != null)
clone.itemStack = this.itemStack.clone();

return clone;
} catch (CloneNotSupportedException var2) {
throw new Error(var2);
}
}

public boolean setShopSettings(ShopItemStackSettingKeys key, ObjectHolder<?> value) {
Expand Down

0 comments on commit 35eb533

Please sign in to comment.