For the complete documentation index, see llms.txt. This page is also available as Markdown.

API

Repository & Dependencies

repositories {
    maven("https://repo.nexomc.com/releases")
}

dependencies {
    compileOnly("com.nexomc:nexo:<version>") //Nexo 1.X -> 1.X.0
}

JavaDocs

Nexo has JavaDocs published at https://jd.nexomc.com. These will be updated whenever changes to the API are made, which is not too often.

Custom Items

Nexo has its own ItemBuilder class which handles building its custom items. The NexoItems-class contains most of the methods you would need to handle items.

ItemBuilder itemBuilder = NexoItems.itemFromId(itemID);
ItemStack itemStack = itemBuilder.build();
String itemId = NexoItems.idFromItem(itemStack);

Nexo loads items in an async task, thus getting them in your plugins onEnable will likely fail You can listen for the NexoItemsLoadedEvent to be sure the items are registered

Modifying how Nexo updates a NexoItem

Nexo will update any NexoItem on several actions to ensure its data is up-to-date. If your plugin should override any property on the Item which Nexo resets, follow the steps below.

You need to register an UpdateCallback which lets you run logic on any item Nexo updates. This should be registered during NexoItemsLoadedEvent as shown below;

External Items

Plugins can register their own items with Nexo through code, instead of through a config in the items-folder. The ConfigurationSection is parsed like any item-config, with its name as the item-id, and is parsed again on every reload.

Nexo fills in anything the section leaves out, like custom_variation or custom_model_data, by writing it onto the section. Your plugin has to save these values itself, as otherwise placed custom blocks get a new variation on the next start. The optional onConfigUpdated is called with the section whenever Nexo writes to it.

The optional itemFactory provides your plugin's own item when a player uses pick-block on its blocks and furniture. NexoItems.createItem(itemID) returns that item for external items, and a normally built NexoItem otherwise.

An id already used by an item-config is refused. The itemFactory can be called from the player's region thread on Folia

Component Projections

ComponentProjections lets you rewrite any text Nexo sends to a player, per player. Nexo caches the text of items per player, so call ComponentProjections.invalidate() whenever your projection would return something different for the same text.

Custom Blocks

The NexoBlocks-class contains all the methods available for placing, removing and checking for custom blocks in Nexo.

Furniture

The NexoFurniture-class contains all the methods available for placing, removing and checking for furniture in Nexo. In addition to this you can return the FurnitureMechanic of the Furniture to get specific properties of it if needed.

Text-Entity Overrides

By default every placed copy of a furniture shows the text configured in its Text-Entities. A FurnitureTextOverride lets your plugin decide the text per placed furniture instead, like a sign showing its owner. Return null to keep the configured text.

Overrides are checked in order of plugin name, and the first one returning a text wins. Pass a set of item-ids to only override those furniture.

The text is cached per placed furniture and shared by every player viewing it. Call NexoFurniture.refreshTextEntities(baseEntity) when the text should change. Overrides are removed automatically when your plugin disables, or manually with NexoFurniture.unregisterTextOverrides(plugin).

textFor runs on the furniture's region thread

Packs merged outside Nexo

Some models Nexo generates are based on models in the pack. If your plugin merges models into the pack after Nexo has generated it, Nexo cannot see them, and these have to be generated on your final pack instead.

resourcePack is a creative ResourcePack.

Custom Mechanics

Nexo allows you to add your own mechanics to the plugin, new ones or extending existing ones An example repository can be found here, with examples for both Java and Kotlin You can register your mechanic in your onEnable or wherever you want. This will register it when Nexo registers its own Mechanics, and parse them for items Mechanics consist of a Mechanic class with properties and methods. MechanicFactory consists of parsing method for global Mechanic properties & linking item -> mechanic NexoMechanicsRegisteredEvent - Called when Nexo loads/reloads Mechanics NexoItemsLoadedEvent - Called when Nexo finishes loading/reloading NexoItems

Toggling lights

NexoBlockInteractEvent and NexoFurnitureInteractEvent have a canToggleLight result, which decides if the interaction toggles a toggleable block light or furniture light. Set it to DENY to stop the light from toggling without cancelling the interaction.

Custom PackServer

If you want a PackServer type that Nexo does not provide, you can make an addon that registers one. Make a class that extends NexoPackServer and override the methods you need.

To register this with Nexo, you simply call PackServerRegistry.register(type, packServer)

Last updated