use of org.spongepowered.api.placeholder.PlaceholderParser in project SpongeCommon by SpongePowered.
the class SpongeRegistryLoaders method placeholderParser.
public static RegistryLoader<PlaceholderParser> placeholderParser() {
return RegistryLoader.of(l -> {
l.add(PlaceholderParsers.CURRENT_WORLD, k -> new SpongePlaceholderParserBuilder().parser(placeholderText -> Component.text(placeholderText.associatedObject().filter(x -> x instanceof Locatable).map(x -> ((Locatable) x).serverLocation().worldKey()).orElseGet(() -> Sponge.server().worldManager().defaultWorld().key()).toString())).build());
l.add(PlaceholderParsers.NAME, k -> new SpongePlaceholderParserBuilder().parser(placeholderText -> placeholderText.associatedObject().filter(x -> x instanceof Nameable).map(x -> Component.text(((Nameable) x).name())).orElse(Component.empty())).build());
});
}
Aggregations