Class EnchantOfferGenerator
java.lang.Object
io.artificial.enchantments.internal.enchanttable.EnchantOfferGenerator
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:
- Filter enchantments by discoverability and bookshelf range
- Calculate weighted probability for each eligible enchantment
- Randomly select enchantments for each slot
- Determine level based on power, slot position, and random factor
- Calculate cost based on level, rarity, and configuration
- Since:
- 0.2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord representing a generated enchantment offer. -
Constructor Summary
ConstructorsConstructorDescriptionEnchantOfferGenerator(@NotNull EnchantmentRegistryManager registryManager) Creates a new offer generator. -
Method Summary
Modifier and TypeMethodDescription@NotNull List<EnchantOfferGenerator.GeneratedOffer> generateOffers(@NotNull org.bukkit.inventory.ItemStack item, int power, @NotNull Set<org.bukkit.enchantments.Enchantment> existingOffers) Generates custom enchantment offers for an item.
-
Constructor Details
-
EnchantOfferGenerator
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 enchantedpower- 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
-