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
gui
Native UI File Setup
Set up native .ui files for custom UI pages. Files must be in Common/UI/Custom/Pages/ in JAR but referenced as Pages/ in Java code. Requires IncludesAssetPack in manifest.
Example Code
// Directory structure in your plugin:
// src/main/resources/
// ├── manifest.json (with "IncludesAssetPack": true)
// └── Common/
// └── UI/
// └── Custom/
// └── Pages/
// └── MyPage.ui
// In your Java code, reference as:
uiCommandBuilder.append("Pages/MyPage.ui");
// Basic .ui file structure (MyPage.ui):
$C = "../Common.ui";
$C.@PageOverlay {
$C.@DecoratedContainer {
Anchor: (Width: 400, Height: 200);
#Title {
Group {
$C.@Title {
@Text = "MY TITLE";
}
}
}
#Content {
LayoutMode: Top;
Padding: (Left: 20, Right: 20, Top: 10, Bottom: 10);
Label #MyLabel {
Anchor: ();
Style: (
FontSize: 18,
TextColor: #ffffff,
HorizontalAlignment: Center,
VerticalAlignment: Center
);
Text: "Hello World!";
}
}
}
}
Thread Safety
UI build() runs on world thread.
Common Mistakes
Using Alignment: MiddleCenter instead of HorizontalAlignment/VerticalAlignment. Forgetting IncludesAssetPack in manifest. Wrong directory structure (must be Common/UI/Custom/Pages/ in JAR). Not adding Common/**/* to pom.xml resources.