Implements netherite salvaging #24
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2024-05-06 21:26:21 +02:00
parent e6047f3866
commit 1d7e8a0732
15 changed files with 430 additions and 209 deletions

View File

@ -7,7 +7,7 @@ import net.knarcraft.blacksmith.config.Settings;
import net.knarcraft.blacksmith.config.TraitSettings;
import net.knarcraft.blacksmith.formatting.TimeFormatter;
import net.knarcraft.blacksmith.manager.EconomyManager;
import net.knarcraft.blacksmith.util.ItemHelper;
import net.knarcraft.blacksmith.util.SalvageHelper;
import net.knarcraft.knarlib.formatting.StringFormatter;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -181,8 +181,8 @@ public abstract class CustomTrait<K extends Setting> extends Trait {
if (isBlacksmith) {
EconomyManager.withdrawBlacksmith(player);
} else {
EconomyManager.withdrawScrapper(player);
} else if (this.session instanceof SalvageSession salvageSession) {
EconomyManager.withdrawScrapper(player, salvageSession.salvageMethod);
}
session.scheduleAction();
@ -198,7 +198,7 @@ public abstract class CustomTrait<K extends Setting> extends Trait {
//Remove the item from the player's inventory
if (!isBlacksmith) {
// For scrappers, just reduce the amounts of items, unless the remaining stack is salvaged
int amount = ItemHelper.getRequiredAmountForSalvage(player.getServer(), heldItem);
int amount = SalvageHelper.getRequiredAmountForSalvage(player.getServer(), heldItem);
if (amount != heldItem.getAmount()) {
heldItem.setAmount(heldItem.getAmount() - amount);
playerInventory.setItemInMainHand(heldItem);