Skip to content

API for Developers

CleverNucleus edited this page Sep 2, 2021 · 4 revisions

The bulk of the heavy lifting code-wise in PlayerEx is done by Data Attributes, meaning that the majority of the API function is for client-side things. These include registering new pages/tabs to the attributes screen, adding render layers to existing pages and providing a hook to the username nameplate rendering method.

It should be noted that as PlayerEx features a relatively light API package, most of the understanding needed to use it can be gained from reading the javadocs.

Cardinal Components

PlayerEx utilises a modifier cache system that uses Cardinal Components. It can be accessed through com.github.clevernucleus.playerex.api.ExAPI; the ExAPI class contains the the DATA field, which only accepts players (using the #get method).

The same class provides Supplier references to all the attributes added. They are lazy instances as depending on the stage/datapack, a given attribute may or may not exist. Therefore, when using these attribute references a null check should always be implemented. Also contained in the ExAPI class is a reference to the config, which is automatically synced when a player joins a world - so it can be called on both the client and server.

Page Registry

The page registry, located at com.github.clevernucleus.playerex.api.client.page.PageRegistry, allows you to register new pages (with custom tab icons). Refer to the javadoc for details.

Also in the page registry, is the ability to register "render layers". These are extensions of the PageLayer class, and allow you to create a gui screen and have it rendered on top of any page. This lets developers take a modular approach to gui components and allows for the addition of items to pre-existing pages.