Interface Player

    • 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 null if 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 null if 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 other Player methods 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 from url to the user. If at all possible, send the resource pack using sendResourcePack(String, byte[]). To monitor the status of the sent resource pack, subscribe to PlayerResourcePackStatusEvent.
        Parameters:
        url - the URL for the resource pack
      • sendResourcePack

        void sendResourcePack​(String url,
                              byte[] hash)
        Sends the specified resource pack from url to the user, using the specified 20-byte SHA-1 hash. To monitor the status of the sent resource pack, subscribe to PlayerResourcePackStatusEvent.
        Parameters:
        url - the URL for the resource pack
        hash - 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 by connectedServer(). Sends a plugin message to this target.
        Specified by:
        sendPluginMessage in interface ChannelMessageSink
        Parameters:
        identifier - the channel identifier to send the message on
        data - the data to send
        Returns:
        whether or not the message could be sent