Code Patterns

Copy-paste examples for common plugin tasks. Commands, events, ECS, GUI, and more.

Command Patterns

60
Add Spawn Point Command

/add command using AbstractAsyncCommand

Async Command with GUI

Create async commands that open custom GUIs. Use CompletableFuture.runAsync with world executor.

Async Command with World Access

Pattern for async commands that need to access the world/ECS. Based on working AdminUI code.

Auto Save Interval Command

/autosave command using AbstractCommand

Change World Command

/changeworld command using CommandBase

Command

/admin command using AbstractAsyncCommand

Command Permissions

Control who can use commands with setPermissionGroup() using GameMode enum.

Command with All Argument Types

Use various argument types: STRING, INTEGER, DOUBLE, BOOLEAN, PLAYER_REF, WORLD, ITEM_ASSET, BLOCK_TYPE_KEY, GAME_MODE, etc.

Command with Arguments

Create a command with required and optional arguments using ArgTypes.

CommandContext Helpers

Useful helper methods on CommandContext for player commands.

Config Command

/config command using AbstractCommand

Debug Command

/debug command using AbstractCommand

Example Command

/test command using CommandBase

Finish Current Map Command

/finish command using AbstractAsyncCommand

Hide All Poi Command

/hidepois command using AbstractCommand

Hide Other Warps Command

/hidewarps command using AbstractCommand

Hide Players Command

/hideplayers command using AbstractCommand

Hide Unexplored Poi Command

/hideunexploredpoi command using AbstractCommand

Hide Unexplored Warps Command

/hideunexploredwarps command using AbstractCommand

Loot Command

/loot command using AbstractCommand

Loot Show Spawn Points Command

/show command using AbstractAsyncCommand

Loot Spawn Command

/spawn command using AbstractCommand

Map Command

/map command using AbstractCommand

Map Exploration Radius Command

/radius command using AbstractCommand

Map Max Scale Command

/maxscale command using AbstractCommand

Map Min Scale Command

/minscale command using AbstractCommand

Map Quality Command

/quality command using AbstractCommand

Map Vote Command

/vote command using CommandBase

Marker Teleport Command

/markerteleport command using AbstractCommand

Max Chunks To Load Command

/maxchunks command using AbstractCommand

Memory Debug Command

/memory command using CommandBase

Menu Command

/menu command using AbstractPlayerCommand

Player Command

Create a command that requires a player context. Extends AbstractPlayerCommand for automatic ECS parameter injection.

Player Location Command

/location command using AbstractCommand

Player Max Scale Command

/maxscale command using AbstractCommand

Player Min Scale Command

/minscale command using AbstractCommand

Radar Range Command

/radarrange command using AbstractCommand

Radar Toggle Command

/radar command using AbstractCommand

Register Command

Register a command in the plugin setup() method.

Reload Command

/reload command using AbstractCommand

Share All Exploration Command

/shareallexploration command using AbstractCommand

Shop

/shop command using CommandBase

Shortcut Command

/adminshortcut command using AbstractAsyncCommand

Show Spawn Points

/show command using AbstractAsyncCommand

Simple Command

Create a simple command using AbstractCommand. Best for server-wide commands or when you dont need ECS/player access. Supports async execution via CompletableFuture.

Spawn Command

/spawn command using AbstractCommand

Spectator Mode

/spectator command using CommandBase

Sync Command

Create a synchronous command using CommandBase. Runs on main thread, good for simple commands that need immediate world access.

Toggle Flight Command

Enable/disable player flight using MovementManager and MovementSettings. Based on working Simple Fly mod by davidhenk.

Track World Command

/track command using AbstractCommand

Traitor Chat Command

/t command using AbstractAsyncCommand

Untrack World Command

/untrack command using AbstractCommand

Waypoint Add Command

/add command using AbstractPlayerCommand

Waypoint Command

/waypoint command using AbstractCommand

Waypoint Delete Command

/remove command using AbstractPlayerCommand

Waypoint Delete Global Command

/removeglobal command using AbstractPlayerCommand

Waypoint Id Command

/id command using AbstractPlayerCommand

Waypoint List Command

/list command using AbstractPlayerCommand

Waypoint Teleport Command

/waypointteleport command using AbstractCommand

Waypoint Update Command

/update command using AbstractPlayerCommand