Interface EnchantTableConfiguration

All Known Implementing Classes:
EnchantTableConfigurationImpl

public interface EnchantTableConfiguration
Configuration API for customizing enchantment table behavior per-enchantment.

This interface allows enchantments to specify how they appear in the enchanting table, including weight multipliers, cost adjustments, and whether they should appear at all.

Usage Example:


 EnchantmentDefinition myEnchant = EnchantmentDefinition.builder()
     .key(new NamespacedKey(plugin, "my_enchant"))
     .displayName(Component.text("My Enchant"))
     .tableConfiguration(EnchantTableConfiguration.builder()
         .tableWeight(5)           // Appears 5x more often than base
         .minBookshelves(5)        // Requires at least 5 bookshelves
         .maxBookshelves(15)       // Won't appear above 15 bookshelves
         .costMultiplier(0.8)      // 20% cheaper than normal
         .allowMultiple(false)     // Only one offer per table
         .build())
     .build();
 
Since:
0.3.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builder for constructing table configurations.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if this enchantment can appear multiple times in the same table.
    Creates a builder for constructing table configurations.
    Gets the default configuration with all default values.
    double
    Gets the cost multiplier for enchanting with this enchantment.
    int
    Gets the maximum number of bookshelves for this enchantment.
    int
    Gets the minimum number of bookshelves required for this enchantment.
    int
    Gets the maximum enchantment level that can appear in the table.
    int
    Gets the minimum enchantment level that can appear in the table.
    double
    Gets the weight multiplier for this enchantment in the table.
    boolean
    Checks if this enchantment respects vanilla treasure/book restrictions.
  • Method Details

    • getWeightMultiplier

      double getWeightMultiplier()
      Gets the weight multiplier for this enchantment in the table.

      Base weights are determined by rarity:

      • COMMON: 10
      • UNCOMMON: 5
      • RARE: 2
      • VERY_RARE: 1

      This multiplier is applied to the base weight. A value of 2.0 makes the enchantment twice as likely to appear.

      Returns:
      the weight multiplier (default: 1.0)
      Since:
      0.3.0
    • getMinBookshelves

      int getMinBookshelves()
      Gets the minimum number of bookshelves required for this enchantment.

      The enchantment will not appear in offers if the table has fewer than this many bookshelves. Vanilla enchantments typically require 0-15 bookshelves depending on the enchantment type.

      Returns:
      minimum bookshelves required (default: 0)
      Since:
      0.3.0
    • getMaxBookshelves

      int getMaxBookshelves()
      Gets the maximum number of bookshelves for this enchantment.

      The enchantment will not appear in offers if the table has more than this many bookshelves. Use this to restrict high-tier enchantments to lower-power tables.

      Returns:
      maximum bookshelves allowed (default: 15)
      Since:
      0.3.0
    • getCostMultiplier

      double getCostMultiplier()
      Gets the cost multiplier for enchanting with this enchantment.

      This multiplier is applied to the base cost calculated from the enchantment level and power. A value of 0.8 makes the enchantment 20% cheaper. Values above 1.0 make it more expensive.

      Returns:
      the cost multiplier (default: 1.0)
      Since:
      0.3.0
    • allowsMultipleOffers

      boolean allowsMultipleOffers()
      Checks if this enchantment can appear multiple times in the same table.

      If false, only one offer slot can contain this enchantment. If true, multiple slots may offer the same enchantment at different levels.

      Returns:
      true if multiple offers allowed (default: false)
      Since:
      0.3.0
    • getTableMinLevel

      int getTableMinLevel()
      Gets the minimum enchantment level that can appear in the table.

      This is independent of the definition's minLevel. Use this to restrict table offers to higher levels while allowing lower levels through other means (e.g., anvil combinations).

      Returns:
      minimum level for table offers (default: definition's minLevel)
      Since:
      0.3.0
    • getTableMaxLevel

      int getTableMaxLevel()
      Gets the maximum enchantment level that can appear in the table.

      This is independent of the definition's maxLevel. Use this to restrict table offers to lower levels while allowing higher levels through other means.

      Returns:
      maximum level for table offers (default: definition's maxLevel)
      Since:
      0.3.0
    • isTreasure

      boolean isTreasure()
      Checks if this enchantment respects vanilla treasure/book restrictions.

      If true, the enchantment will only appear in the table when the item is placed directly (not via book). Treasure enchantments typically only appear this way.

      Returns:
      true if treasure-like behavior (default: false)
      Since:
      0.3.0
    • builder

      @NotNull static @NotNull EnchantTableConfiguration.Builder builder()
      Creates a builder for constructing table configurations.
      Returns:
      a new builder instance
      Since:
      0.3.0
    • defaults

      @NotNull static @NotNull EnchantTableConfiguration defaults()
      Gets the default configuration with all default values.
      Returns:
      the default configuration instance
      Since:
      0.3.0