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 Modifier and Type Method Description ClientSettingsclientSettings()Returns the player's client settings.@Nullable ServerConnectionconnectedServer()Returns the server that the player is currently connected to.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.GameProfilegameProfile()Returns the player's game profile.UUIDid()Returns the player's UUID.@Nullable ModInfomodInfo()Returns the player's mod info if they have a modded client.booleanonlineMode()Returns the player's connection status.longping()Returns the current player's ping.booleansendPluginMessage(PluginChannelId 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)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.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.TabListtabList()Returns the player's tab list.Stringusername()Returns the player's current username.-
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, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, showBossBar, showTitle, stopSound
-
Methods inherited from interface net.kyori.adventure.identity.Identified
identity
-
Methods inherited from interface com.velocitypowered.api.proxy.connection.InboundConnection
connectedHostname, isActive, protocolVersion, remoteAddress
-
Methods inherited from interface com.velocitypowered.api.permission.PermissionSubject
evaluatePermission, hasPermission
-
-
-
-
Method Detail
-
username
String username()
Returns the player's current username.- Returns:
- the username
-
id
UUID id()
Returns the player's UUID.- Returns:
- the UUID
-
connectedServer
@Nullable ServerConnection connectedServer()
Returns the server that the player is currently connected to.- Returns:
- the server that the player is connected to, which could be
nullif no connection was made yet (or the player is switching servers)
-
clientSettings
ClientSettings clientSettings()
Returns the player's client settings.- Returns:
- the settings
-
modInfo
@Nullable ModInfo modInfo()
Returns the player's mod info if they have a modded client.- Returns:
- an the mod info. which may be
nullif no info is available
-
ping
long ping()
Returns the current player's ping.- Returns:
- the player's ping or -1 if ping information is currently unknown
-
onlineMode
boolean onlineMode()
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
-
setGameProfileProperties
void setGameProfileProperties(List<GameProfile.Property> properties)
Sets the player's profile properties.- Parameters:
properties- the properties
-
gameProfile
GameProfile gameProfile()
Returns the player's game profile.
-
tabList
TabList tabList()
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
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
-
sendPluginMessage
boolean sendPluginMessage(PluginChannelId 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 byconnectedServer(). Sends a plugin message to this target.- 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
-
-