Skip to content

Commit

Permalink
Don't take the item when the transaction failed (#14)
Browse files Browse the repository at this point in the history
* Don't take the item when the transaction failed

* Fixed it in the browser

* Now my IDE is completely freaking out

* Why did it push the non working code ARRGH
  • Loading branch information
Luca0208 authored and hsyyid committed Sep 18, 2016
1 parent 83d468f commit 7d21641
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,7 @@ else if (shopModifier.isPresent())
{
if (!player.get(Keys.IS_SNEAKING).orElse(false))
{
if (player.getItemInHand().isPresent() && player.getItemInHand().get().getItem() == shop.getItem().getType() && player.getItemInHand().get().getQuantity() == shop.getItem().getCount())
{
player.setItemInHand(null);
}
else if (player.getItemInHand().isPresent() && player.getItemInHand().get().getItem() == shop.getItem().getType() && player.getItemInHand().get().getQuantity() > shop.getItem().getCount())
{
ItemStack stack = player.getItemInHand().get();
int quantityInHand = stack.getQuantity() - shop.getItem().getCount();
stack.setQuantity(quantityInHand);
player.setItemInHand(stack);
}
else
if (!(player.getItemInHand().isPresent() && player.getItemInHand().get().getItem() == shop.getItem().getType() && player.getItemInHand().get().getQuantity() >= shop.getItem().getCount()))
{
player.sendMessage(Text.of(TextColors.DARK_RED, "[AdminShop]: ", TextColors.DARK_RED, "Error! ", TextColors.RED, "You're not holding this item or the right quantity of this item!"));
return;
Expand All @@ -157,6 +146,17 @@ else if (player.getItemInHand().isPresent() && player.getItemInHand().get().getI
if (result == ResultType.SUCCESS)
{
player.sendMessage(Text.builder().append(Text.of(TextColors.DARK_RED, "[AdminShop]: ", TextColors.GOLD, "You have just sold " + shop.getItem().getCount() + " " + shop.getItem().getType().getTranslation().get() + " for " + price + " ")).append(AdminShop.economyService.getDefaultCurrency().getPluralDisplayName()).build());
if (player.getItemInHand().isPresent() && player.getItemInHand().get().getItem() == shop.getItem().getType() && player.getItemInHand().get().getQuantity() == shop.getItem().getCount())
{
player.setItemInHand(null);
}
else if (player.getItemInHand().isPresent() && player.getItemInHand().get().getItem() == shop.getItem().getType() && player.getItemInHand().get().getQuantity() > shop.getItem().getCount())
{
ItemStack stack = player.getItemInHand().get();
int quantityInHand = stack.getQuantity() - shop.getItem().getCount();
stack.setQuantity(quantityInHand);
player.setItemInHand(stack);
}
}
else if (result == ResultType.ACCOUNT_NO_SPACE)
{
Expand Down

0 comments on commit 7d21641

Please sign in to comment.