Library components for user interfaces in the chat box
5

Chat UI Library

This plugin provides a library for creating user interfaces in the chat box.

Server administrators may need to install this if instructed by another plugin. It doesn’t provide any features to end-users by itself, please refer to the documentation for the plugin that requires Chat UI Library.

Plugin developers may find the Developer Documentation useful.

The principal plugin that utilizes this library is Chat UI, see that plugin for a demonstration of what this library enables.

That said, the library does have configuration settings, and provides some end-user commands for configuring the UI for players.

Configuration

The library’s configuration is stored in the config/chatuilib/ directory. The preferences.conf file stores the main configuration.

The following table outlines the options in preferences.conf:

KeyDefaultDescription
player-settings{}Stores UI settings for each player. Is a map of UUID -> settings. See below table for player settings recognized by Chat UI Library
use-language-packfalseEnable the usage of language packs. See below section on language packs
default-font""Sets the font data for players that haven’t set their own font data. If this is empty/missing then vanilla font is assumed. See below section on font data

Player settings

Every player has their own UI settings that they configure to work with their client. By default a vanilla client without any changed options (e.g. resource pack) is assumed.

KeyDefaultDescription
display-width320The width of the chat window in pixels. This value should correspond to the “Width” value on the client settings (see image below)
display-height180The height of the chat window in pixels. This value should correspond to the “Focused Height” value on the client settings (see image below)
force-unicodefalseEnable/disable unicode font mode. Corresponds to the “Force Unicode Font” button on the language selection screen of the Minecraft client. Some languages may require unicode mode.
font-dataA Base64-encoded string representing font dimension data. Refer to below section on font data

The width and height should correspond to the width and height on the chat settings screen: Client chat settings

Commands

The following commands are recognised by Chat UI Library. Please note that additional commands may be made available by the plugin(s) utilising this library plugin.

Also note that there are “hidden” commands under the /chatui command - these are used internally and should not be invoked directly.

CommandDescription
/chatui configOutputs the settings of the current player. Refer to above player settings table
/chatui config width <width>Sets the player’s UI width
/chatui config height <height>Sets the player’s UI height
/chatui config unicode <true|false>Sets whether the player is using unicode fonts
/chatui config font <fontdata>Sets custom font data for the player
/chatui emptySend an empty message to the open window. Required because you can’t send an empty message in the chat box

Language Packs and Font Data

Chat UI Library needs to perform calculations on the text it sends to the client. Normally, text is sent to the client and text calculations are done by the client based on the active resource pack and language settings. Chat UI Library has to perform these calculations server-side. Therefore, the server needs to be aware of the font information on each player’s client.

Language Packs

The vanilla server currently doesn’t come with translations for any language other than English (US). In order for Chat UI Library to perform operations on translated messages, it needs to have all translations available.

By enabling the use-language-pack option, Chat UI Library will download translation files used by the vanilla client into a zip file in the config/chatuilib/lang/ directory. These “language packs” contain bundled translation files.

If no players require localized translations and are happy with English (US) then language packs are not necessary.

Be aware that by enabling language packs, the initial download will connect to Mojang’s server to fetch the files. A request is made to https://launchermeta.mojang.com/mc/game/version_manifest.json and it follows the links from there.

Once the pack has been downloaded, translations will be served from the local zip file.

Font Data

Another thing usually handled by the client is measurements of fonts. Chat UI Library needs to be aware of the size of all characters in order to display properly. Because players may have different resource packs, this information needs to be configured per-player.

If you guarantee (or near-enough guarantee) that all players will be using a specific resource pack (maybe you have one set in server.properties), then you can specify default-font to be the font data for that resource pack.

Otherwise, Chat UI Library assumes the vanilla font.

In either case, every player may override their font data with the relevant /chatui config font command.

The font data is a Base64 string that encodes the dimensions of every character in the ascii.png file found in resource packs and in the vanilla game.

No tool currently exists to generate this string, but such a tool is planned at some point.

Category: Developer Tools

Published on Jul 13, 2017

views

stars

watchers

total downloads

Licensed under MIT

Promoted Versions

Pages

Members