Skip to content

Commit ba1a765

Browse files
committed
Dont use Enchantment.values()
1 parent 591da50 commit ba1a765

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
import javax.annotation.Nonnull;
1313
import javax.annotation.ParametersAreNonnullByDefault;
1414

15+
import io.papermc.paper.registry.RegistryAccess;
16+
import io.papermc.paper.registry.RegistryKey;
1517
import org.bukkit.Location;
1618
import org.bukkit.Material;
19+
import org.bukkit.Registry;
1720
import org.bukkit.SoundCategory;
1821
import org.bukkit.enchantments.Enchantment;
1922
import org.bukkit.entity.Entity;
@@ -57,7 +60,7 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r
5760

5861
List<Enchantment> enchantments = new ArrayList<>();
5962

60-
for (Enchantment enchantment : Enchantment.values()) {
63+
for (Enchantment enchantment : RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT)) {
6164
if (enchantment.equals(Enchantment.BINDING_CURSE) || enchantment.equals(Enchantment.VANISHING_CURSE)) {
6265
continue;
6366
}

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import javax.annotation.Nullable;
1212
import javax.annotation.ParametersAreNonnullByDefault;
1313

14+
import io.papermc.paper.registry.RegistryAccess;
15+
import io.papermc.paper.registry.RegistryKey;
1416
import org.apache.commons.lang.Validate;
1517
import org.bukkit.Material;
1618
import org.bukkit.enchantments.Enchantment;
@@ -25,7 +27,7 @@
2527
/**
2628
* The {@link MagicianTalisman} is a special kind of {@link Talisman} which awards a {@link Player}
2729
* with an extra {@link Enchantment} when they enchant their {@link ItemStack}.
28-
*
30+
*
2931
* @author TheBusyBiscuit
3032
*
3133
*/
@@ -40,7 +42,7 @@ public MagicianTalisman(SlimefunItemStack item, ItemStack[] recipe) {
4042

4143
addItemSetting(allowEnchantmentBooks);
4244

43-
for (Enchantment enchantment : Enchantment.values()) {
45+
for (Enchantment enchantment : RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT)) {
4446
try {
4547
for (int i = 1; i <= enchantment.getMaxLevel(); i++) {
4648
enchantments.add(new TalismanEnchantment(this, enchantment, i));
@@ -63,13 +65,13 @@ public MagicianTalisman(SlimefunItemStack item, ItemStack[] recipe) {
6365
/**
6466
* This method picks a random {@link TalismanEnchantment} for the provided {@link ItemStack}.
6567
* The method will return null, if null was provided or no applicable {@link Enchantment} was found.
66-
*
68+
*
6769
* @param item
6870
* The {@link ItemStack} to find an {@link Enchantment} for
6971
* @param existingEnchantments
7072
* A {@link Set} containing the {@link Enchantment Enchantments} that currently exist on the
7173
* {@link ItemStack}
72-
*
74+
*
7375
* @return An applicable {@link TalismanEnchantment} or null
7476
*/
7577
@Nullable

0 commit comments

Comments
 (0)