Skip to content

Enchantment seekers

Enchantment seekers, or seekers, are responsible for finding the enchantment in the player's inventory.

Creating a seeker

To start, create a class that implements the interface RegistrableEnchantmentSeeker.

class MySeeker : RegistrableEnchantmentSeeker {
  override val aliases = listOf<String>()

  override fun seekItems(player: Player): List<ItemStack?> = listOf()
}

Fill the aliases list with however you want to identify your seeker.

override val aliases = listOf("myseeker", "coolseeker")

Finding the items

All that the seeker does is select the items from the player inventory. These items later get checked for enchantments internally. As such, the seeker should simply return the list of all the (nullable) items to check:

override fun seekItems(player: Player): List<ItemStack?> = player.inventory.armorContents.toList()

Example seeker

Built-in MainHandSeeker
class MainHandSeeker : RegistrableEnchantmentSeeker {
  override val aliases = listOf("mainhand", "primaryhand", "main-hand", "primary-hand", "main", "primary")
  override fun seekItems(player: Player): List<ItemStack?> = listOf(player.inventory.itemInMainHand)
}