Enchants API

The EdToolsEnchantAPI allows you to interact with the custom enchantment system of the plugin. You can get, modify, and trigger enchantments for players.

Get API Instance

EdToolsEnchantAPI enchantAPI = EdToolsAPI.getInstance().getEnchantAPI();

Methods

registerEnchant(String enchantId, APIEnchant enchant)

Registers an API enchant.

  • uuid: The enchant id. This should be the same to the enchant file name inside EdTools/enchants folder.

getEnchantLevel(UUID uuid, String enchant)

Gets the current level of a specific enchant for a player.

  • uuid: The player's unique ID.

  • enchant: The ID of the enchantment.

  • Returns: A double representing the player's enchant level.

addEnchantLevel(UUID uuid, String enchant, double level)

Adds a specified number of levels to a player's enchant.

  • uuid: The player's unique ID.

  • enchant: The ID of the enchantment.

  • level: The number of levels to add.

removeEnchantLevel(UUID uuid, String enchant, double level)

Removes a specified number of levels from a player's enchant.

  • uuid: The player's unique ID.

  • enchant: The ID of the enchantment.

  • level: The number of levels to remove.

triggerCustomEnchant(Player player, String enchant, Material material, Vector position)

Forces the activation of a custom enchant's effect. This does not perform a chance check.

  • player: The player triggering the enchant.

  • enchant: The ID of the enchant to trigger.

  • material: The Material of the block involved (if applicable).

  • position: The Vector position of the event (e.g., block broken).

tryTriggerCustomEnchant(Player player, String enchant, Material material, Vector position)

Attempts to trigger a custom enchant, respecting its activation chance.

  • Returns: true if the enchant successfully triggered, false otherwise.

getEnchantChance(UUID uuid, String enchant)

Gets the activation chance for a given enchant for a specific player.

  • uuid: The player's unique ID.

  • enchant: The ID of the enchantment.

  • Returns: A double between 0 and 100 representing the chance.

getEnchantMaxLevel(String enchant)

Gets the configured maximum level for an enchantment.

  • enchant: The ID of the enchantment.

  • Returns: A double for the max level.

getEnchantStartingLevel(String enchant)

Gets the configured starting level for an enchantment.

  • enchant: The ID of the enchantment.

  • Returns: A double for the starting level.

getEnchantMaxChance(String enchant)

Gets the configured maximum activation chance for an enchantment.

  • enchant: The ID of the enchantment.

  • Returns: A double for the max chance.

Last updated

Was this helpful?