Download the PHP package sofe/infoapi without Composer
On this page you can find all versions of the php package sofe/infoapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package infoapi
InfoAPI
Extensible templating for PocketMine plugins.
In a nutshell, InfoAPI provides a simple API to register placeholders between plugins. But it is more powerful than just that:
- Object-oriented placeholder expressions
- Continuously update a template when variables change
- Parametric infos — mathematical operations on info expressions
Developer guide: Templating
If you let users customize messages in a config, you can consider formatting the message with InfoAPI.
Pass the config message into InfoAPI:
- "message" is the config key for the message template
- The args array are the base variables for the template.
The types of the variables must be one of the default types
or provided by another plugin through
InfoAPI::addKind
. $player
is optional. It tells InfoAPI how to localize the message better, e.g. by formatting for the player's language.
Advanced: Continuous templating
You can create a template and watch for changes using the renderContinuous
API:
Developer guide: Register mapping
A mapping converts one info to another,
e.g. money
converts a player to the amount of money in {player money}
.
You can register your own mappings
so that your plugin as well as other plugins using InfoAPI
can use this info in the template.
For example, to provide the money of an online player:
The source and return types must be a default or InfoAPI::addKind
types.
Advanced: Register continuous mapping
You can additionally provide a watchChanges
closure,
which returns a traverser
that yields a value when a change is detected.
The pmevent library may help
with building traversers from events:
Developer guide: Install InfoAPI
If you are not developing a plugin, you do not need to install InfoAPI yourself. Plugins should have included InfoAPI in their phar release.
InfoAPI v2 is a virion library using virion 3.1. Virion 3.1 uses composer to install libraries:
-
Include the InfoAPI virion by adding sof3/infoapi in your composer.json:
You can place this file next to your plugin.yml. Installing composer is recommended but not required.
-
Build your plugin with the InfoAPI virion using pharynx. You can test it on a server using the custom start.cmd/start.sh provided by pharynx.
- Use the pharynx GitHub action to integrate with Poggit. Remember to gitignore your vendor directory so that you don't push it to GitHub.
User guide: Writing a template
InfoAPI replaces expressions inside {}
with variables.
For example, if a chat plugin provides two variables:
sender
: the player who sent chat (SOFe)message
: the chat message the following will become something like<SOFe> Hello world
if the plugin providessender
andmessage
("Hello world")for the template:
Color codes are default variables. Instead of writing §1 §b etc, you could also write:
You can get more detailed info for a variable.
For example, to get the coordinates of a player player
:
Writing {
directly will cause error without a matching }
.
If you want to write a {
/}
that is not part of an expression, write twice instead:
This will become
All versions of infoapi with dependencies
sof3/await-generator Version ^3.6.1
sof3/pmevent Version ^0.0.2
sof3/zleep Version ^0.1.0
php Version ^8.1