Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
fix issue #68
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinWD committed Jan 28, 2021
1 parent ce79aae commit b6d3347
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/java/cat/nyaa/heh/command/SellCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@
import cat.nyaa.nyaacore.cmdreceiver.Arguments;
import cat.nyaa.nyaacore.cmdreceiver.CommandReceiver;
import cat.nyaa.nyaacore.cmdreceiver.SubCommand;
import cat.nyaa.nyaacore.utils.InventoryUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.Plugin;
Expand Down Expand Up @@ -102,12 +98,15 @@ private boolean sellToRequisition(Player player, Arguments arguments) {
}
PlayerInventory inventory = player.getInventory();
ItemStack clone = itemInMainHand.clone();
itemInMainHand.setAmount(Math.max(itemInMainHand.getAmount() - amountToSell, 0));
inventory.setItemInMainHand(itemInMainHand);

try{
ItemStack clone1 = clone.clone();
clone1.setAmount(amountToSell);
requisition.onSell(player, clone1);
boolean succeeded = requisition.onSell(player, clone1);
if (succeeded){
itemInMainHand.setAmount(Math.max(itemInMainHand.getAmount() - amountToSell, 0));
inventory.setItemInMainHand(itemInMainHand);
}
return true;
}catch (Exception e){
Bukkit.getLogger().log(Level.SEVERE, "error selling item: ", e);
Expand Down

0 comments on commit b6d3347

Please sign in to comment.