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 dd145a7 commit 3b4d1c8
Showing 1 changed file with 41 additions and 14 deletions.
55 changes: 41 additions & 14 deletions src/main/java/world/bentobox/biomes/tasks/BiomeUpdateHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -564,18 +564,15 @@ private void withdrawMoney(CompletableFuture<Boolean> changeBiomeStage, double m
this.callerUser.getTranslation(Constants.ERRORS + "could-not-remove-money"));
this.addon.logError("Economy Addon not provided.");
changeBiomeStage.complete(false);
return;
}

if (this.addon.getSettings().isUseBankAccount() && this.addon.isBankProvided())
{
BankManager bankManager = this.addon.getBankAddon().getBankManager();
bankManager.withdraw(this.callerUser, this.island, new Money(money), TxType.WITHDRAW).
thenAccept(response -> {
if (response == BankResponse.SUCCESS)
{
changeBiomeStage.complete(true);
}
else
if (response != BankResponse.SUCCESS)
{
Utils.sendMessage(this.callerUser,
this.callerUser.getTranslation(Constants.ERRORS + "could-not-remove-money"));
Expand All @@ -587,11 +584,7 @@ private void withdrawMoney(CompletableFuture<Boolean> changeBiomeStage, double m
{
EconomyResponse withdraw = this.addon.getVaultHook().withdraw(this.callerUser, money);

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

Expand All @@ -618,7 +611,7 @@ private void withdrawItems(CompletableFuture<Boolean> changeBiomeStage,
if (this.callerUser.getPlayer().getGameMode() == GameMode.CREATIVE)
{
// No point to check items from creative inventory.
changeBiomeStage.complete(true);
return;
}

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

changeBiomeStage.complete(false);
return;
}
}

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


Expand All @@ -695,6 +686,12 @@ private void withdrawPerBlock(CompletableFuture<Boolean> changeBiomeStage)
this.withdrawMoney(changeBiomeStage, this.biome.getCost() * blockCount);
}

if (changeBiomeStage.isDone())
{
// Return if already processed.
return;
}

if (!this.biome.getItemCost().isEmpty())
{
List<ItemStack> itemCost = Utils.groupEqualItems(this.biome.getItemCost(), Collections.emptySet());
Expand All @@ -703,6 +700,12 @@ private void withdrawPerBlock(CompletableFuture<Boolean> changeBiomeStage)
this.withdrawItems(changeBiomeStage, itemCost, Collections.emptySet());
}

if (changeBiomeStage.isDone())
{
// Return if already processed.
return;
}

changeBiomeStage.complete(true);
}

Expand All @@ -722,6 +725,12 @@ private void withdrawPerUsage(CompletableFuture<Boolean> changeBiomeStage)
this.biome.getCost() + increment * this.biome.getCost());
}

if (changeBiomeStage.isDone())
{
// Return if already processed.
return;
}

if (!this.biome.getItemCost().isEmpty())
{
List<ItemStack> itemCost = Utils.groupEqualItems(this.biome.getItemCost(), Collections.emptySet());
Expand All @@ -733,6 +742,12 @@ private void withdrawPerUsage(CompletableFuture<Boolean> changeBiomeStage)
Collections.emptySet());
}

if (changeBiomeStage.isDone())
{
// Return if already processed.
return;
}

changeBiomeStage.complete(true);
}

Expand All @@ -749,13 +764,25 @@ private void withdrawStatic(CompletableFuture<Boolean> changeBiomeStage)
this.withdrawMoney(changeBiomeStage, this.biome.getCost());
}

if (changeBiomeStage.isDone())
{
// Return if already processed.
return;
}

if (!this.biome.getItemCost().isEmpty())
{
this.withdrawItems(changeBiomeStage,
Utils.groupEqualItems(this.biome.getItemCost(), Collections.emptySet()),
Collections.emptySet());
}

if (changeBiomeStage.isDone())
{
// Return if already processed.
return;
}

changeBiomeStage.complete(true);
}

Expand Down

0 comments on commit 3b4d1c8

Please sign in to comment.