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
command
Sync Command
Create a synchronous command using CommandBase. Runs on main thread, good for simple commands that need immediate world access.
Example Code
public class TestCommand extends CommandBase {
public TestCommand() {
super("test", "A test command");
this.setPermissionGroup(GameMode.Adventure); // Anyone can use
}
@Override
protected void executeSync(@Nonnull CommandContext ctx) {
ctx.sendMessage(Message.raw("Hello from sync command!"));
}
}
Thread Safety
executeSync runs on main thread - safe for direct world/entity access without world.execute().
Common Mistakes
Using executeSync for long operations - this blocks the main thread.