Skip to content

Commit eeff82b

Browse files
committed
update mechanic register docs
1 parent 39322b9 commit eeff82b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

developers/mechanics.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,17 @@ class DurabilityMechanicsManager implements Listener {
207207
### Last step: register our mechanic
208208

209209
To finish we need to register our MechanicFactory and reload the items to apply the new mechanic to them.\
210+
It is recommended to register it in an EventListener for `OraxenNativeMechanicsRegisteredEvent`, due to `/oraxen reload all` clearing this registry.\
210211
To do this we need to add these lines in the onEnable method of our plugin:
211212

212213
```java
213-
MechanicsManager.registerMechanicFactory("durability", DurabilityMechanicFactory::new, true);
214-
OraxenItems.loadItems();
214+
Bukkit.getPluginManager().registerEvents(new Listener() {
215+
@EventHandler
216+
public void onMechanicRegister(OraxenNativeMechanicsRegisteredEvent event) {
217+
MechanicsManager.registerMechanicFactory("durability", DurabilityMechanicFactory::new, true);
218+
OraxenItems.loadItems();
219+
}
220+
}, this);
215221
```
216222

217223
## Conclusion

0 commit comments

Comments
 (0)