Code Patterns
Copy-paste examples for common plugin tasks. Commands, events, ECS, GUI, and more.
Ui Patterns
22Use java.awt.Color for message colors. Available constants: RED, GREEN, BLUE, YELLOW, CYAN (not AQUA!), MAGENTA, WHITE, BLACK, GRAY, DARK_GRAY, LIGHT_GRAY, ORANGE, PINK.
Official Hytale UI: ActionButton - Container layout with buttons with text elements
Official Hytale UI: Common - Container layout with buttons with text elements
Official Hytale UI: Sounds with buttons
Official Hytale UI: TextButton with buttons with text elements
Official Hytale UI: TimeLeft
Helper for setting up navigation bar in custom UI pages with permission-filtered entries
Play sounds to players using SoundUtil.
Send item pickup-style notifications to players.
Display server statistics (CPU, RAM, uptime) in custom UI with auto-refresh
Searchable list UI with delete confirmation on hover pattern
Singleton registry for registering UI pages with navigation bar and command shortcuts
Simplest Custom UI Page pattern using BasicCustomUIPage. Use this for static, non-interactive UI displays that just show information without any buttons or inputs.
Define reusable button styles with hover and pressed states using TextButtonStyle. Styles are defined at the top of .ui files with @ prefix and referenced in TextButton elements.
Color formats and common styling properties for Hytale UI elements. Colors use hex format with optional alpha. Style properties control text appearance, alignment, and formatting.
Two-panel layout with sidebar navigation and main content area. Uses LayoutMode: Left for horizontal arrangement and FlexWeight for flexible sizing. Great for settings pages, dashboards, or info panels.
Pattern for passing dynamic data from Java to UI elements using cmd.set(). Pass data through constructor, store as fields, then use cmd.set("#ElementId.Property", value) in build() method.
Different event binding types for UI interactions. Activating is most common (button clicks), but other types exist for hover, focus changes, and value changes.
Form pattern with TextField, NumberField, and CheckBox inputs. Shows how to read input values using the @-prefix in EventData codec and binding input values to events.
Dialog pattern using InteractiveCustomUIPage with button click event handling. Demonstrates event binding, dynamic text setting with cmd.set(), and closing the page programmatically.
Understanding LayoutMode options for arranging child elements. Top = vertical stack, Left = horizontal row, Center = centered, Right = right-aligned. Combine with FlexWeight for responsive layouts.
CustomPageLifetime options control when and how a UI page can be closed. Choose based on whether the UI should be dismissible by ESC key, clicking outside, or only through explicit code.