Interface PlayerAbilities
public sealed interface PlayerAbilities
The movement abilities of a player that persist across sessions.
- Since:
- 0.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PlayerAbilitiesDefault values for theGameMode.SURVIVALgame mode; not allowed to fly with default speeds. -
Method Summary
Modifier and TypeMethodDescriptionstatic PlayerAbilitiesabilities(boolean flightAllowed, boolean flying, float flySpeed, float walkSpeed) Creates abilities.booleanReturns whether the player may fly; reset to the game mode's default when the game mode changes.booleanflying()Returns whether the player is flying; nevertrueunlessflightAllowed().floatflySpeed()Returns the flying speed,0.05by default.floatReturns the walking speed, which becomes the base of the player's movement speed attribute,0.1by default.withFlightAllowed(boolean flightAllowed) withFlying(boolean flying) withFlySpeed(float flySpeed) withWalkSpeed(float walkSpeed)
-
Field Details
-
DEFAULT
Default values for theGameMode.SURVIVALgame mode; not allowed to fly with default speeds.- Since:
- 0.1.0
-
-
Method Details
-
abilities
@Contract(value="_, _, _, _ -> new", pure=true) static PlayerAbilities abilities(boolean flightAllowed, boolean flying, float flySpeed, float walkSpeed) Creates abilities.- Parameters:
flightAllowed- whether the player is allowed to flyflying- whether the player is flyingflySpeed- the flying speedwalkSpeed- the walking speed- Returns:
- the abilities
- Throws:
IllegalArgumentException- if a speed is not finite- Since:
- 0.1.0
-
flightAllowed
-
flying
Returns whether the player is flying; nevertrueunlessflightAllowed().- Returns:
- whether the player is flying; never
trueunlessflightAllowed() - Since:
- 0.1.0
-
flySpeed
-
walkSpeed
-
withFlightAllowed
- Parameters:
flightAllowed- whether the player is allowed to fly; disallowing it also stops flight- Returns:
- a copy with the given flight permission
- Since:
- 0.1.0
-
withFlying
- Parameters:
flying- whether the player is flying; ignored unlessflightAllowed()- Returns:
- a copy with the given flying state
- Since:
- 0.1.0
-
withFlySpeed
- Parameters:
flySpeed- the flying speed- Returns:
- a copy with the given flying speed
- Throws:
IllegalArgumentException- ifflySpeedis not finite- Since:
- 0.1.0
-
withWalkSpeed
- Parameters:
walkSpeed- the walking speed- Returns:
- a copy with the given walking speed
- Throws:
IllegalArgumentException- ifwalkSpeedis not finite- Since:
- 0.1.0
-