Adds optional ability to reforge anvils #15
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2023-01-09 23:47:17 +01:00
parent a856aa03e0
commit 753c7c6275
10 changed files with 95 additions and 14 deletions

View File

@ -6,6 +6,7 @@ import net.knarcraft.blacksmith.config.NPCSettings;
import net.knarcraft.blacksmith.manager.EconomyManager;
import net.knarcraft.blacksmith.util.InputParsingHelper;
import net.knarcraft.blacksmith.util.ItemHelper;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -129,6 +130,11 @@ public class ReforgeSession implements Runnable {
// Remove any damage done to the item
updateDamage(itemToReforge, 0);
//Replace damaged anvils with a normal anvil
if (ItemHelper.isAnvil(itemToReforge.getType(), true)) {
itemToReforge.setType(Material.ANVIL);
}
// Add random enchantments
int roll = random.nextInt(100);
if (!(roll < config.getExtraEnchantmentChance() &&