Interface Player
- All Superinterfaces:
Audience,ChannelMessageSink,ChannelMessageSource,CommandSource,HoverEventSource<HoverEvent.ShowEntity>,Identified,InboundConnection,Keyed,KeyIdentifiable,PermissionSubject,Pointered,Sound.Emitter
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddCustomChatCompletions(@NotNull Collection<String> completions) Add custom chat completion suggestions shown to the player while typing a message.default @NotNull HoverEvent<HoverEvent.ShowEntity>asHoverEvent(@NotNull UnaryOperator<HoverEvent.ShowEntity> op) default voidDeprecated.voidClears the player list header and footer.default voidThis method is not currently implemented in Velocity and will not perform any actions.Creates a new connection request so that the player can connect to another server.voiddisconnect(Component reason) Disconnects the player with the specified reason.@Nullable ResourcePackInfoDeprecated.@NotNull Collection<ResourcePackInfo>Gets theResourcePackInfoof the currently applied resource-packs.@Nullable StringGets the player's client brand.Returns the server that the player is currently connected to.@Nullable LocaleReturns the locale the proxy will use to send messages translated via the Adventure global translator.Returns the player's game profile.Gets the player's profile properties.Returns the player's mod info if they have a modded client.@Nullable ResourcePackInfoDeprecated.@NotNull Collection<ResourcePackInfo>Gets theResourcePackInfoof the resource packs the user is currently downloading or is currently prompted to install.longgetPing()Gets the player's estimated ping in milliseconds.Returns the player's player list footer.Returns the player's player list header.Returns the player's client settings.Returns the player's tab list.Returns the player's UUID.Returns the player's current username.booleanReturns whether the player has sent its client settings.booleanReturns the player's connection status.default @NotNull Keykey()default voidThis method is not currently implemented in Velocity and will not perform any actions.default voiddefault voiddefault voidplaySound(@NotNull Sound sound, Sound.Emitter emitter) voidremoveCustomChatCompletions(@NotNull Collection<String> completions) Remove custom chat completion suggestions shown to the player while typing a message.voidrequestCookie(Key key) Requests a previously stored cookie from the player's client.booleansendPluginMessage(@NotNull ChannelIdentifier identifier, byte @NotNull [] data) Sends a plugin message to this target.booleansendPluginMessage(@NotNull ChannelIdentifier identifier, @NotNull PluginMessageEncoder dataEncoder) Sends a plugin message to this target.voidsendResourcePack(String url) Deprecated.UsesendResourcePackOffer(ResourcePackInfo)insteadvoidsendResourcePack(String url, byte[] hash) Deprecated.UsesendResourcePackOffer(ResourcePackInfo)insteadvoidsendResourcePackOffer(ResourcePackInfo packInfo) Queues and sends a new Resource-pack offer to the player.voidsetCustomChatCompletions(@NotNull Collection<String> completions) Set the list of chat completion suggestions shown to the player while typing a message.voidsetEffectiveLocale(Locale locale) Change the locale the proxy will be translating its messages to.voidsetGameProfileProperties(List<GameProfile.Property> properties) Sets the player's profile properties.voidsetServerLinks(@NotNull List<ServerLink> links) Send the player a list of custom links to display in their client's pause menu.default voidshowDialog(@NotNull DialogLike dialog) This method is not currently implemented in Velocity and will not perform any actions.voidspoofChatInput(String input) Sends chat input onto the players current server as if they typed it into the client chat box.default voidvoidstoreCookie(Key key, byte[] data) Stores a cookie with arbitrary data on the player's client.voidtransferToHost(@NotNull InetSocketAddress address) Transfers a Player to a host.Methods inherited from interface net.kyori.adventure.audience.Audience
clearResourcePacks, clearTitle, deleteMessage, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, removeResourcePacks, removeResourcePacks, removeResourcePacks, removeResourcePacks, removeResourcePacks, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, sendResourcePacks, sendTitlePart, showBossBar, showTitle, stopSoundMethods inherited from interface com.velocitypowered.api.command.CommandSource
sendPlainMessage, sendRichMessage, sendRichMessageMethods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEventMethods inherited from interface net.kyori.adventure.identity.Identified
identityMethods inherited from interface com.velocitypowered.api.proxy.InboundConnection
getHandshakeIntent, getProtocolState, getProtocolVersion, getRawVirtualHost, getRemoteAddress, getVirtualHost, isActiveMethods inherited from interface com.velocitypowered.api.proxy.crypto.KeyIdentifiable
getIdentifiedKeyMethods inherited from interface com.velocitypowered.api.permission.PermissionSubject
getPermissionChecker, getPermissionValue, hasPermissionMethods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom, pointers
-
Method Details
-
getUsername
String getUsername()Returns the player's current username.- Returns:
- the username
-
getEffectiveLocale
@Nullable Locale getEffectiveLocale()Returns the locale the proxy will use to send messages translated via the Adventure global translator. By default, the value ofPlayerSettings.getLocale()is used.This can be
nullwhen the client has not yet connected to any server.- Returns:
- the locale.
-
setEffectiveLocale
Change the locale the proxy will be translating its messages to.- Parameters:
locale- the locale to translate to
-
getUniqueId
UUID getUniqueId()Returns the player's UUID.- Returns:
- the UUID
-
getCurrentServer
Optional<ServerConnection> getCurrentServer()Returns the server that the player is currently connected to.- Returns:
- an
Optionalthe server that the player is connected to, which may be empty
-
getPlayerSettings
PlayerSettings getPlayerSettings()Returns the player's client settings.- Returns:
- the settings
-
hasSentPlayerSettings
boolean hasSentPlayerSettings()Returns whether the player has sent its client settings.- Returns:
- true if the player has sent its client settings
-
getModInfo
Returns the player's mod info if they have a modded client.- Returns:
- an
Optionalthe mod info. which may be empty
-
getPing
long getPing()Gets the player's estimated ping in milliseconds.- Returns:
- the player's ping or -1 if ping information is currently unknown
-
isOnlineMode
boolean isOnlineMode()Returns the player's connection status.- Returns:
- true if the player is authenticated with Mojang servers
-
createConnectionRequest
Creates a new connection request so that the player can connect to another server.- Parameters:
server- the server to connect to- Returns:
- a new connection request
-
getGameProfileProperties
List<GameProfile.Property> getGameProfileProperties()Gets the player's profile properties.The returned list may be unmodifiable.
- Returns:
- the player's profile properties
-
setGameProfileProperties
Sets the player's profile properties.- Parameters:
properties- the properties
-
getGameProfile
GameProfile getGameProfile()Returns the player's game profile. -
getPlayerListHeader
Component getPlayerListHeader()Returns the player's player list header.- Returns:
- this player's player list header
-
getTabList
TabList getTabList()Returns the player's tab list.- Returns:
- this player's tab list
-
disconnect
Disconnects the player with the specified reason. Once this method is called, further calls to otherPlayermethods will become undefined.- Parameters:
reason- component with the reason
-
spoofChatInput
Sends chat input onto the players current server as if they typed it into the client chat box.- Parameters:
input- the chat input to send
-
sendResourcePack
Deprecated.UsesendResourcePackOffer(ResourcePackInfo)insteadSends the specified resource pack fromurlto the user. If at all possible, send the resource pack usingsendResourcePack(String, byte[]). To monitor the status of the sent resource pack, subscribe toPlayerResourcePackStatusEvent.- Parameters:
url- the URL for the resource pack
-
sendResourcePack
Deprecated.UsesendResourcePackOffer(ResourcePackInfo)insteadSends the specified resource pack fromurlto the user, using the specified 20-byte SHA-1 hash. To monitor the status of the sent resource pack, subscribe toPlayerResourcePackStatusEvent.- Parameters:
url- the URL for the resource packhash- the SHA-1 hash value for the resource pack
-
sendResourcePackOffer
Queues and sends a new Resource-pack offer to the player. To monitor the status of the sent resource pack, subscribe toPlayerResourcePackStatusEvent. To create aResourcePackInfouse theProxyServer.createResourcePackBuilder(String)builder.- Parameters:
packInfo- the resource-pack in question
-
getAppliedResourcePack
Deprecated.Gets theResourcePackInfoof the currently applied resource-pack or null if none.Note that since 1.20.3 it is no longer recommended to use this method as it will only return the last applied resource pack. To get all applied resource packs, use
getAppliedResourcePacks()instead.- Returns:
- the applied resource pack or null if none.
-
getPendingResourcePack
Deprecated.Gets theResourcePackInfoof the resource pack the user is currently downloading or is currently prompted to install or null if none.Note that since 1.20.3 it is no longer recommended to use this method as it will only return the last pending resource pack. To get all pending resource packs, use
getPendingResourcePacks()instead.- Returns:
- the pending resource pack or null if none
-
getAppliedResourcePacks
Gets theResourcePackInfoof the currently applied resource-packs.- Returns:
- collection of the applied resource packs.
-
getPendingResourcePacks
Gets theResourcePackInfoof the resource packs the user is currently downloading or is currently prompted to install.- Returns:
- collection of the pending resource packs
-
sendPluginMessage
Sends a plugin message to this target.Note that this method does not send a plugin message to the server the player is connected to. You should only use this method if you are trying to communicate with a mod that is installed on the player's client.
To send a plugin message to the server from the player, you should use the equivalent method on the instance returned by
getCurrentServer().final ChannelIdentifier identifier; final Player player; player.getCurrentServer() .map(ServerConnection::getServer) .ifPresent((RegisteredServer server) -> { server.sendPluginMessage(identifier, data); });- Specified by:
sendPluginMessagein interfaceChannelMessageSink- Parameters:
identifier- the channel identifier to send the message ondata- the data to send- Returns:
- whether or not the message could be sent
-
sendPluginMessage
boolean sendPluginMessage(@NotNull @NotNull ChannelIdentifier identifier, @NotNull @NotNull PluginMessageEncoder dataEncoder) Sends a plugin message to this target.final ChannelMessageSink target; final ChannelIdentifier identifier; final boolean result = target.sendPluginMessage(identifier, (output) -> { output.writeUTF("some input"); output.writeInt(1); });Note that this method does not send a plugin message to the server the player is connected to. You should only use this method if you are trying to communicate with a mod that is installed on the player's client.
To send a plugin message to the server from the player, you should use the equivalent method on the instance returned by
getCurrentServer().- Specified by:
sendPluginMessagein interfaceChannelMessageSink- Parameters:
identifier- the channel identifier to send the message ondataEncoder- the encoder of the data to be sent- Returns:
- whether the message could be sent
-
key
-
asHoverEvent
@NotNull default @NotNull HoverEvent<HoverEvent.ShowEntity> asHoverEvent(@NotNull @NotNull UnaryOperator<HoverEvent.ShowEntity> op) - Specified by:
asHoverEventin interfaceHoverEventSource<HoverEvent.ShowEntity>
-
getClientBrand
@Nullable String getClientBrand()Gets the player's client brand.- Returns:
- the player's client brand
-
addCustomChatCompletions
Add custom chat completion suggestions shown to the player while typing a message.- Parameters:
completions- the completions to send
-
removeCustomChatCompletions
Remove custom chat completion suggestions shown to the player while typing a message.Online player names can't be removed with this method, it will only affect custom completions added by
addCustomChatCompletions(Collection)orsetCustomChatCompletions(Collection).- Parameters:
completions- the completions to remove
-
setCustomChatCompletions
Set the list of chat completion suggestions shown to the player while typing a message.If completions were set previously, this method will remove them all and replace them with the provided completions.
- Parameters:
completions- the completions to set
-
playSound
-
playSound
-
playSound
Note: Due to MC-146721, stereo sounds are always played globally in 1.14+.
Note: Due to MC-138832, the volume and pitch are ignored when using this method in 1.14 to 1.16.5.
- Specified by:
playSoundin interfaceAudience- Parameters:
sound- the sound to playemitter- the emitter of the sound; may be another player of this player's server- Since:
- 3.4.0
- API Note:
- This method is currently only implemented for players on 1.19.3+
and requires a present
getCurrentServer()for the emitting player as well as this player. - Since Minecraft:
- 1.19.3
-
stopSound
-
openBook
This method is not currently implemented in Velocity and will not perform any actions. -
showDialog
This method is not currently implemented in Velocity and will not perform any actions.- Specified by:
showDialogin interfaceAudience- See Also:
-
closeDialog
default void closeDialog()This method is not currently implemented in Velocity and will not perform any actions.- Specified by:
closeDialogin interfaceAudience- See Also:
-
transferToHost
Transfers a Player to a host.- Parameters:
address- the host address- Throws:
IllegalArgumentException- if the player is from a version lower than 1.20.5- Since:
- 3.3.0
-
storeCookie
Stores a cookie with arbitrary data on the player's client.- Parameters:
key- the identifier of the cookiedata- the data of the cookie- Throws:
IllegalArgumentException- if the player is from a version lower than 1.20.5- Since:
- 3.3.0
- Since Minecraft:
- 1.20.5
-
requestCookie
Requests a previously stored cookie from the player's client. Calling this method causes the client to send the cookie to the proxy. To retrieve the actual data of the requested cookie, you have to use theCookieReceiveEvent.- Parameters:
key- the identifier of the cookie- Throws:
IllegalArgumentException- if the player is from a version lower than 1.20.5- Since:
- 3.3.0
- Since Minecraft:
- 1.20.5
-
setServerLinks
Send the player a list of custom links to display in their client's pause menu.Note that later packets sent by the backend server may override links sent by the proxy.
- Parameters:
links- an ordered list ofServerLinks to send to the player- Throws:
IllegalArgumentException- if the player is from a version lower than 1.21- Since:
- 3.3.0
- Since Minecraft:
- 1.21
-
clearPlayerListHeaderAndFooter().