Enchant API
Overview
The enchantment system extends beyond vanilla Minecraft enchantments, providing custom effects with configurable levels, chances, and trigger conditions. Enchantments can be tied to specific materials and have complex probability-based activation systems.
Enchantment Registration
void registerEnchant(String id, APIEnchant enchant)
Description: Registers a new custom enchantment in the system
Parameters:
id- Unique identifier for the enchantmentenchant- APIEnchant implementation defining the enchantment behavior
Usage: Plugin initialization, dynamic enchantment loading
Note: This allows external plugins to create their own enchantments
Player Enchantment Management
Level Operations
void addEnchantLevel(UUID uuid, String enchant, double level)
Description: Increases a player's enchantment level
Parameters:
uuid- Player's unique identifierenchant- Enchantment identifierlevel- Levels to add (can be fractional)
Usage: Reward progression, enchantment upgrades, leveling systems
double getEnchantLevel(UUID uuid, String enchant)
Description: Gets a player's current level in a specific enchantment
Parameters:
uuid- Player's unique identifierenchant- Enchantment identifier
Returns: Current enchantment level (0.0 if not learned)
Usage: Display progression, calculate effects, requirement checking
void removeEnchantLevel(UUID uuid, String enchant, double level)
Description: Decreases a player's enchantment level
Parameters:
uuid- Player's unique identifierenchant- Enchantment identifierlevel- Levels to remove (can be fractional)
Usage: Penalties, rebalancing, temporary level reduction
Chance Calculation
double getEnchantChance(UUID uuid, String enchant)
Description: Gets the current activation chance for a player's enchantment level
Parameters:
uuid- Player's unique identifierenchant- Enchantment identifier
Returns: Activation chance as decimal (0.0 to 1.0)
Usage: Display probability, calculate expected outcomes
Enchantment Activation
Manual Triggering
void triggerCustomEnchant(Player player, String enchant, int mobId)
Description: Forcefully triggers an enchantment effect
Parameters:
player- Player triggering the enchantmentenchant- Enchantment to triggermobId- Target mob entity ID
Usage: Guaranteed activation, testing, special abilities
boolean tryTriggerCustomEnchant(Player player, String enchant, int mobId)
Description: Attempts to trigger an enchantment based on its activation chance
Parameters:
player- Player attempting to triggerenchant- Enchantment to attemptmobId- Target mob entity ID
Returns: True if enchantment activated, false otherwise
Usage: Natural enchantment activation, combat systems
Enchantment Configuration
Level Constraints
double getEnchantMaxLevel(String enchant)
Description: Gets the maximum level for an enchantment
Parameters:
enchant- Enchantment identifierReturns: Maximum achievable level
Usage: Progression caps, validation, upgrade limits
double getEnchantStartingLevel(String enchant)
Description: Gets the starting level for new players
Parameters:
enchant- Enchantment identifierReturns: Initial level value
Usage: New player initialization, reset operations
double getEnchantMaxChance(String enchant)
Description: Gets the maximum activation chance for an enchantment
Parameters:
enchant- Enchantment identifierReturns: Maximum chance value (typically 1.0 for 100%)
Usage: Balance checking, progression planning
Last updated
Was this helpful?