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
Command Permissions
Control who can use commands with setPermissionGroup() using GameMode enum.
Example Code
// In command constructor:
// Anyone can use (default for most commands)
this.setPermissionGroup(GameMode.Adventure);
// Only creative/elevated users
this.setPermissionGroup(GameMode.Creative);
// Only spectators/admins
this.setPermissionGroup(GameMode.Spectator);
// Or check permissions manually in execute:
if (!PermissionsModule.hasPermission(player.getUuid(), "myplugin.admin")) {
ctx.sendMessage(Message.raw("No permission!"));
return;
}
Common Mistakes
Not setting any permission group (defaults to most restrictive).