Package com.ultikits.ultitools.widgets
Class Toast
java.lang.Object
com.ultikits.ultitools.widgets.Toast
A Minecraft advancement toast notification widget.
Creates temporary advancement toast notifications that appear in the top-right corner of the player's screen. Uses dynamic advancement creation and auto-cleanup.
Minecraft 成就提示通知组件。 创建临时的成就提示通知,显示在玩家屏幕右上角。 使用动态成就创建和自动清理机制。
Example Usage / 使用示例:
// Display a goal-style toast / 显示目标样式提示
Toast.displayTo(player, "diamond", "You found a diamond!", Toast.Style.GOAL);
// Display a task-style toast / 显示任务样式提示
Toast.displayTo(player, "emerald", "Trade completed!", Toast.Style.TASK);
// Multi-line message using | separator / 使用 | 分隔符显示多行消息
Toast.displayTo(player, "gold_ingot", "Welcome!|Enjoy your stay!", Toast.Style.CHALLENGE);
Toast Styles / 提示样式:
Toast.Style.GOAL- Green background, for completed goals / 绿色背景,用于完成目标Toast.Style.TASK- Yellow background, for tasks / 黄色背景,用于任务Toast.Style.CHALLENGE- Purple background, for challenges / 紫色背景,用于挑战
- Since:
- 6.0.0
- Author:
- wisdomme
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumToast display styles based on Minecraft advancement frame types. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe Minecraft item ID for the icon (without "minecraft:" prefix) / 图标的 Minecraft 物品 ID(不含 "minecraft:" 前缀)private final org.bukkit.NamespacedKeyUnique key for this advancement, auto-generated UUID / 此成就的唯一键,自动生成 UUIDprivate final StringThe toast message, use "|" for line breaks / 提示消息,使用 "|" 换行private final Toast.StyleThe visual style of the toast / 提示的视觉样式 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateToast(String icon, String message, Toast.Style style) Private constructor - usedisplayTo(Player, String, String, Style)instead. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidstatic voiddisplayTo(org.bukkit.entity.Player player, String icon, String message, Toast.Style style) Displays a toast notification to the specified player.private voidgrantAdvancement(org.bukkit.entity.Player player) private voidrevokeAdvancement(org.bukkit.entity.Player player) private voidstart(org.bukkit.entity.Player player)
-
Field Details
-
key
private final org.bukkit.NamespacedKey keyUnique key for this advancement, auto-generated UUID / 此成就的唯一键,自动生成 UUID -
icon
The Minecraft item ID for the icon (without "minecraft:" prefix) / 图标的 Minecraft 物品 ID(不含 "minecraft:" 前缀) -
message
The toast message, use "|" for line breaks / 提示消息,使用 "|" 换行 -
style
The visual style of the toast / 提示的视觉样式
-
-
Constructor Details
-
Toast
Private constructor - usedisplayTo(Player, String, String, Style)instead.
私有构造函数 - 请使用displayTo(Player, String, String, Style)代替。- Parameters:
icon- the Minecraft item ID for the icon / 图标的 Minecraft 物品 IDmessage- the toast message / 提示消息style- the visual style / 视觉样式
-
-
Method Details
-
start
private void start(org.bukkit.entity.Player player) -
createAdvancement
private void createAdvancement() -
grantAdvancement
private void grantAdvancement(org.bukkit.entity.Player player) -
revokeAdvancement
private void revokeAdvancement(org.bukkit.entity.Player player) -
displayTo
public static void displayTo(org.bukkit.entity.Player player, String icon, String message, Toast.Style style) Displays a toast notification to the specified player.The toast will automatically be revoked after 10 ticks (0.5 seconds) to clean up the temporary advancement.
向指定玩家显示提示通知。 提示将在 10 tick(0.5 秒)后自动撤销,以清理临时成就。
- Parameters:
player- the target player / 目标玩家icon- the Minecraft item ID for the icon (e.g., "diamond", "emerald") 图标的 Minecraft 物品 ID(如 "diamond"、"emerald")message- the toast message, use "|" for line breaks 提示消息,使用 "|" 换行style- the visual style of the toast / 提示的视觉样式
-