Improves messages when trying to salvage an item
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
Implements unimplemented too damaged for salvage message Adds two new messages explaining whether an item will produce full or partial salvage
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package net.knarcraft.blacksmith.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -24,6 +25,23 @@ public final class SalvageHelper {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
/**
|
||||
* Gets whether the given item has a valid crafting recipe
|
||||
*
|
||||
* @param item <p>The item to check</p>
|
||||
* @return <p>True if the item has a valid crafting recipe</p>
|
||||
*/
|
||||
public static boolean hasRecipe(@NotNull ItemStack item) {
|
||||
List<Recipe> recipes = Bukkit.getRecipesFor(new ItemStack(item.getType(), item.getAmount()));
|
||||
for (Recipe recipe : recipes) {
|
||||
if (recipe instanceof ShapedRecipe || recipe instanceof ShapelessRecipe) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sum of all enchantment levels for the given item
|
||||
*
|
||||
|
Reference in New Issue
Block a user