Starts on the Scrapper implementation

This commit is contained in:
2023-11-12 19:02:11 +01:00
parent 72ea5600fe
commit 3e3a35d02a
17 changed files with 697 additions and 518 deletions

View File

@ -1,7 +1,7 @@
package net.knarcraft.blacksmith.manager;
import net.knarcraft.blacksmith.BlacksmithPlugin;
import net.knarcraft.blacksmith.config.GlobalSettings;
import net.knarcraft.blacksmith.config.blacksmith.GlobalBlacksmithSettings;
import net.knarcraft.blacksmith.util.ItemHelper;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Material;
@ -89,15 +89,15 @@ public class EconomyManager {
* @return <p>The cost of the repair</p>
*/
private static double getCost(ItemStack item) {
GlobalSettings globalSettings = BlacksmithPlugin.getInstance().getSettings();
GlobalBlacksmithSettings globalBlacksmithSettings = BlacksmithPlugin.getInstance().getSettings();
Material material = item.getType();
//Calculate the base price
double price = globalSettings.getBasePrice(material);
double price = globalBlacksmithSettings.getBasePrice(material);
// Adjust price based on durability
double pricePerDurabilityPoint = globalSettings.getPricePerDurabilityPoint(material);
if (globalSettings.getUseNaturalCost()) {
double pricePerDurabilityPoint = globalBlacksmithSettings.getPricePerDurabilityPoint(material);
if (globalBlacksmithSettings.getUseNaturalCost()) {
//Cost increases with damage
price += ((double) ItemHelper.getDamage(item)) * pricePerDurabilityPoint;
} else {
@ -110,7 +110,7 @@ public class EconomyManager {
//Override the cost for anvils
if (ItemHelper.isAnvil(material, true)) {
price = globalSettings.getAnvilCost(material);
price = globalBlacksmithSettings.getAnvilCost(material);
}
return price;
}
@ -122,7 +122,7 @@ public class EconomyManager {
* @return <p>The resulting enchantment cost</p>
*/
private static double getEnchantmentCost(ItemStack item) {
GlobalSettings settings = BlacksmithPlugin.getInstance().getSettings();
GlobalBlacksmithSettings settings = BlacksmithPlugin.getInstance().getSettings();
double price = 0;
for (Enchantment enchantment : item.getEnchantments().keySet()) {
price += settings.getEnchantmentCost(enchantment) * item.getEnchantmentLevel(enchantment);