Skip to content

Commit

Permalink
Dont use Enchantment.values()
Browse files Browse the repository at this point in the history
  • Loading branch information
md5sha256 committed Sep 25, 2024
1 parent 591da50 commit ba1a765
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.SoundCategory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -57,7 +60,7 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r

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

for (Enchantment enchantment : Enchantment.values()) {
for (Enchantment enchantment : RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT)) {
if (enchantment.equals(Enchantment.BINDING_CURSE) || enchantment.equals(Enchantment.VANISHING_CURSE)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
Expand All @@ -25,7 +27,7 @@
/**
* The {@link MagicianTalisman} is a special kind of {@link Talisman} which awards a {@link Player}
* with an extra {@link Enchantment} when they enchant their {@link ItemStack}.
*
*
* @author TheBusyBiscuit
*
*/
Expand All @@ -40,7 +42,7 @@ public MagicianTalisman(SlimefunItemStack item, ItemStack[] recipe) {

addItemSetting(allowEnchantmentBooks);

for (Enchantment enchantment : Enchantment.values()) {
for (Enchantment enchantment : RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT)) {
try {
for (int i = 1; i <= enchantment.getMaxLevel(); i++) {
enchantments.add(new TalismanEnchantment(this, enchantment, i));
Expand All @@ -63,13 +65,13 @@ public MagicianTalisman(SlimefunItemStack item, ItemStack[] recipe) {
/**
* This method picks a random {@link TalismanEnchantment} for the provided {@link ItemStack}.
* The method will return null, if null was provided or no applicable {@link Enchantment} was found.
*
*
* @param item
* The {@link ItemStack} to find an {@link Enchantment} for
* @param existingEnchantments
* A {@link Set} containing the {@link Enchantment Enchantments} that currently exist on the
* {@link ItemStack}
*
*
* @return An applicable {@link TalismanEnchantment} or null
*/
@Nullable
Expand Down

0 comments on commit ba1a765

Please sign in to comment.