Removed most hyperlink

alexcrea 2024-07-12 02:28:17 +02:00
parent ea3722e51c
commit 3b06021748

@ -1,17 +1,33 @@
Registering your enchantment allow Custom Anvil to use your enchantment. Registering your enchantment allow Custom Anvil to use your enchantment.
To register your enchantment, you need into a [CAEnchantment](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/enchant/CAEnchantment.java) 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. 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.
*** ***
If you were able to register your enchantment to the bukkit registry. Then you should use or extend [CABukkitEnchantment](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/enchant/wrapped/CABukkitEnchantment.java) If you were able to register your enchantment to the bukkit registry. Then you should use or extend `CABukkitEnchantment`
```java ```java
CAEnchantment enchantment = new CABukkitEnchantment(bukkitEnchant); CAEnchantment enchantment = new CABukkitEnchantment(bukkitEnchant);
``` ```
<br></br>
If your enchantment does not register 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.
* `isEnchantmentPresent`: To test is an enchantment is present in item or an item meta .
* `addEnchantmentUnsafe`: To add the enchantment with the specified level using item or an item meta.
* `removeFrom`: To remove the enchantment from the specified item.
If your enchantment does not register into the bukkit registry (for example, if you store via persistend data), then you should preferably create a class extending [CAEnchantmentBase](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/enchant/CAEnchantmentBase.java) and implement the required functions. You can also directly implement [CAEnchantment](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/enchant/CAEnchantment.java), but it is not recommended. You can add optional features by implementing other function:
* `isCleanOptimised` and `isCleanOptimised`: Indicate if a bulk operation exist for this echantment. (wiki in WIP)
* `isAllowed`: Allow the enchantment to be combined by only certain player. usefull for example if you like to allow only player with a specific permission.
You also need 3 object as constructor:
* `key`: Namespaced key of your enchantment.
* `defaultRarity`: Default rarity of your enchantment. Please note "rarity" is how custom anvil name the concept of "Multipler by book/item". ([minecraft wiki](https://minecraft.wiki/w/Anvil_mechanics#Costs_for_combining_enchantments))
* `defaultMaxLevel`: Default maximum enchantment level.
<br></br>
You can also directly implement `CAEnchantment`, but it is not recommended.
*** ***
@ -21,9 +37,9 @@ Here is the function to use to register your enchantment:
EnchantmentApi.registerEnchantment(enchantment); EnchantmentApi.registerEnchantment(enchantment);
``` ```
You should use it on only when or after the [CAEnchantRegistryReadyEvent](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/api/event/CAEnchantRegistryReadyEvent.java) event is triggered. You should use it on only when and after the `CAEnchantRegistryReadyEvent` event is triggered.
To register the enchantment present on startup you should listen to the [CAEnchantRegistryReadyEvent](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/api/event/CAEnchantRegistryReadyEvent.java) event and register your enchantment. \ To register the enchantment present on startup, you should listen to the `CAEnchantRegistryReadyEvent` event and register your enchantment. \
It should look something like this example: It should look something like this example:
```java ```java
@ -41,9 +57,9 @@ It should look something like this example:
*** ***
You can also register or unregister an enchantment at runtime via the [EnchantmentApi](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/api/EnchantmentApi.java) facade. But every enchantment using previously written conflict should be registered on the event trigger. If you do not register the enchantment in time, the conflict will not find your enchantment and will cause issue. You can register or unregister an enchantment at runtime via the `EnchantmentApi` facade. But every enchantment using previously written conflict should be registered on the event trigger. If you do not register the enchantment in time, the conflict will not find your enchantment and will cause issue.
It is recommended to register conflict alongside its enchantment when [CAConfigReadyEvent](https://github.com/alexcrea/CustomAnvil/blob/master/src/main/java/xyz/alexcrea/cuanvil/api/event/CAConfigReadyEvent.java) is triggered. (page about conflict do not exist: wiki in WIP) It is recommended to register conflict alongside its enchantment when `CAConfigReadyEvent` is triggered. (wiki in WIP)