Code Patterns
Copy-paste examples for common plugin tasks. Commands, events, ECS, GUI, and more.
All
225
Command
60
Damage
2
Ecs
27
Entity
5
Gui
75
Interaction
2
Inventory
4
Moderation
3
Permission
2
Player
9
Plugin
4
Storage
2
Teleport
3
Ui
22
Util
5
← Back to Patterns
java
ui
ui-basic-page
Simplest Custom UI Page pattern using BasicCustomUIPage. Use this for static, non-interactive UI displays that just show information without any buttons or inputs.
Example Code
// HelloWorldPage.ui - The UI layout file
Group {
Anchor: (Width: 400, Height: 250);
Background: #1a1a2e(0.95);
LayoutMode: Top;
Padding: (Full: 20);
Label #Title {
Text: "Hello World";
Anchor: (Height: 40);
Style: (FontSize: 24, TextColor: #ffffff, Alignment: Center);
}
}
// HelloWorldPage.java - The page class
public class HelloWorldPage extends BasicCustomUIPage {
public HelloWorldPage(@Nonnull PlayerRef playerRef, @Nonnull CustomPageLifetime lifetime) {
super(playerRef, lifetime);
}
@Override
public void build(UICommandBuilder uiCommandBuilder) {
// Load the UI layout from resources
uiCommandBuilder.append("Pages/HelloWorldPage.ui");
}
}
// Opening the page from a command:
Player player = store.getComponent(ref, Player.getComponentType());
player.getPageManager().setPage(ref, store,
new HelloWorldPage(playerRef, CustomPageLifetime.CanDismissOrCloseThroughInteraction));
Thread Safety
BasicCustomUIPage is safe for single-player UI operations
Common Mistakes
Using BasicCustomUIPage for interactive UIs - use InteractiveCustomUIPage instead when you need button clicks or input handling