From 0aef22ad1e9606edcd2670676bf767ae9f3f8524 Mon Sep 17 00:00:00 2001 From: Roch Blonndiaux Date: Sun, 26 Mar 2023 17:45:25 +0200 Subject: [PATCH] Issue fixed --- .../net/Indyuce/mmoitems/comp/eco/MoneyCondition.java | 4 ++++ .../net/Indyuce/mmoitems/gui/CraftingStationView.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/eco/MoneyCondition.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/eco/MoneyCondition.java index 587c17b2..6e238180 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/eco/MoneyCondition.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/comp/eco/MoneyCondition.java @@ -31,4 +31,8 @@ public class MoneyCondition extends Condition { public void whenCrafting(PlayerData data) { MMOItems.plugin.getVault().getEconomy().withdrawPlayer(data.getPlayer(), amount); } + + public double getAmount() { + return amount; + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationView.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationView.java index 8bb8c1a0..07fe19b1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationView.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/gui/CraftingStationView.java @@ -16,6 +16,7 @@ import net.Indyuce.mmoitems.api.crafting.recipe.Recipe; import net.Indyuce.mmoitems.api.event.PlayerUseCraftingStationEvent; import net.Indyuce.mmoitems.api.item.util.ConfigItems; import net.Indyuce.mmoitems.api.util.message.Message; +import net.Indyuce.mmoitems.comp.eco.MoneyCondition; import net.Indyuce.mmoitems.listener.CustomSoundListener; import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.Bukkit; @@ -221,6 +222,13 @@ public class CraftingStationView extends PluginInventory { // Give ingredients back for (Ingredient ingredient : recipeInfo.getRecipe().getIngredients()) new SmartGive(player).give(ingredient.generateItemStack(playerData.getRPG())); + + // Give money back + recipe.getConditions() + .stream() + .filter(condition -> condition instanceof MoneyCondition) + .map(condition -> (MoneyCondition) condition) + .forEach(condition -> MMOItems.plugin.getVault().getEconomy().depositPlayer(player, condition.getAmount())); } updateData();