Adds negation for material names and presets #13

This commit is contained in:
2023-01-09 05:03:28 +01:00
parent 30b8507b9f
commit ea54492ccf
5 changed files with 120 additions and 42 deletions

View File

@ -1,8 +1,13 @@
package net.knarcraft.blacksmith.util;
import org.bukkit.Material;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import java.util.ArrayList;
import java.util.List;
public final class ItemHelper {
private ItemHelper() {
@ -40,4 +45,20 @@ public final class ItemHelper {
}
}
/**
* Gets a complete list of all reforge-able materials
*
* @return <p>A complete list of reforge-able materials</p>
*/
public static List<Material> getAllReforgeAbleMaterials() {
List<Material> reforgeAbleMaterials = new ArrayList<>();
for (Material material : Material.values()) {
ItemStack item = new ItemStack(material);
if (item.getItemMeta() instanceof Damageable && EnchantmentTarget.BREAKABLE.includes(item)) {
reforgeAbleMaterials.add(material);
}
}
return reforgeAbleMaterials;
}
}