Interface GeyserConnection
- All Superinterfaces:
CommandSource,org.geysermc.api.connection.Connection
Represents a player connection used in Geyser.
-
Method Summary
Modifier and TypeMethodDescription@NonNull CameraDatacamera()Exposes theCameraDatafor this connection.voidCloses the currently open form on the client.@NonNull EntityDataentities()Exposes theEntityDatafor this connection.@NonNull CompletableFuture<@Nullable GeyserEntity>entityByJavaId(@org.checkerframework.checker.index.qual.NonNegative int javaId) Deprecated.Deprecated.UseCameraData.fogEffects()instead.boolean@NonNull StringGets the hostname or ip address the player used to join this Geyser instance.@org.checkerframework.checker.index.qual.Positive intjoinPort()Gets the port the player used to join this Geyser instance.voidAttempts to open theminecraft:pause_screen_additionsdialog tag.voidAttempts to open theminecraft:quick_actionsdialog tag.intping()Returns the current ping of the connection.@NonNull GeyserPlayerEntityReturns the associated player entity for this connection.@NonNull StringThe PlayFab ID of this player.intGets the Bedrock protocol version of the player.voidDeprecated.UseCameraData.removeFog(String...)instead.voidRequests an offhand swap from the Java server.voidsendCommand(String command) Sends a command as if the player had executed it.voidDeprecated.UseCameraData.sendFog(String...)instead.voidApplies a skin to a player seen by this Geyser connection.voidshakeCamera(float intensity, float duration, @NonNull CameraShake type) Deprecated.UseCameraData.shakeCamera(float, float, CameraShake)instead.voidshowEmote(@NonNull GeyserPlayerEntity emoter, @NonNull String emoteId) Displays a player entity as emoting to this client.voidDeprecated.UseCameraData.stopCameraShake()instead.Methods inherited from interface org.geysermc.geyser.api.command.CommandSource
connection, hasPermission, isConsole, locale, name, playerUuid, sendMessage, sendMessageMethods inherited from interface org.geysermc.api.connection.Connection
bedrockUsername, inputMode, isLinked, javaUsername, javaUuid, languageCode, platform, sendForm, sendForm, transfer, uiProfile, version, xuid
-
Method Details
-
camera
@NonNull CameraData camera()Exposes theCameraDatafor this connection. It allows you to send fogs, camera shakes, force camera perspectives, and more.- Returns:
- the CameraData for this connection.
-
entities
@NonNull EntityData entities()Exposes theEntityDatafor this connection. It allows you to get entities by their Java entity ID, show emotes, and get the player entity.- Returns:
- the EntityData for this connection.
-
ping
int ping()Returns the current ping of the connection. -
hasFormOpen
boolean hasFormOpen()- Returns:
trueif the client currently has a form open.- Since:
- 2.8.0
-
closeForm
void closeForm()Closes the currently open form on the client. -
protocolVersion
int protocolVersion()Gets the Bedrock protocol version of the player. -
openPauseScreenAdditions
void openPauseScreenAdditions()Attempts to open theminecraft:pause_screen_additionsdialog tag. This method opens this dialog the same way Java does, that is:- If there are multiple dialogs in the additions tag, the
minecraft:custom_optionsdialog is opened to select a dialog. - If there is one dialog in the additions tag, that dialog is opened.
- If there are no dialogs in the tag, but there are server links sent to the client, the
minecraft:server_linksdialog is opened. - If all of the above fails, no dialog is opened.
Use
hasFormOpen()to check if a dialog was opened.- Since:
- 2.8.0
- If there are multiple dialogs in the additions tag, the
-
openQuickActions
void openQuickActions()Attempts to open theminecraft:quick_actionsdialog tag. This method opens this dialog the same way Java does, that is:- If there are multiple dialogs in the actions tag, the
minecraft:quick_actionsdialog is opened to select a dialog. - If there is one dialog in the actions tag, that dialog is opened.
- If there are no dialogs in the tag, no dialog is opened.
Use
hasFormOpen()to check if a dialog was opened.- Since:
- 2.8.0
- If there are multiple dialogs in the actions tag, the
-
sendCommand
Sends a command as if the player had executed it.- Parameters:
command- the command without the leading forward-slash- Since:
- 2.8.0
-
joinAddress
@NonNull String joinAddress()Gets the hostname or ip address the player used to join this Geyser instance. Example:-
test.geysermc.org -
127.0.0.1 -
06e9:c755:4eff:5f13:9b4c:4b21:9df2:6a73
- Returns:
- the ip address or hostname string the player used to join
- Throws:
NoSuchElementException- if called before the session is fully initialized- Since:
- 2.8.3
-
-
joinPort
@org.checkerframework.checker.index.qual.Positive int joinPort()Gets the port the player used to join this Geyser instance. Example:-
19132 -
2202
- Returns:
- the port the player used to join
- Throws:
NoSuchElementException- if called before the session is fully initialized- Since:
- 2.8.3
-
-
sendSkin
Applies a skin to a player seen by this Geyser connection. If the uuid matches theConnection.javaUuid(), this will update the skin of this Geyser connection. If the player uuid provided is not known to this connection, this method will silently return.- Parameters:
player- which player this skin should be applied toskinData- the skin data to apply- Since:
- 2.8.3
-
entityByJavaId
@Deprecated @NonNull CompletableFuture<@Nullable GeyserEntity> entityByJavaId(@org.checkerframework.checker.index.qual.NonNegative int javaId) Deprecated.UseEntityData.entityByJavaId(int)instead- Parameters:
javaId- the Java entity ID to look up.- Returns:
- a
GeyserEntityif present in this connection's entity tracker.
-
showEmote
Displays a player entity as emoting to this client.- Parameters:
emoter- the player entity emoting.emoteId- the emote ID to send to this client.
-
shakeCamera
Deprecated.UseCameraData.shakeCamera(float, float, CameraShake)instead.Shakes the client's camera.If the camera is already shaking with the same
CameraShaketype, then the additional intensity will be layered on top of the existing intensity, with their own distinct durations.
If the existing shake type is different and the new intensity/duration are not positive, the existing shake only switches to the new type. Otherwise, the existing shake is completely overridden.- Parameters:
intensity- the intensity of the shake. The client has a maximum total intensity of 4.duration- the time in seconds that the shake will occur fortype- the type of shake
-
stopCameraShake
Deprecated.UseCameraData.stopCameraShake()instead.Stops all camera shake of any type. -
sendFog
Deprecated.UseCameraData.sendFog(String...)instead.Adds the given fog IDs to the fog cache, then sends all fog IDs in the cache to the client.Fog IDs can be found here
- Parameters:
fogNameSpaces- the fog IDs to add. If empty, the existing cached IDs will still be sent.
-
removeFog
Deprecated.UseCameraData.removeFog(String...)instead.Removes the given fog IDs from the fog cache, then sends all fog IDs in the cache to the client.- Parameters:
fogNameSpaces- the fog IDs to remove. If empty, all fog IDs will be removed.
-
fogEffects
Deprecated.UseCameraData.fogEffects()instead.Returns an immutable copy of all fog affects currently applied to this client. -
playerEntity
@NonNull GeyserPlayerEntity playerEntity()Returns the associated player entity for this connection.- Returns:
- the
GeyserPlayerEntityfor this connection - Since:
- 2.9.3
-
requestOffhandSwap
void requestOffhandSwap()Requests an offhand swap from the Java server. There is no guarantee of the server accepting the request.- Since:
- 2.9.3
-
playFabId
@NonNull String playFabId()The PlayFab ID of this player.- Since:
- 2.9.4
-
EntityData.entityByJavaId(int)instead