org.lodemc.api package. Build your own mechanics on top of Lode Items content, let server owners configure them in the same YAML files, and ship your models and textures in the same resource pack.
The API is written in Kotlin and is called from Java like any Java library. Every example on these pages is Java.
Setting up
1
Compile against the Lode Items jar
Put the Lode Items jar in your project, for example in
libs/, and add it as a compile-only dependency. Don’t shade it into your plugin.2
Depend on Lode Items
Lode Items must load before your plugin, and your plugin must be able to see its classes.With
softdepend or required: false, check that Lode Items is enabled before you touch any org.lodemc.api class.When to call what
Lode Items loads its content in its ownonEnable, which runs after every plugin’s onLoad and before your onEnable. So:
Everything you register is removed when your plugin disables.
Things to know
- Call the API from the main thread. The one exception is crop rules, which Lode Items calls itself.
- Ids are Adventure keys, such as
Key.key("lodeitems", "ruby"). Methods that also take aStringreadrubyaslodeitems:ruby. A namespaced id likemyserver:rubyis kept as written.LodeItemsApi.key("ruby")does the same conversion for you. - Content changes on
/lodeitems reload. Items, blocks, props and crops can be added, changed or removed. Objects you got from the API before a reload are out of date afterwards, so look them up again onLodeItemsLoadEvent. Placed blocks and props in the world stay where they are. - Bukkit can’t tell custom blocks apart. It reports a generic
Materialfor all of them:STONEfor solid blocks,GLASSfor see-through blocks, andTRIPWIREfor walk-through blocks and crops. UseLodeBlocks.atto find out what a block really is. - Normal Bukkit events still fire for custom content, such as
BlockPlaceEvent,BlockBreakEventandPlayerInteractEvent. See Vanilla events. - Free and licensed editions don’t change the API. The free edition loads fewer items, blocks and plants, so the API only sees what loaded.
Example: a mana cost on any item
This short plugin lets owners writemana-cost: on any Lode Items item, and reads it when a player right-clicks:
items/weapons/fire_staff.yml
