API Placeholders - Senither/Lilypad-Minigame-Hook GitHub Wiki

Placeholders

Placeholders are dynamic variables that are sent across the network from servers using the Lilypad Minigame Hook plugin to servers defined as lobbies by the config.yml file, gameboards on lobbies can then use the variables on signs to render the variable contents to the sign, registering placeholders is made easy via the Minigame API.

How to

Register placeholders

The registerPlaceholder method can be used to register a custom placeholder via the API, the method takes three arguments and returns a boolean, true on success, false on failure:

Type Name Description
Plugin plugin The instance of the plugin attempting to register the placeholder.
String placeholder The string versions of the placeholder that should be registered.
Closure value The value of the placeholder, the API closure class is used for this but a lambda expression can also be used instead.

Example Usage

LilypadMinigameAPI.registerPlaceholder(plugin, "playersOnline", () -> {
    return "" + getServer().getOnlinePlayers().size();
});

The example above would produce a placeholder called {playersOnline} that always shows the number of players online on the game boards for any server who has the placeholder registered.

Placeholders are updated once every second, or once every 20 Minecraft game tick.

Get the amount of existing placeholders

If for some reason you need to know how many placeholders are registered with the Minigame Hook you can use the getPlaceholderCount method, the method returns an integer of the size of the placeholder map.

Example Usage

LilypadMinigameAPI.getPlaceholderCount();
// This will return 4 unless custom placeholders has already been registered.

Get the placeholders already registered

The placeholder keys can be accessed as an immutable list via the getPlaceholders method.

Example Usage

LilypadMinigameAPI.getPlaceholders();
// ["display", "serverMotd", "playersMax", "playersOnline", ...]