MiniPlaceholders

适用于 Minecraft 平台的 MiniMessage 组件化占位符 API。

资源图片
# MiniPlaceholders [![WorkFlow](https://img.shields.io/github/actions/workflow/status/MiniPlaceholders/MiniPlaceholders/build.yml?style=flat-square)](https://github.com/MiniPlaceholders/MiniPlaceholders/actions) ![Latest Version](https://img.shields.io/github/v/release/MiniPlaceholders/MiniPlaceholders?style=flat-square) [![Discord](https://img.shields.io/discord/899740810956910683?color=7289da&logo=Discord&label=Discord&style=flat-square)](https://discord.gg/5NMMzK5mAn) ![Modrinth Downloads](https://img.shields.io/modrinth/dt/HQyibRsN?logo=Modrinth&style=flat-square) ![GitHub Downloads](https://img.shields.io/github/downloads/MiniPlaceholders/MiniPlaceholders/total?logo=GitHub&style=flat-square) MiniMessage 组件化占位符 API,用于 Minecraft 平台 ## 兼容性 - Paper 1.21+ - Velocity 3.4.0+ - Fabric 1.21.4+ - Sponge API 12+ [![](https://www.bisecthosting.com/partners/custom-banners/6fa909d5-ad2b-42c2-a7ec-1c51f8b6384f.webp)](https://www.bisecthosting.com/4drian3d) ## 用户用法 请查看我们的 [用户用法 Wiki](https://miniplaceholders.github.io/docs/user-guide/User-Getting-Started) ## API 请查看可用的 [Javadocs](https://javadoc.io/doc/io.github.miniplaceholders/miniplaceholders-api) 或者查看 [开发者 Wiki](https://miniplaceholders.github.io/docs/developer-guide/Developer-Getting-Started) ### Java ```java class Main { public static void registerExpansion() { final Expansion expansion = Expansion.builder("my-expansion") .audiencePlaceholder(Player.class, "name", (player, ctx, queue) -> { return Tag.selfClosingInserting(player.getName()); }) .globalPlaceholder("tps", (ctx, queue) -> Tag.selfClosingInserting(Component.text(Bukkit.getTps()[0])) ).build; expansion.register(); Player player; final TagResolver playerResolver = MiniPlaceholders.audiencePlaceholders(); player.sendMessage(miniMessage().deserialize("Player Name: ", player, playerResolver)); } } ``` ### Kotlin ```kotlin fun register() { val expansion = expansion("my-expansion") { audience("name") { aud, _, _ -> aud.getName().asClosingTag() } global("tps") { _, _ -> Component.text(Bukkit.getTps()[0]).asInsertingTag() } } expansion.register() val player: Player val playerResolver = MiniPlaceholders.audiencePlaceholders() player.sendMessage(miniMessage().deserialize("Player Name: ", player, playerResolver)) } ```