Implements netherite salvaging #24
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
This commit is contained in:
@ -3,11 +3,8 @@ package net.knarcraft.blacksmith.util;
|
||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||
import net.knarcraft.blacksmith.config.SmithPreset;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.CraftingRecipe;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -168,40 +165,6 @@ public final class ItemHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given item can be salvaged, assuming no restrictions apply
|
||||
*
|
||||
* @param server <p>The server to get recipes from</p>
|
||||
* @param item <p>The item to check</p>
|
||||
* @return <p>True if the item can be salvaged</p>
|
||||
*/
|
||||
public static boolean isSalvageable(@NotNull Server server, @NotNull ItemStack item) {
|
||||
for (Recipe recipe : server.getRecipesFor(new ItemStack(item.getType(), item.getAmount()))) {
|
||||
// Only crafting recipes are allowed.
|
||||
if ((recipe instanceof CraftingRecipe) && item.getAmount() >= recipe.getResult().getAmount()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of an item that's required to salvage that item
|
||||
*
|
||||
* @param server <p>The server to get recipes from</p>
|
||||
* @param item <p>The item to check</p>
|
||||
* @return <p>The number of items required for salvage, or -1 if the recipe was not found</p>
|
||||
*/
|
||||
public static int getRequiredAmountForSalvage(@NotNull Server server, @NotNull ItemStack item) {
|
||||
for (Recipe recipe : server.getRecipesFor(new ItemStack(item.getType(), item.getAmount()))) {
|
||||
// Only crafting recipes are allowed.
|
||||
if (recipe instanceof CraftingRecipe) {
|
||||
return recipe.getResult().getAmount();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all materials matching the given material wildcard
|
||||
*
|
||||
|
Reference in New Issue
Block a user