mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Add AdditionalTestEnchantment section.
parent
12b7910421
commit
cbec93122e
1 changed files with 10 additions and 5 deletions
|
|
@ -3,17 +3,17 @@ Registering your enchantment allow Custom Anvil to use your enchantment.
|
|||
To register your enchantment, you need into a `CAEnchantment` instance and then register it. \
|
||||
This is so Custom Anvil know how to handle action with your enchantment like adding/removing and getting level of it from an item.
|
||||
|
||||
## Create the Custom Anvil enchantment
|
||||
# Creating a Custom Anvil enchantment
|
||||
|
||||
### If you were able to register your enchantment to the bukkit registry.
|
||||
## If you were able to register your enchantment to the bukkit registry.
|
||||
Then you should use or extend `CABukkitEnchantment`
|
||||
|
||||
```java
|
||||
CAEnchantment enchantment = new CABukkitEnchantment(bukkitEnchant);
|
||||
```
|
||||
|
||||
### If your enchantment is not registered into the bukkit registry
|
||||
For example if you store via persistent data:
|
||||
## If your enchantment is not registered into the bukkit registry
|
||||
For example, if you store via persistent data:
|
||||
|
||||
Then you should preferably create a class extending `CAEnchantmentBase` and implement the required functions:
|
||||
* `getLevel`: To get the enchantment level using item and item meta.
|
||||
|
|
@ -33,7 +33,12 @@ You also need 3 objects for the constructor:
|
|||
<br></br>
|
||||
You can also directly implement `CAEnchantment`, but it is not recommended.
|
||||
|
||||
## Registering your custom anvil enchantment
|
||||
## Custom Restriction
|
||||
You may want to implement AdditionalTestEnchantment to your Custom Anvil Enchantment class. It allows you to add external restriction:
|
||||
* `isEnchantConflict`: Test if the enchantment is compatible with a provided enchantment map. (key = enchantment, value = level)
|
||||
* `isItemConflict`: Test if this enchantment is compatible with a provided item (and its enchantments)
|
||||
|
||||
# Registering your custom anvil enchantment
|
||||
```java
|
||||
EnchantmentApi.registerEnchantment(enchantment);
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue