Skip to content

integration

Simon816 edited this page Feb 19, 2019 · 2 revisions

It is possible to integrate with Chat UI from other plugins.

Firstly, see the Chat UI Library documentation.

This page outlines how to integrate with the Chat UI tabbed-based interface. You can use the UI component library without depending on Chat UI, instead only depending on the library.

Creating Features

Features are pluggable modules that "install" themselves onto a player's chat view.
They have their own config section in the config file, and can be enabled or disabled by a server admin.

A feature is created by extending AbstractFeature. It is then registered with ChatUI.instance().getFeatureManager().registerFeature(plugin, featureId, featureSupplier).
The featureSupplier typically just invokes the constructor, it is used to lazy-load features so that disabled features never get constructed.

Features install themselves onto an ActivePlayerChatView with onNewPlayerView.

The ActivePlayerChatView is a PlayerChatView that indicates the player has the full Chat UI interface enabled. (tabs, status bar, etc)

To add a button to the "new tab" page, call getNewTab() on the view to obtain the NewTab tab. Call addButton(label, action) to add a button. Typically a LaunchTabAction is used to replace the "new tab" tab with the given tab.

To manipulate tabs on an active view, call getWindow() to return an instance of Window. With the window, tabs can be added, removed and switched to.

An active chat view also features a player list (one of the built in buttons in the new tab page). It is obtained by calling getPlayerList() on the view.
The player list is a table of players, with plugin defined additional columns.

An additional column can be defined by implementing PlayerList.Addon. An addon simply takes as argument a Player and returns a Text object which is shown in the associated column.
Addons are added by calling addAddon

Clone this wiki locally