Package com.velocitypowered.api.proxy
Interface Player
-
- All Superinterfaces:
Audience,ChannelMessageSink,ChannelMessageSource,CommandSource,HoverEventSource<HoverEvent.ShowEntity>,Identified,InboundConnection,net.kyori.adventure.key.Keyed,KeyIdentifiable,PermissionSubject,Pointered
public interface Player extends CommandSource, InboundConnection, ChannelMessageSource, ChannelMessageSink, Identified, HoverEventSource<HoverEvent.ShowEntity>, net.kyori.adventure.key.Keyed, KeyIdentifiable
Represents a player who is connected to the proxy.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default @NotNull HoverEvent<HoverEvent.ShowEntity>asHoverEvent(@NotNull UnaryOperator<HoverEvent.ShowEntity> op)voidclearHeaderAndFooter()Deprecated.ConnectionRequestBuildercreateConnectionRequest(RegisteredServer server)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 ResourcePackInfogetAppliedResourcePack()Gets theResourcePackInfoof the currently applied resource-pack or null if none.@Nullable StringgetClientBrand()Gets the player's client brand.Optional<ServerConnection>getCurrentServer()Returns the server that the player is currently connected to.@Nullable LocalegetEffectiveLocale()Returns the locale the proxy will use to send messages translated via the Adventure global translator.GameProfilegetGameProfile()Returns the player's game profile.List<GameProfile.Property>getGameProfileProperties()Gets the player's profile properties.Optional<ModInfo>getModInfo()Returns the player's mod info if they have a modded client.@Nullable ResourcePackInfogetPendingResourcePack()Gets theResourcePackInfoof the resource pack the user is currently downloading or is currently prompted to install or null if none.longgetPing()Gets the player's estimated ping in milliseconds.ComponentgetPlayerListFooter()Returns the player's player list footer.ComponentgetPlayerListHeader()Returns the player's player list header.PlayerSettingsgetPlayerSettings()Returns the player's client settings.TabListgetTabList()Returns the player's tab list.UUIDgetUniqueId()Returns the player's UUID.StringgetUsername()Returns the player's current username.booleanhasSentPlayerSettings()Returns whether the player has sent its client settings.booleanisOnlineMode()Returns the player's connection status.default @NotNull net.kyori.adventure.key.Keykey()booleansendPluginMessage(ChannelIdentifier identifier, byte[] data)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.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.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.voidspoofChatInput(String input)Sends chat input onto the players current server as if they typed it into the client chat box.-
Methods inherited from interface net.kyori.adventure.audience.Audience
clearTitle, deleteMessage, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, openBook, playSound, playSound, playSound, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, showTitle, stopSound, stopSound
-
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
-
Methods inherited from interface net.kyori.adventure.identity.Identified
identity
-
Methods inherited from interface com.velocitypowered.api.proxy.InboundConnection
getProtocolVersion, getRemoteAddress, getVirtualHost, isActive
-
Methods inherited from interface com.velocitypowered.api.proxy.crypto.KeyIdentifiable
getIdentifiedKey
-
Methods inherited from interface com.velocitypowered.api.permission.PermissionSubject
getPermissionChecker, getPermissionValue, hasPermission
-
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom, pointers
-
-
-
-
Method Detail
-
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
void setEffectiveLocale(Locale locale)
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
Optional<ModInfo> 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
ConnectionRequestBuilder createConnectionRequest(RegisteredServer server)
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
void setGameProfileProperties(List<GameProfile.Property> properties)
Sets the player's profile properties.- Parameters:
properties- the properties
-
getGameProfile
GameProfile getGameProfile()
Returns the player's game profile.
-
clearHeaderAndFooter
@Deprecated void clearHeaderAndFooter()
Deprecated.Clears the tab list header and footer for the player.
-
getPlayerListHeader
Component getPlayerListHeader()
Returns the player's player list header.- Returns:
- this player's player list header
-
getPlayerListFooter
Component getPlayerListFooter()
Returns the player's player list footer.- Returns:
- this player's tab list
-
getTabList
TabList getTabList()
Returns the player's tab list.- Returns:
- this player's tab list
-
disconnect
void disconnect(Component reason)
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
void spoofChatInput(String input)
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 void sendResourcePack(String url)
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 void sendResourcePack(String url, byte[] hash)
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
void sendResourcePackOffer(ResourcePackInfo packInfo)
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
@Nullable ResourcePackInfo getAppliedResourcePack()
Gets theResourcePackInfoof the currently applied resource-pack or null if none.- Returns:
- the applied resource pack or null if none.
-
getPendingResourcePack
@Nullable ResourcePackInfo getPendingResourcePack()
Gets theResourcePackInfoof the resource pack the user is currently downloading or is currently prompted to install or null if none.- Returns:
- the pending resource pack or null if none
-
sendPluginMessage
boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data)
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 bygetCurrentServer().- 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
-
key
@NotNull default @NotNull net.kyori.adventure.key.Key key()
- Specified by:
keyin interfacenet.kyori.adventure.key.Keyed
-
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
-
-