Updates Spigot, and fixes depreciated code
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2024-05-04 02:46:46 +02:00
parent 44f8bb36b0
commit 7e5525bd00
13 changed files with 38 additions and 338 deletions

View File

@@ -6,7 +6,9 @@ import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSettings;
import net.knarcraft.blacksmith.manager.EconomyManager;
import net.knarcraft.blacksmith.util.InputParsingHelper;
import net.knarcraft.blacksmith.util.ItemHelper;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -31,7 +33,7 @@ public class ReforgeSession extends Session implements Runnable {
private final NPC npc;
private final ItemStack itemToReforge;
private final BlacksmithNPCSettings config;
private static final String[] enchantments = new String[Enchantment.values().length];
private static List<String> enchantments = null;
private static final Random random = new Random();
/**
@@ -51,10 +53,15 @@ public class ReforgeSession extends Session implements Runnable {
this.config = config;
//Populate enchantments the first time this is run
if (enchantments[0] == null) {
int i = 0;
for (Enchantment enchantment : Enchantment.values()) {
enchantments[i++] = enchantment.getKey().getKey();
if (enchantments == null) {
Registry<Enchantment> enchantmentRegistry = Bukkit.getRegistry(Enchantment.class);
if (enchantmentRegistry == null) {
throw new RuntimeException("Unable to get enchantment registry");
}
enchantments = new ArrayList<>();
for (Enchantment enchantment : enchantmentRegistry) {
enchantments.add(enchantment.getKey().getKey());
}
}
}