Package com.velocitypowered.api.proxy
Interface Player
-
- All Superinterfaces:
Audience,ChannelMessageSink,ChannelMessageSource,CommandSource,Identified,InboundConnection,PermissionSubject
public interface Player extends CommandSource, Identified, InboundConnection, ChannelMessageSource, ChannelMessageSink
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 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.voiddisconnect(net.kyori.text.Component reason)Deprecated.Usedisconnect(Component)insteadOptional<ServerConnection>getCurrentServer()Returns the server that the player is currently connected to.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.longgetPing()Returns the current player's ping.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.booleanisOnlineMode()Returns the player's connection status.default voidsendMessage(net.kyori.text.Component component)Deprecated.voidsendMessage(net.kyori.text.Component component, MessagePosition position)Deprecated.Use @deprecated UseAudience.sendMessage(Identified, Component)orAudience.sendMessage(Identity, Component)for chat messages, orAudience.sendActionBar(net.kyori.adventure.text.Component)for action bar messagesvoidsendResourcePack(String url)Sends the specified resource pack fromurlto the user.voidsendResourcePack(String url, byte[] hash)Sends the specified resource pack fromurlto the user, using the specified 20-byte SHA-1 hash.voidsendTitle(Title title)Deprecated.voidsetGameProfileProperties(List<GameProfile.Property> properties)Sets the player's profile properties.voidsetHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer)Deprecated.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, hideBossBar, openBook, openBook, playSound, playSound, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, showBossBar, showTitle, stopSound
-
Methods inherited from interface com.velocitypowered.api.proxy.messages.ChannelMessageSink
sendPluginMessage
-
Methods inherited from interface com.velocitypowered.api.command.CommandSource
sendMessage
-
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.permission.PermissionSubject
getPermissionValue, hasPermission
-
-
-
-
Method Detail
-
getUsername
String getUsername()
Returns the player's current username.- Returns:
- the username
-
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
-
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()
Returns the current player's ping.- 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
-
sendMessage
@Deprecated default void sendMessage(net.kyori.text.Component component)
Deprecated.Sends a chat message to the player's client.- Specified by:
sendMessagein interfaceCommandSource- Parameters:
component- the chat message to send
-
sendMessage
@Deprecated void sendMessage(net.kyori.text.Component component, MessagePosition position)
Deprecated.Use @deprecated UseAudience.sendMessage(Identified, Component)orAudience.sendMessage(Identity, Component)for chat messages, orAudience.sendActionBar(net.kyori.adventure.text.Component)for action bar messagesSends a chat message to the player's client in the specified position.- Parameters:
component- the chat message to sendposition- the position for the message
-
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.
-
setHeaderAndFooter
@Deprecated void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer)
Deprecated.Sets the tab list header and footer for the player.- Parameters:
header- the header componentfooter- the footer component
-
clearHeaderAndFooter
@Deprecated void clearHeaderAndFooter()
Deprecated.Clears the tab list header and footer for the player.
-
getTabList
TabList getTabList()
Returns the player's tab list.- Returns:
- this player's tab list
-
disconnect
@Deprecated void disconnect(net.kyori.text.Component reason)
Deprecated.Usedisconnect(Component)insteadDisconnects the player with the specified reason. Once this method is called, further calls to otherPlayermethods will become undefined.- Parameters:
reason- component with the reason
-
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
-
sendTitle
@Deprecated void sendTitle(Title title)
Deprecated.Sends the specified title to the client.- Parameters:
title- the title to send
-
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
void sendResourcePack(String url)
Sends 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
void sendResourcePack(String url, byte[] hash)
Sends 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
-
-