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.
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 goalsToast.Style.TASK- Yellow background, for tasksToast.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)private final org.bukkit.NamespacedKeyUnique key for this advancement, auto-generated UUIDprivate final StringThe toast message, use "|" for line breaksprivate 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 -
icon
The Minecraft item ID for the icon (without "minecraft:" prefix) -
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.- Parameters:
icon- the Minecraft item ID for the iconmessage- the toast messagestyle- 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.
- Parameters:
player- the target playericon- the Minecraft item ID for the icon (e.g., "diamond", "emerald")message- the toast message, use "|" for line breaksstyle- the visual style of the toast
-