Search in sources :

Example 1 with PlaceholderAPI

use of com.creeperface.nukkit.placeholderapi.api.PlaceholderAPI in project Plan by plan-player-analytics.

the class NukkitPlaceholderRegistrar method register.

public void register() {
    PlaceholderAPI api = PlaceholderAPI.getInstance();
    placeholders.getPlaceholders().forEach((name, loader) -> api.builder(name, Serializable.class).visitorLoader(options -> {
        try {
            return loader.apply(getPlayer(options.getPlayer()), getPlaceholderParameterValues(options.getParameters()));
        } catch (Exception e) {
            errorLogger.warn(e, ErrorContext.builder().related("Registering PlaceholderAPI").build());
            return null;
        }
    }).build());
    placeholders.getStaticPlaceholders().forEach((name, loader) -> api.builder(name, Serializable.class).loader(options -> {
        try {
            return loader.apply(new Arguments(getPlaceholderParameterValues(options.getParameters())));
        } catch (Exception e) {
            errorLogger.warn(e, ErrorContext.builder().related("Registering PlaceholderAPI").build());
            return null;
        }
    }).build());
}
Also used : Serializable(java.io.Serializable) Arguments(com.djrapitops.plan.commands.use.Arguments) PlaceholderAPI(com.creeperface.nukkit.placeholderapi.api.PlaceholderAPI)

Aggregations

PlaceholderAPI (com.creeperface.nukkit.placeholderapi.api.PlaceholderAPI)1 Arguments (com.djrapitops.plan.commands.use.Arguments)1 Serializable (java.io.Serializable)1