mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-12 06:06:55 +00:00
cache registry getters
This commit is contained in:
@@ -12,10 +12,11 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
public class SoulboundListener implements Listener {
|
||||
|
||||
private final Registry<Enchantment> registry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT);
|
||||
private final Enchantment soulbound = registry.get(SoulboundEnchant.KEY);
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onSoulboundEnchantDeath(PlayerDeathEvent event) {
|
||||
Registry<Enchantment> registry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT);
|
||||
Enchantment soulbound = registry.get(SoulboundEnchant.KEY);
|
||||
if (soulbound == null) return;
|
||||
event.getPlayer().getInventory().forEach(itemStack -> {
|
||||
if (itemStack != null && itemStack.containsEnchantment(soulbound)) {
|
||||
|
||||
@@ -17,10 +17,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class TelepathyListener implements Listener {
|
||||
|
||||
private final Registry<Enchantment> registry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT);
|
||||
private final Enchantment telepathy = registry.get(TelepathyEnchant.KEY);
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onTelepathyTool(BlockDropItemEvent event) {
|
||||
Registry<Enchantment> registry = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT);
|
||||
Enchantment telepathy = registry.get(TelepathyEnchant.KEY);
|
||||
if (telepathy == null) return;
|
||||
|
||||
ItemStack tool = event.getPlayer().getInventory().getItemInMainHand();
|
||||
|
||||
Reference in New Issue
Block a user