### Complete Enchantment Configuration Example Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/how-to-make-a-custom-enchant.md A comprehensive example demonstrating all configuration sections including display, mechanics, obtaining, drag-and-drop settings, and functional effects. ```yaml # === Display: what the player sees === display-name: "Example" # In-game name of the enchantment description: # Lore shown under the enchantment - "Gives a &a%placeholder%%&8 bonus to damage" placeholder: "%level% * 20" # Value injected wherever %placeholder% appears placeholders: # Extra named placeholders (optional) example: "%level% * 800" # Used as %example% in the description type: normal # Enchantment type, from types.yml # === Mechanics: where it goes and how it relates to others === targets: # Item groups it can apply to, from targets.yml - sword conflicts: # Enchantments it can't coexist with (optional) - sharpness required: # Enchantments that must be present first (optional) - unbreaking rarity: common # Rarity, from rarity.yml max-level: 4 # Highest obtainable level # === Obtaining: how players can get it naturally === tradeable: true # Buyable from villagers discoverable: true # Generates in loot chests # To toggle individual discovery methods instead, use a map: # discoverable: # chests: true # fishing: true # mob-drops: true # raids: true enchantable: true # Rolls from the enchanting table # === Drag and drop: applying via an enchanted book (optional) === drag-and-drop: enabled: false # Lets players apply this enchantment by holding an enchanted book on their cursor and clicking an eligible item price: # Same format as any other eco price value: "100" type: coins display: "&a%value% coins" price-level-multiplier: "%level%" # Optional; %level% is the book's stored level, used as the price multiplier # === Effects: what the enchantment actually does === effects: - id: damage_multiplier # The effect to run args: multiplier: "1 + 0.2 * %level%" # Effect strength, scaling with level triggers: - melee_attack # When it fires conditions: [ ] # When the enchantment may activate ([ ] = always) ``` -------------------------------- ### Example Configuration Triggering MissingDependencyException Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/errors.md A YAML configuration snippet that requires specific plugins to be installed. ```yaml enchants: special_effect: display-name: "&cSpecial" max-level: 3 dependencies: - MyAwesomePlugin - AnotherRequiredPlugin effects: - effect: play_sound sound: entity_blaze_hurt ``` -------------------------------- ### EnchantmentTarget Usage Examples Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentTarget.md Demonstrates how to retrieve targets, check item matches, and find applicable enchantments. ```kotlin import com.willfp.ecoenchants.target.EnchantmentTargets import org.bukkit.inventory.ItemStack // Get all targets val targets = EnchantmentTargets.values() for (target in targets) { println("${target.id}: ${target.displayName} (${target.slot.id})") } // Get specific target val weaponTarget = EnchantmentTargets.getByID("weapon") if (weaponTarget != null) { println("Weapon target items: ${weaponTarget.items.size}") } // Check if item matches target val item = player.inventory.itemInMainHand val targetMatch = weaponTarget?.matches(item) ?: false println("Item matches weapon target: $targetMatch") // Get applicable enchantments for item val applicableEnchants = item.applicableEnchantments for (enchant in applicableEnchants) { for (target in enchant.targets) { if (target.matches(item)) { println("Can apply ${enchant.id} to this item") } } } // Check if item is enchantable val isEnchantable = item.isEnchantable ``` -------------------------------- ### Use EnchantmentType in Application Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentType.md Example demonstrating how to retrieve types and enforce application limits. ```kotlin import com.willfp.ecoenchants.type.EnchantmentTypes // Get all types val allTypes = EnchantmentTypes.values() println("Enchantment types: ${allTypes.map { it.id }}") // Get specific type val damageType = EnchantmentTypes.getByID("damage") if (damageType != null) { println("Display format: ${damageType.format}") println("Limit: ${damageType.limit}") println("High level bias: ${damageType.highLevelBias}") println("Grindstone removable: ${!damageType.noGrindstone}") } // Check limits when applying enchantment val type = enchantment.type val existingTypeEnchants = item.enchantments.count { it.key.wrap().type == type } if (existingTypeEnchants >= type.limit) { println("Cannot add more enchantments of type ${type.id}") } ``` -------------------------------- ### Configure Discovery in YAML Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/DiscoveryType.md Example configuration showing how to toggle discovery types globally or per-type for an enchantment. ```yaml enchants: burning: display-name: "&cBurning" max-level: 3 # Option 1: Boolean applies to all types discoverable: true # Option 2: Per-type control discoverable: chests: true fishing: false mob-drops: true raids: true ``` -------------------------------- ### Use EcoEnchantLike in Practice Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchantLike.md Example demonstrating how to inspect properties, validate item compatibility, and retrieve descriptions. ```kotlin import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack import com.willfp.ecoenchants.enchant.EcoEnchantLike // Get enchantment-like object (could be EcoEnchant or wrapper) val enchant: EcoEnchantLike = getEnchantmentLike() // Check basic properties println("Display Name: ${enchant.rawDisplayName}") println("Max Level: ${enchant.maximumLevel}") println("Type: ${enchant.type.id}") println("Rarity: ${enchant.enchantmentRarity.displayName}") // Check if item can be enchanted val item = player.inventory.itemInMainHand if (enchant.canEnchantItem(item)) { println("Can enchant this item!") } // Check with additional enchantments to consider val existingEnchants = item.enchantments.keys val canEnchant = enchant.canEnchantItem(item, existingEnchants) // Get formatted description val description = enchant.getRawDescription(3, player) for (line in description) { println(line) } ``` -------------------------------- ### Example MissingDependencyException Console Output Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/errors.md The warning message displayed in the server console when dependencies are missing. ```text [WARNING] 5 enchantments were not loaded because they need MyAwesomePlugin to be installed! [WARNING] Either download MyAwesomePlugin or delete the folder at /plugins/EcoEnchants/enchants/myawesomeplugin to remove this message ``` -------------------------------- ### Use EnchantmentTargets Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRegistries.md Example of retrieving targets and using ItemStack extensions to check compatibility. ```kotlin import com.willfp.ecoenchants.target.EnchantmentTargets import org.bukkit.inventory.ItemStack // Get all targets for (target in EnchantmentTargets.values()) { println("${target.id}: ${target.displayName}") } // Get specific target val weaponTarget = EnchantmentTargets.getByID("weapon") // Check if item is enchantable val item: ItemStack = // ... if (item.isEnchantable) { println("This item can be enchanted") } // Get applicable enchantments for item val applicable = item.applicableEnchantments println("Can apply ${applicable.size} enchantments to this item") ``` -------------------------------- ### Use EnchantmentRarities Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRegistries.md Example of iterating through all rarities and retrieving a specific rarity by ID. ```kotlin import com.willfp.ecoenchants.rarity.EnchantmentRarities // Get all rarities for (rarity in EnchantmentRarities.values()) { println("${rarity.id}: ${rarity.tableChance}") } // Get specific rarity val rare = EnchantmentRarities.getByID("rare") if (rare != null) { println("Villager chance: ${rare.villagerChance}") } ``` -------------------------------- ### Triggering Configuration Example Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/errors.md A YAML configuration snippet that triggers an IllegalArgumentException due to an invalid slot value. ```yaml targets: my_target: id: my_target display-name: "&cMy Items" slot: "NOT_A_REAL_SLOT" items: - DIAMOND_SWORD ``` -------------------------------- ### EcoEnchantLevel Usage Example Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchantLevel.md Demonstrates retrieving an enchantment level, accessing its properties, and verifying instance caching. ```kotlin import com.willfp.ecoenchants.enchant.EcoEnchants // Get an enchantment val enchant = EcoEnchants.getByID("burning") ?: return // Get level 3 of that enchantment val level3 = enchant.getLevel(3) // Check the level properties println("Enchantment: ${level3.enchant.id}") println("Level: ${level3.level}") println("ID: ${level3.id}") // Access effects and conditions val effects = level3.effects val conditions = level3.conditions // Levels are cached and will return the same instance val level3Again = enchant.getLevel(3) println("Same instance: ${level3 === level3Again}") // true // Use in holders and libreforge context // The level is used by libreforge to evaluate effects and conditions ``` -------------------------------- ### Anvil Cost Calculation Example Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/advanced-configuration.md Illustrates a specific anvil cost calculation with an exponent of 1.02 and an original cost of 25, resulting in a rounded-up cost of 28. ```Go cost = 25^1.02 + 1 ``` -------------------------------- ### EnchantFinder Usage Examples Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantFinder.md Demonstrates checking for active enchantments on players, retrieving items with specific enchantments, and validating enchantment slots. ```kotlin import com.willfp.ecoenchants.target.EnchantFinder import com.willfp.ecoenchants.enchant.EcoEnchants import org.bukkit.entity.Player val player: Player = // ... val enchant = EcoEnchants.getByID("burning") ?: return // Check if player has enchantment active if (player.hasEnchantActive(enchant)) { println("Player has burning enchantment active!") } // Get items with enchantment active val items = player.getItemsWithEnchantActive(enchant) for ((item, level) in items) { println("Item in slot has burning level $level") } // Find all enchantments on an item val item = player.inventory.itemInMainHand val enchantLevels = EnchantFinder.find(item) for (level in enchantLevels) { println("${level.enchant.id} level ${level.level}") } // Check if enchantment valid in slot val slot = SlotType.HAND val valid = EnchantFinder.isValidInSlot(enchantLevels[0], slot) ``` -------------------------------- ### Get String Representation Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRarity.md Returns a string representation in the format EnchantmentRarity{id}. ```kotlin override fun toString(): String ``` -------------------------------- ### Get Enchant from Name Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/README.md Retrieve an enchantment object based on a user-provided string identifier. ```kotlin val enchant = EcoEnchants.getByName(userInput) if (enchant != null) { println("Found: ${enchant.rawDisplayName}") } ``` -------------------------------- ### Get Formatted Enchantment Description Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Retrieves the formatted description lines for an enchantment, optionally using player context for placeholders. ```kotlin fun EcoEnchantLike.getFormattedDescription(level: Int, player: Player? = null): List ``` -------------------------------- ### Retrieve Enchantment Description Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchantLike.md Method to get processed description lines for a specific level, supporting dynamic placeholders. ```kotlin fun getRawDescription(level: Int, player: Player?): List ``` -------------------------------- ### Invalid Slot Error Message Format Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/errors.md Example of the error message generated when an invalid slot type is provided in the configuration. ```text Invalid slot type: INVALID_SLOT, options are [HAND, ARMOR_HEAD, ARMOR_CHEST, ARMOR_LEGS, ARMOR_FEET, ARMOR, OFF_HAND, ANY, ...] ``` -------------------------------- ### Project File Structure Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/SUMMARY.md Visual representation of the documentation directory layout. ```text /workspace/home/output/ ├── README.md ← Start here ├── SUMMARY.md ← This file ├── types.md ← Type definitions ├── configuration.md ← Config reference ├── errors.md ← Error reference └── api-reference/ ├── README.md ← API quick start ├── EcoEnchant.md ├── EcoEnchantLevel.md ├── EcoEnchantLike.md ├── EcoEnchants.md ├── EnchantmentType.md ├── EnchantmentRarity.md ├── EnchantmentTarget.md ├── DiscoveryType.md ├── EnchantFinder.md ├── EnchantDisplay.md ├── EnchantmentUtilities.md └── EnchantmentRegistries.md ``` -------------------------------- ### Get Formatted Enchantment Name Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Retrieves the formatted display name for an enchantment at a specific level. ```kotlin @JvmOverloads fun EcoEnchantLike.getFormattedName( level: Int, showNotMet: Boolean = false ): String ``` -------------------------------- ### Register an item Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRegistries.md Adds a new item to the registry. ```kotlin fun register(item: T) ``` -------------------------------- ### Prepare for Reload Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchants.md Prepares the system for a reload by replacing enchantment, rarity, target, and type registries. ```kotlin override fun beforeReload(plugin: LibreforgePlugin) ``` -------------------------------- ### Initialize EnchantmentTargets Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRegistries.md Initializes the registry with the default 'all' target. ```kotlin init { register(AllEnchantmentTarget) update() } ``` -------------------------------- ### Retrieve Applicable Enchantments Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentTarget.md Get a list of valid enchantments for an ItemStack based on defined targets and conflict rules. ```kotlin val ItemStack.applicableEnchantments: List ``` -------------------------------- ### Get Items with Active Enchantment Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantFinder.md Extension function to retrieve a map of items and their levels for a specific active enchantment. ```kotlin fun LivingEntity.getItemsWithEnchantActive(enchant: EcoEnchant): Map ``` -------------------------------- ### Handle MissingDependencyException with Prompts Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/errors.md Functions to track and report missing dependencies to the server console. ```kotlin fun addPluginPrompt(plugin: EcoEnchantsPlugin, plugins: Set) { for (pluginName in plugins) { prompts[pluginName] = prompts.getOrDefault(pluginName, 0) + 1 } } fun sendPrompts() { for ((pl, amount) in prompts) { plugin.logger.apply { warning("$amount enchantments were not loaded because they need $pl to be installed!") warning("Either download $pl or delete the folder at /plugins/EcoEnchants/enchants/${pl.lowercase()} to remove this message") } } prompts.clear() } ``` -------------------------------- ### Display Formatting in Kotlin Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/README.md Retrieve formatted names and descriptions for enchantments to display to players. ```kotlin import com.willfp.ecoenchants.display.getFormattedName import com.willfp.ecoenchants.display.getFormattedDescription val enchant: EcoEnchantLike = // ... val player: Player = // ... // Get formatted name val name = enchant.getFormattedName(3) // e.g., "&cBurning III" // Get formatted description val description = enchant.getFormattedDescription(3, player) for (line in description) { player.sendMessage(line) } ``` -------------------------------- ### Process and Register Configuration Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchants.md Processes an enchantment configuration and registers it. Missing dependencies will trigger plugin prompts. ```kotlin override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) ``` -------------------------------- ### shouldPreload Property Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchants.md Configuration property indicating if enchantments should be preloaded at startup. ```kotlin override val shouldPreload = true ``` -------------------------------- ### Calculate Anvil Cost with Exponent Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/advanced-configuration.md Demonstrates the formula for calculating anvil cost using a cost exponent. The result is rounded up to the nearest whole number. ```Go cost = level^exponent + 1 ``` -------------------------------- ### Display Method Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Formats and renders enchantment information into an item's lore. ```kotlin override fun display( itemStack: ItemStack, player: Player?, props: DisplayProperties, vararg args: Any ) ``` -------------------------------- ### Format for Display Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/README.md Generate formatted names and descriptions for enchantments at a specific level. ```kotlin import com.willfp.ecoenchants.display.getFormattedName val name = enchant.getFormattedName(3) val description = enchant.getFormattedDescription(3, player) ``` -------------------------------- ### Initialize HideStoredEnchantsProxy Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Retrieves the version-specific proxy for managing stored enchantment visibility. ```kotlin private val hse = plugin.getProxy(HideStoredEnchantsProxy::class.java) ``` -------------------------------- ### Check Enchantment Discovery Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/DiscoveryType.md Demonstrates how to verify if an enchantment is obtainable through specific discovery types or iterate through all available types. ```kotlin import com.willfp.ecoenchants.enchant.DiscoveryType import com.willfp.ecoenchants.enchant.EcoEnchants // Get an enchantment val enchant = EcoEnchants.getByID("burning") ?: return // Check if obtainable through specific discovery types if (enchant.isObtainableThrough(DiscoveryType.CHESTS)) { println("Can be found in chests") } if (enchant.isObtainableThrough(DiscoveryType.FISHING)) { println("Can be obtained fishing") } if (enchant.isObtainableThrough(DiscoveryType.MOB_DROPS)) { println("Can be obtained from mob drops") } if (enchant.isObtainableThrough(DiscoveryType.RAIDS)) { println("Can be obtained from raids") } // Check if obtainable through any discovery method if (enchant.isObtainableThroughDiscovery) { println("Can be discovered somehow") } // Iterate through all discovery types for (type in DiscoveryType.entries) { val obtainable = enchant.isObtainableThrough(type) println("${type.name}: $obtainable") } ``` -------------------------------- ### Access and Use Enchantment Rarities Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRarity.md Demonstrates retrieving all rarities, fetching specific rarities by ID, and accessing rarity data from an enchantment instance. ```kotlin import com.willfp.ecoenchants.rarity.EnchantmentRarities // Get all rarities val rarities = EnchantmentRarities.values() for (rarity in rarities) { println("${rarity.id}: ${rarity.displayName}") println(" Table chance: ${rarity.tableChance}") println(" Villager chance: ${rarity.villagerChance}") println(" Loot chance: ${rarity.lootChance}") } // Get specific rarity val rare = EnchantmentRarities.getByID("rare") if (rare != null) { println("Display: ${rare.displayName}") println("Table spawn rate: ${rare.tableChance * 100}%") } // Access rarity from enchantment val enchant = EcoEnchants.getByID("burning") val rarity = enchant?.enchantmentRarity if (rarity != null) { println("${enchant.rawDisplayName} is ${rarity.displayName}") } // Check if enchantment can spawn at a given level val enchantmentLevel = 3 val rarity = enchantment.enchantmentRarity if (enchantmentLevel >= rarity.minimumLevel) { val chance = rarity.tableChance * 100 println("$chance% chance from enchanting table") } ``` -------------------------------- ### Initialize EnchantmentRarity Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRarity.md The primary constructor for creating an instance from a configuration object. ```kotlin EnchantmentRarity(config: Config) ``` -------------------------------- ### In-Game Commands Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/configuration.md List of administrative commands available for managing enchantments in-game. ```APIDOC ## In-Game Commands ### /ecoenchants reload Reloads all plugin configurations. ### /enchant [player] [level] Applies a specific enchantment to a player. ### /enchantinfo Displays detailed information about a specific enchantment. ### /ecoenchants gui Opens the enchantment graphical user interface. ``` -------------------------------- ### Configure EnchantDisplay in config.yml Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Define display settings for enchantment names, descriptions, and collapsing behavior. ```yaml display: require-enchantable: true numerals: enabled: true threshold: 10 collapse: enabled: true threshold: 5 per-line: 3 delimiter: " &8| &r" descriptions: enabled: true threshold: 5 format: "&7" word-wrap: 40 enchantments-below-lore: false not-met: format: "&8&o" above-max-level: enabled: true format: "&c+" level-only: false ``` -------------------------------- ### Configure LibreForge Conditions Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/configuration.md Specify requirements that must be met for an enchantment to remain active. ```yaml conditions: - condition: holding_item_with_enchant enchant: sharpness - condition: health_above_percentage percentage: 50 ``` -------------------------------- ### Process Preloaded Configuration Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchants.md Processes a preloaded enchantment configuration, which ignores missing dependencies. ```kotlin override fun acceptPreloadConfig(plugin: LibreforgePlugin, id: String, config: Config) ``` -------------------------------- ### Implement EnchantmentType Methods Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentType.md Standard methods for registry interaction and object comparison. ```kotlin override fun getID(): String ``` ```kotlin override fun equals(other: Any?): Boolean ``` ```kotlin override fun hashCode(): Int ``` ```kotlin override fun toString(): String ``` ```kotlin override fun onRegister() ``` -------------------------------- ### Configure LibreForge Effects Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/configuration.md Define actions to trigger when an enchantment activates using the effects list. ```yaml effects: - effect: play_sound sound: entity_blaze_hurt volume: 1.0 pitch: 1.0 - effect: apply_potion_effect potion_effect: SPEED duration: 20 amplifier: 1 ``` -------------------------------- ### Accessing and Inspecting EcoEnchant Properties Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchant.md Demonstrates retrieving an enchantment from the registry and checking its properties, conflicts, and item compatibility. ```kotlin // Access an enchantment from the registry val enchant: EcoEnchant = EcoEnchants.getByID("my_custom_enchant") ?: return // Check basic properties println("Max Level: ${enchant.maximumLevel}") println("Can enchant through table: ${enchant.isObtainableThroughEnchanting}") println("Hidden from GUI: ${enchant.isHiddenFromGui}") // Check conflict val other = Enchantment.getByKey(NamespacedKey.minecraft("sharpness"))!! val conflicts = enchant.conflictsWith(other) // Get enchantment level with effects val level5 = enchant.getLevel(5) println("Effects for level 5: ${level5.effects}") // Check if item can be enchanted with this val item = player.inventory.itemInMainHand if (enchant.canEnchantItem(item)) { println("Can enchant this item!") } ``` -------------------------------- ### Implement matches Method Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentTarget.md Logic to determine if an ItemStack satisfies the target's item matchers. ```kotlin fun matches(itemStack: ItemStack): Boolean { for (item in items) { if (item.matches(itemStack)) { return true } } return false } ``` -------------------------------- ### Enchantment Conditions and Acquisition Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchant.md Properties defining activation conditions and methods for obtaining the enchantment. ```kotlin val conditions: ConditionList ``` ```kotlin val isObtainableThroughEnchanting: Boolean ``` ```kotlin val isObtainableThroughTrading: Boolean ``` ```kotlin val isObtainableThroughDiscovery: Boolean get() = DiscoveryType.entries.any { isObtainableThrough(it) } ``` ```kotlin val isHiddenFromGui: Boolean ``` -------------------------------- ### display(itemStack, player, props, ...args) Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Formats and renders enchantment information into an item's lore based on configured display properties. ```APIDOC ## display(itemStack, player, props, ...args) ### Description Formats and displays enchantments in an item's lore, handling sorting, collapsing, descriptions, and conditional indicators. ### Parameters - **itemStack** (ItemStack) - The item to format - **player** (Player?) - Optional player for context-specific formatting - **props** (DisplayProperties) - Display properties from eco-core - **args** (Array) - First arg: Boolean hideEnchants (true to hide with HIDE_ENCHANTS flag) ``` -------------------------------- ### EcoEnchantLevel Method Signatures Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchantLevel.md Standard methods for equality, hashing, and string representation based on the unique ID. ```kotlin override fun equals(other: Any?): Boolean ``` ```kotlin override fun hashCode(): Int ``` ```kotlin override fun toString(): String ``` -------------------------------- ### Configure Drag and Drop Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/how-to-make-a-custom-enchant.md Enables players to apply enchantments by clicking items with an enchanted book, supporting custom pricing and level multipliers. ```yaml drag-and-drop: enabled: false # Off by default price: # Same format as any other eco price - see the price lookup system docs value: "100" type: coins display: "&a%value% coins" price-level-multiplier: "%level%" # Optional expression; %level% is the book's stored level, used as the price multiplier ``` -------------------------------- ### Enable Debug Logging in config.yml Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/errors.md Set the debug flag to true in the configuration file to increase logging verbosity for troubleshooting. ```yaml debug: true ``` -------------------------------- ### getRawDescription Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchantLike.md Retrieves the raw description lines for a specific enchantment level, with dynamic placeholders evaluated. ```APIDOC ## fun getRawDescription(level: Int, player: Player?): List ### Description Get the raw description lines for a specific enchantment level, with placeholders evaluated. Supports custom placeholders, level-based math, and context-specific player data. ### Parameters - **level** (Int) - Required - The enchantment level to get description for. - **player** (Player?) - Optional - Optional player for context-specific placeholder evaluation. ### Returns - **List** - List of description lines with placeholders replaced. ``` -------------------------------- ### Display Formatting Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/README.md Methods for retrieving formatted names and descriptions for display purposes. ```APIDOC ## Display Formatting ### Description Methods to get the display-ready name and description of an enchantment at a specific level. ### Methods - **enchant.getFormattedName(level: Int)**: Returns the formatted name string. - **enchant.getFormattedDescription(level: Int, player: Player)**: Returns the formatted description string based on the player context. ``` -------------------------------- ### Initialize EnchantmentType Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentType.md Constructor for creating a new enchantment type instance. ```kotlin EnchantmentType(config: Config) ``` -------------------------------- ### Iterate All Enchantments on Item Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/README.md Retrieve and loop through all enchantments currently present on an item. ```kotlin val levels = EnchantFinder.find(item) for (level in levels) { println("${level.enchant.id} level ${level.level}") } ``` -------------------------------- ### Revert Method Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Removes enchantment display formatting and restores original item lore state. ```kotlin override fun revert(itemStack: ItemStack) ``` -------------------------------- ### Enchantment Requirements and Targets Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchant.md Properties defining prerequisites and valid item targets for the enchantment. ```kotlin val required: Set ``` ```kotlin val targets: Set ``` ```kotlin val slots: Set get() = targets.map { it.slot }.toSet() ``` -------------------------------- ### EcoEnchantLike.getFormattedDescription Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Retrieves the formatted description lines for an enchantment, including placeholder evaluation and word wrapping. ```APIDOC ## fun EcoEnchantLike.getFormattedDescription(level: Int, player: Player? = null): List ### Description Generates a list of formatted description lines for an enchantment, applying word wrapping and evaluating placeholders based on the provided player context. ### Parameters - **level** (Int) - Required - The enchantment level. - **player** (Player?) - Optional - The player context for placeholder evaluation. ### Returns - **List** - Description lines with formatting and word wrapping applied. ``` -------------------------------- ### Exception Hierarchy Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/errors.md Visual representation of the exception hierarchy used within the plugin. ```text Exception (java.lang) ├── MissingDependencyException └── IllegalArgumentException ``` -------------------------------- ### Registry Lookups Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/README.md Perform lookups for various enchantment components using their respective registries. ```kotlin EcoEnchants.getByID(id) // → EcoEnchant? EnchantmentTypes.getByID(id) // → EnchantmentType? EnchantmentRarities.getByID(id) // → EnchantmentRarity? EnchantmentTargets.getByID(id) // → EnchantmentTarget? ``` -------------------------------- ### Check Item Compatibility Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/README.md Verify if an item is enchantable and retrieve its applicable enchantments. ```kotlin import com.willfp.ecoenchants.target.EnchantmentTargets if (item.isEnchantable) { val applicable = item.applicableEnchantments } ``` -------------------------------- ### Accessing Enchantments in Kotlin Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/README.md Retrieve enchantments by ID, list all available enchantments, or wrap vanilla enchantments into EcoEnchantLike objects. ```kotlin import com.willfp.ecoenchants.enchant.EcoEnchants import com.willfp.ecoenchants.enchant.wrap // Get enchantment by ID val enchant = EcoEnchants.getByID("burning") // Get all enchantments val all = EcoEnchants.values() // Get enchantment level val level3 = enchant?.getLevel(3) // Get a vanilla enchantment val sharpness = Enchantment.getByKey(NamespacedKey.minecraft("sharpness")) val wrapped = sharpness?.wrap() // Convert to EcoEnchantLike ``` -------------------------------- ### Configure Lore Conversion Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/plugin-config.md Enable lore-based enchantment conversion to migrate items from other plugins. Use aggressive mode with caution as it may impact server performance. ```yaml lore-conversion: enabled: false # If lore conversion should be enabled aggressive: false # Will convert all items in all inventories when opened, likely to use a lot of performance ``` -------------------------------- ### Configure Enchantment Groups Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/plugin-config.md Define GUI groups for enchantments based on type, rarity, or target. Ensure IDs match the corresponding configuration files. ```yaml groups: - id: normal item: enchanted_book name:"&7Normal Enchantments" lore: - "&fClick to browse normal enchantments" row: 2 column: 2 - id: spell item: enchanted_book name:"Spell Enchantments" lore: - "&fClick to browse spell enchantments" row: 2 column: 4 - id: special item: enchanted_book name:"Special Enchantments" lore: - "&fClick to browse special enchantments" row: 2 column: 6 - id: curse item: enchanted_book name:"&cCurse Enchantments" lore: - "&fClick to browse curse enchantments" row: 2 column: 8 ``` -------------------------------- ### EcoEnchants SDK Methods Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/README.md Common patterns for interacting with the EcoEnchants API, including checking item compatibility, finding enchantments, and applying them. ```APIDOC ## SDK Methods ### Check if Item Can Be Enchanted Checks if a specific item is compatible with a given enchantment. ### Iterate All Enchantments on Item Retrieves all enchantments currently applied to an item using `EnchantFinder.find(item)`. ### Apply Enchantment to Item Applies a specific enchantment to an item using `item.addEnchantments(mapOf(enchant.enchantment to level), true)`. ### Get Enchant from Name Retrieves an enchantment instance by its ID or name using `EcoEnchants.getByID` or `EcoEnchants.getByName`. ### Filter Enchantments by Type Filters the global list of enchantments based on a specific `EnchantmentType`. ``` -------------------------------- ### Generate Hash Code Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRarity.md Generates a hash code based on the rarity ID. ```kotlin override fun hashCode(): Int ``` -------------------------------- ### EnchantDisplay Declaration Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md The singleton declaration for the EnchantDisplay module. ```kotlin @Suppress("DEPRECATION") object EnchantDisplay : DisplayModule(plugin, DisplayPriority.HIGH) ``` -------------------------------- ### EcoEnchantLevel Primary Constructor Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchantLevel.md Initializes a new enchantment level holder instance. ```kotlin EcoEnchantLevel( enchant: EcoEnchant, level: Int, effects: EffectList, conditions: ConditionList ) ``` -------------------------------- ### Enchantment Compatibility Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/README.md Utilities for checking if items are compatible with specific enchantments. ```APIDOC ## item.isEnchantable ### Description Checks if the provided item is eligible for enchantment. ## item.applicableEnchantments ### Description Returns a list of enchantments that can be applied to the item. ## EcoEnchantLike.canEnchantItem(ItemStack item) ### Description Checks if a specific enchantment can be applied to the given item. ``` -------------------------------- ### Configuring Enchantment Obtaining Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/how-to-make-a-custom-enchant.md Controls natural acquisition methods like trading, loot chests, and enchanting tables. ```yaml tradeable: true # Can be bought from villagers discoverable: true # Can generate in loot chests enchantable: true # Can roll from the enchanting table ``` ```yaml discoverable: chests: true # Loot chests fishing: true # Fishing rewards mob-drops: true # Mob drop tables raids: true # Raid rewards ``` -------------------------------- ### DisplayCache Object Structure Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantDisplay.md Defines the caching mechanism for formatted enchantment names and descriptions. ```kotlin object DisplayCache { val nameCache: EcoCache val descriptionCache: EcoCache> internal fun reload() } ``` -------------------------------- ### Access Enchantment Targets via Registry Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentTarget.md Retrieve enchantment targets or check item compatibility using the EnchantmentTargets registry. ```kotlin import com.willfp.ecoenchants.target.EnchantmentTargets // Get target by ID val target = EnchantmentTargets.getByID("weapon") // Get all targets for (target in EnchantmentTargets.values()) { // Process each target } // Check if item is enchantable val isEnchantable = item.isEnchantable // Get applicable enchantments for item val applicableEnchants = item.applicableEnchantments ``` -------------------------------- ### Use EnchantmentTypes Registry Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRegistries.md Demonstrates iterating through all registered types and retrieving a specific type by ID. ```kotlin import com.willfp.ecoenchants.type.EnchantmentTypes // Get all types for (type in EnchantmentTypes.values()) { println("${type.id}: ${type.format}") } // Get specific type val damageType = EnchantmentTypes.getByID("damage") if (damageType != null) { println("Damage limit: ${damageType.limit}") } ``` -------------------------------- ### EnchantmentTargets Registry Methods Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentRegistries.md Methods for retrieving and updating enchantment target data. ```kotlin fun getByID(id: String): EnchantmentTarget? ``` ```kotlin fun values(): Collection ``` ```kotlin @JvmStatic fun update() ``` -------------------------------- ### Configuring Enchantment Mechanics Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/how-to-make-a-custom-enchant.md Defines item compatibility, conflicts, requirements, and rarity settings. ```yaml targets: # Item groups it applies to (sword, axe, bow, armor...) from targets.yml; list as many as you like - sword conflicts: # Optional; IDs of enchantments that can't share an item with this one - sharpness required: # Optional; IDs that must already be on the item before this can apply - unbreaking rarity: common # Rarity from rarity.yml; affects coloring and how likely it rolls randomly max-level: 4 # Highest level players can reach; effects scale with %level% up to here ``` -------------------------------- ### Configuring Enchantment Display Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/how-to-make-a-custom-enchant.md Defines how the enchantment appears in-game, including lore, placeholders, and type classification. ```yaml display-name: "Example" # In-game name; supports color codes like &a and &8 description: # Lore shown under the enchant; one string or a list of lines, color codes and placeholders work - "Gives a &a%placeholder%%&8 bonus to damage" placeholder: "%level% * 20" # Optional; replaces %placeholder% in the description, good for scaling numbers placeholders: # Optional; define extra named placeholders when one isn't enough example: "%level% * 800" # Referenced as %example% in the description type: normal # Enchantment type from types.yml; controls coloring and grouping (e.g. normal, curse, special) ``` -------------------------------- ### Configure EcoEnchants settings Source: https://github.com/auxilor/ecoenchants/blob/master/documentation/ecoenchants/plugin-config.md The default configuration file for EcoEnchants, defining mechanics for enchanting tables, villagers, loot, anvils, and item display formatting. ```yaml # Options for enchanting items in the enchanting table enchanting-table: enabled: true # If custom enchantments should be available from enchanting tables book-multiplier: 0.5 # Multiplier applied to the chance of getting an enchantment on a book (to balance enchant numbers) maximum-obtainable-level: 30 # The max level for the enchanting table. EcoEnchants doesn't change the limit, but if you have a plugin that does, adjust this to match. cap: 5 # The maximum amount of enchantments to get at any given time reduction: 2.2 # The chance to get each subsequent enchantment is divided by this number, e.g. 2nd enchant is 2.2x less likely than 1st, 3rd is 2.2x less likely again, etc # Options for obtaining custom enchants from villagers villager: enabled: true # If custom enchantments should be available from villagers pass-through-chance: 25 # The chance to leave the book as-is with a vanilla/no enchantment applied. book-multiplier: 0.14 # Multiplier applied to the chance of getting an enchantment on a book (to balance enchant numbers) reduction: 5 # The chance to get each subsequent enchantment is divided by this number, e.g. 2nd enchant is 5x less likely than 1st, 3rd is 5x less likely again, etc # Options for obtaining custom enchants in natural loot loot: enabled: true # If custom enchantments should be available from natural loot book-multiplier: 0.5 # Multiplier applied to the chance of getting an enchantment on a book (to balance enchant numbers) reduction: 7.5 # The chance to get each subsequent enchantment is divided by this number, e.g. 2nd enchant is 7.5x less likely than 1st, 3rd is 7.5x less likely again, etc # Options for merging items in an anvil anvil: cost-exponent: 0.95 # The exponent for each enchant level to prevent constant "Too Expensive!" problems enchant-limit: -1 # The limit for the amount of enchantments on an item (-1 to disable) use-rework-penalty: true # If the rework penalty should be applied max-repair-cost: 40 # Override the maximum repair cost (-1 to make it infinite). When clamp-repair-cost is false, exceeding this cost will block the enchantment. clamp-repair-cost: true # If the repair cost should be clamped to the maximum repair cost # Options for how enchantments are displayed on items display: # If you disable display, enchantments will not show up on items. Only disable if you are handling display elsewhere. # Changing this will require a server restart. enabled: true # If enchantments should be displayed on the bottom of the item's lore enchantments-below-lore: false numerals: enabled: true # If numerals should be used for the enchantment levels threshold: 10 # Above this, numbers will be used instead of numerals # Options for not met lines: https://plugins.auxilor.io/effects/configuring-a-condition#example-condition-config not-met: format: "" # Enchantments with any not-met-lines active will have this format added to them above-max-level: enabled: true # If enchantments above their max level should have a custom format format: "" # The format to apply level-only: true # If only the level should be formatted sort: type: false # If enchantments should be sorted by time type-order: # The order for types to be sorted in. Types not in this list will not be displayed if type sorting is enabled. - normal - special - curse length: false # If enchantments should be sorted by length rarity: false # If enchantments should be sorted by rarity rarity-order: # The order for rarities to be sorted in. Rarities not in this list will not be displayed if rarity sorting is enabled. - common - uncommon - rare - epic - legendary - special - veryspecial collapse: enabled: true # If enchantments should be collapsed in lore threshold: 9 # Above this amount, enchantments will be collapsed per-line: 2 # The amount of enchantments to put in each line delimiter: ",&r " # The delimiter between enchantments descriptions: enabled: true # If enchantment descriptions should be shown in lore threshold: 5 # Above this amount, enchantment descriptions will not be shown word-wrap: 27 # Number of characters to have on each line format: "&8" ``` -------------------------------- ### Player Extension Methods Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantFinder.md Extension methods available on Player objects to check for active enchantments. ```APIDOC ## Player.hasEnchantActive(EcoEnchant) ### Description Checks if the player currently has a specific enchantment active. ### Signature `Player.hasEnchantActive(enchant: EcoEnchant): Boolean` --- ## Player.getItemsWithEnchantActive(EcoEnchant) ### Description Retrieves a map of items and their corresponding levels for a specific active enchantment on the player. ### Signature `Player.getItemsWithEnchantActive(enchant: EcoEnchant): Map` ``` -------------------------------- ### Configure Enchantment Targets in YAML Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentTarget.md Define custom enchantment targets and their associated items in the targets.yml configuration file. ```yaml targets: weapon: id: weapon display-name: "&cWeapons" slot: HAND items: - DIAMOND_SWORD - IRON_SWORD - WOODEN_SWORD - STONE_SWORD - NETHERITE_SWORD - DIAMOND_AXE - IRON_AXE armor: id: armor display-name: "&bArmor" slot: ARMOR items: - DIAMOND_HELMET - DIAMOND_CHESTPLATE - DIAMOND_LEGGINGS - DIAMOND_BOOTS helmet: id: helmet display-name: "&bHelmets" slot: ARMOR_HEAD items: - DIAMOND_HELMET - IRON_HELMET tool: id: tool display-name: "&6Tools" slot: HAND items: - DIAMOND_PICKAXE - DIAMOND_AXE - DIAMOND_SHOVEL ``` -------------------------------- ### Access configKey Property Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/DiscoveryType.md The property used to map discovery types to YAML configuration keys. ```kotlin val configKey: String ``` -------------------------------- ### EnchantmentTargets Utility Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentTarget.md Methods for retrieving and managing enchantment targets. ```APIDOC ## EnchantmentTargets ### Description Utility class for accessing registered enchantment targets. ### Methods - **values()**: Returns a collection of all registered EnchantmentTarget instances. - **getByID(String id)**: Retrieves a specific EnchantmentTarget by its unique identifier. Returns null if not found. ``` -------------------------------- ### Enchantment.wrap() Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentUtilities.md Converts a Bukkit Enchantment into an EcoEnchantLike wrapper. If the enchantment is already an EcoEnchant, it returns it directly; otherwise, it retrieves or creates a cached wrapper. ```APIDOC ## fun Enchantment.wrap(): EcoEnchantLike ### Description Converts any Bukkit Enchantment to an EcoEnchantLike wrapper. This allows for unified handling of both custom and vanilla enchantments. ### Parameters - **(receiver)** (Enchantment) - Required - The enchantment to wrap. ### Returns - **EcoEnchantLike** - Either the enchantment itself if it's an EcoEnchant, or a wrapper for vanilla enchantments. ``` -------------------------------- ### EcoEnchants SDK Methods Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EcoEnchants.md Methods for interacting with the enchantment registry, including retrieval by ID, name, and iteration. ```APIDOC ## EcoEnchants SDK Methods ### Description Provides access to the enchantment registry to retrieve, filter, and inspect enchantment data. ### Methods - **EcoEnchants.values()**: Returns a collection of all registered enchantments. - **EcoEnchants.getByID(id: String)**: Retrieves an enchantment by its unique identifier. Returns null if not found. - **EcoEnchants.getByName(name: String)**: Retrieves an enchantment by its display name. Returns null if not found. ### Enchantment Object Properties - **id** (String): The unique identifier of the enchantment. - **rawDisplayName** (String): The display name of the enchantment. - **targets** (List): The valid item targets for the enchantment. - **isObtainableThroughEnchanting** (Boolean): Whether the enchantment can be obtained via an enchanting table. - **getLevel(level: Int)**: Returns the configuration for a specific enchantment level, including its effects. ``` -------------------------------- ### Convert Negative to Infinite Limit Source: https://github.com/auxilor/ecoenchants/blob/master/_autodocs/api-reference/EnchantmentUtilities.md Maps negative integers to Int.MAX_VALUE to represent unlimited limits in configuration. ```kotlin internal fun Int.infiniteIfNegative(): Int ``` ```kotlin if (this < 1) Int.MAX_VALUE else this ``` ```kotlin val limit = config.getInt("enchant-limit").infiniteIfNegative() when (limit) { Int.MAX_VALUE -> println("Unlimited") else -> println("Limited to $limit") } ```