Skip to content

Commit

Permalink
Fixes a bug, when players in creative menu still receive a message ab…
Browse files Browse the repository at this point in the history
…out missing items.
  • Loading branch information
BONNe committed Jan 26, 2022
1 parent 3b4d1c8 commit e116096
Showing 1 changed file with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ public void purchaseBiome(@NotNull User user,
this.withdrawMoney(purchaseBiome, user, island, biomesObject.getUnlockCost());
}

if (!biomesObject.getUnlockItems().isEmpty())
if (!purchaseBiome.isDone() && !biomesObject.getUnlockItems().isEmpty())
{
this.withdrawItems(purchaseBiome,
user,
Expand All @@ -1002,7 +1002,10 @@ public void purchaseBiome(@NotNull User user,
}
}

purchaseBiome.complete(true);
if (!purchaseBiome.isDone())
{
purchaseBiome.complete(true);
}
}


Expand All @@ -1021,11 +1024,7 @@ private void withdrawMoney(CompletableFuture<Boolean> changeBiomeStage, User use
BankManager bankManager = this.addon.getBankAddon().getBankManager();
bankManager.withdraw(user, island, new Money(money), TxType.WITHDRAW).
thenAccept(response -> {
if (response == BankResponse.SUCCESS)
{
changeBiomeStage.complete(true);
}
else
if (response != BankResponse.SUCCESS)
{
Utils.sendMessage(user,
user.getTranslation(Constants.ERRORS + "could-not-remove-money"));
Expand All @@ -1037,11 +1036,7 @@ private void withdrawMoney(CompletableFuture<Boolean> changeBiomeStage, User use
{
EconomyResponse withdraw = this.addon.getVaultHook().withdraw(user, money);

if (withdraw.transactionSuccess())
{
changeBiomeStage.complete(true);
}
else
if (!withdraw.transactionSuccess())
{
// Something went wrong on withdraw.

Expand Down Expand Up @@ -1070,7 +1065,7 @@ private void withdrawItems(CompletableFuture<Boolean> changeBiomeStage,
if (user.getPlayer().getGameMode() == GameMode.CREATIVE)
{
// No point to check items from creative inventory.
changeBiomeStage.complete(true);
return;
}

for (ItemStack required : requiredItemList)
Expand Down Expand Up @@ -1125,11 +1120,9 @@ private void withdrawItems(CompletableFuture<Boolean> changeBiomeStage,
" from player's inventory!");

changeBiomeStage.complete(false);
return;
}
}

// Complete at the end.
changeBiomeStage.complete(true);
}


Expand Down

0 comments on commit e116096

Please sign in to comment.