Overview
The/fly command allows players to toggle flight mode on and off. Flight state persists across sessions using player persistent data.
Syntax
Permission
Required to use the
/fly command.Default: opBehavior
The command toggles flight mode with the following logic:- Checks if flight is enabled in the plugin configuration
- Verifies the player has permission or is an operator
- Ignores spectator mode players (they can always fly)
- Reads the player’s current flight state from persistent data
- Toggles the flight state and saves it to persistent data
- Sends a confirmation message to the player
Flight States
- Enabled (1): Player can fly by double-jumping (similar to creative mode)
- Disabled (0): Player cannot fly and will fall if currently flying
Flight state is stored in the player’s persistent data container using the key
hubbly.canFly, meaning it persists across server restarts and world changes.Examples
Enabling flight:Flight mode enabled.
Disabling flight:
Flight mode disabled.
Configuration
Flight must be enabled in the plugin’sconfig.yml:
player.fly.enabled is set to false, the command will be disabled and players will receive:
Technical Details
Persistent Data Storage
The command uses Bukkit’sPersistentDataContainer API to store flight state:
- Key:
NamespacedKey(plugin, "fly") - Type:
PersistentDataType.BYTE - Values:
0= Flight disabled1= Flight enabled
Game Mode Restrictions
Players in spectator mode are ignored by this command as they have flight by default.
Players in creative mode already have flight. This command will update their persistent data but won’t affect their ability to fly.
Messages
All messages are defined inlanguages/en.yml and support localization:
| Message Key | Default Text | When Shown |
|---|---|---|
fly.enable | ”Flight mode enabled.” | When flight is turned on |
fly.disable | ”Flight mode disabled.” | When flight is turned off |
no_fly_enabled | ”Flight is disabled in config” | When flight is disabled in config |
no_permission_command | ”You do not have permission to use this command!” | When player lacks permission |
no_console | ”Only players can use this command!” | When used from console |
Permissions Summary
| Permission | Description | Default |
|---|---|---|
hubbly.command.fly | Use the /fly command | op |
hubbly.command.* | All command permissions | op |
Source Reference
Implemented in:FlyCommand.java:47- Flight toggle handler- Flight state is managed via Bukkit’s PersistentDataContainer API