Class EnchantOfferGenerator

java.lang.Object
io.artificial.enchantments.internal.enchanttable.EnchantOfferGenerator

public final class EnchantOfferGenerator extends Object
Generates enchantment offers for the enchantment table.

This class handles the generation of custom enchantment offers based on:

  • Enchantment rarity weights (common, uncommon, rare, very rare)
  • Table power level (number of bookshelves)
  • Item material applicability
  • Enchantment configuration (min/max bookshelves, cost multipliers)
  • Conflict detection with vanilla and other custom enchantments

Offer Generation:

  1. Filter enchantments by discoverability and bookshelf range
  2. Calculate weighted probability for each eligible enchantment
  3. Randomly select enchantments for each slot
  4. Determine level based on power, slot position, and random factor
  5. Calculate cost based on level, rarity, and configuration
Since:
0.2.0
  • Constructor Details

    • EnchantOfferGenerator

      public EnchantOfferGenerator(@NotNull @NotNull EnchantmentRegistryManager registryManager)
      Creates a new offer generator.
      Parameters:
      registryManager - the enchantment registry for looking up definitions
      Throws:
      NullPointerException - if registryManager is null
      Since:
      0.2.0
  • Method Details

    • generateOffers

      @NotNull public @NotNull List<EnchantOfferGenerator.GeneratedOffer> generateOffers(@NotNull @NotNull org.bukkit.inventory.ItemStack item, int power, @NotNull @NotNull Set<org.bukkit.enchantments.Enchantment> existingOffers)
      Generates custom enchantment offers for an item.

      Creates up to 3 offers based on the item type, table power, and existing vanilla enchantments. Each offer includes the enchantment definition, calculated level, cost, and configuration.

      Parameters:
      item - the item being enchanted
      power - the enchantment table power (number of bookshelves)
      existingOffers - set of vanilla enchantments already offered
      Returns:
      list of generated custom offers (may be empty)
      Since:
      0.2.0