Class OfflinePlayer
- Direct Known Subclasses:
ChatPluginProxyPlayer
,ChatPluginServerPlayer
This object contains just two values: a UUID
and a name.
You can manually create offline players to interact with the plugin's code
(for example with the punishment system) from an online player or just a
UUID and a name. They may also be used to interact with the storage.
Note: "offline player" here has nothing to do with non-paid accounts, it simply indicates a player who may or may not be online at the moment.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOfflinePlayer
(UUID uuid, String name) Constructs an offline player using given UUID and name.OfflinePlayer
(PlayerAdapter player) Constructs an offline player using aPlayerAdapter
's UUID and name.OfflinePlayer
(CommandSenderAdapter sender) Constructs an offline player using aCommandSenderAdapter
's UUID and name. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if another object is an instance ofOfflinePlayer
and if this player'sgetUUID()
(if running on online mode) orgetName()
(if running on offline mode) value is equal to the other object's one.static CompletableFuture
<OfflinePlayer> Gets an offline player, possibly from storage, based on the input: a name starting withPlayerManager.getFloodgateUsernamePrefix()
for a Bedrock account any other name whileChatPlugin.isOnlineMode()
for a paid Java account any other name while!
ChatPlugin.isOnlineMode()
for a non-paid Java accountstatic CompletableFuture
<OfflinePlayer> Gets this player's IP address.getName()
Gets this player's name.getUUID()
Gets this player's UUID.int
hashCode()
Gets this player's hash code.boolean
hasPermission
(String permission) Checks if this player has the specified permission.boolean
Checks if this player is contained in theDataContainer.PLAYERS
data container usingStorageConnector.isPlayerStored(OfflinePlayer)
.boolean
isLoaded()
Checks if this player is loaded.boolean
isOnline()
Checks if this player is online.boolean
Checks if this player corresponds to a paid Java or Bedrock account.Gets this player's correspondingPlayerAdapter
object.Gets this player's correspondingChatPluginProxyPlayer
object.Gets this player's correspondingChatPluginServerPlayer
object.
-
Constructor Details
-
OfflinePlayer
Constructs an offline player using aPlayerAdapter
's UUID and name.- Parameters:
player
- Online player
-
OfflinePlayer
Constructs an offline player using aCommandSenderAdapter
's UUID and name.- Parameters:
sender
- Command sender
-
OfflinePlayer
Constructs an offline player using given UUID and name.Note: this constructor is not checked and you should use it only if you are sure that the specified UUID and name correspond to an existing account.
- Parameters:
uuid
- Player's UUIDname
- Player's name
-
-
Method Details
-
isPaidAccount
public boolean isPaidAccount()Checks if this player corresponds to a paid Java or Bedrock account.- Returns:
- Whether this is a paid account
-
equals
Checks if another object is an instance ofOfflinePlayer
and if this player'sgetUUID()
(if running on online mode) orgetName()
(if running on offline mode) value is equal to the other object's one.- Overrides:
equals
in classObject
- Parameters:
obj
- Object to compare- Returns:
- Whether the two objects are equal
- Throws:
IllegalStateException
- IfChatPlugin.isOnlineMode()
cannot be run yet
-
hashCode
public int hashCode()Gets this player's hash code.Will return
getUUID()
's (if running on online mode) orgetName()
's (if running on offline mode) hash code or -1 if the name isnull
.- Overrides:
hashCode
in classObject
- Returns:
- Player's hash code
- Throws:
IllegalStateException
- IfChatPlugin.isOnlineMode()
cannot be run yet
-
getUUID
Gets this player's UUID.- Returns:
- Player's UUID
-
getName
Gets this player's name.- Returns:
- Player's name
-
getIPAddress
Gets this player's IP address.Will grab it from the storage if they are offline, but it will return
null
if they have never joined the server before.Note: BungeeCord supports connections via Unix domain sockets. If this method is called on a player connected through a Unix domain socket, "127.0.0.1" is returned.
- Returns:
- Player's IP address
-
isOnline
public boolean isOnline()Checks if this player is online.- Returns:
- Whether this player is online
-
isLoaded
public boolean isLoaded()Checks if this player is loaded.- Returns:
- Whether this player is loaded
- See Also:
-
hasPlayedBefore
public boolean hasPlayedBefore()Checks if this player is contained in theDataContainer.PLAYERS
data container usingStorageConnector.isPlayerStored(OfflinePlayer)
.- Returns:
- Whether this player has played before
-
hasPermission
Checks if this player has the specified permission.Will always return
false
unlessisOnline()
or aPermissionIntegration
is enabled: in those cases, it will be actually checked.Note: this method might take some time to be executed: async calls are recommended.
- Parameters:
permission
- Permission to check- Returns:
- Whether this player has the permission
-
toAdapter
Gets this player's correspondingPlayerAdapter
object.Will return
null
if!
isOnline()
.- Returns:
- Corresponding
PlayerAdapter
-
toServerPlayer
Gets this player's correspondingChatPluginServerPlayer
object.Will return
null
if!
isLoaded()
.- Returns:
- Corresponding
ChatPluginServerPlayer
- Throws:
UnsupportedOperationException
- IfEnvironment.isProxy()
-
toProxyPlayer
Gets this player's correspondingChatPluginProxyPlayer
object.Will return
null
if!
isLoaded()
.- Returns:
- Corresponding
ChatPluginProxyPlayer
- Throws:
UnsupportedOperationException
- If!
Environment.isProxy()
-
get
Gets an offline player, possibly from storage, based on the input:- a name starting with
PlayerManager.getFloodgateUsernamePrefix()
for a Bedrock account - any other name while
ChatPlugin.isOnlineMode()
for a paid Java account - any other name while
!
ChatPlugin.isOnlineMode()
for a non-paid Java account
The future is instantly completed and will not throw any exception if:
- a player with the specified name is online
- specified name is not a Bedrock username and
!
ChatPlugin.isOnlineMode()
The future throws:
SQLException
if the storage lookup fails andStorageMethod.isDatabase()
InterruptedException
if the future is suddenly interruptedNoSuchElementException
if the name does not belong to a paid Java (ifChatPlugin.isOnlineMode()
) or Bedrock accountIOException
if a connection or JSON error occurs while fetching
- Parameters:
name
- Player's name, case insensitive- Returns:
- New offline player
- Throws:
IllegalArgumentException
- If specified name!
PlayerManager.isValidUsername(String)
- a name starting with
-
get
Gets an offline player, possibly from storage, based on the input:The future throws:
UnsupportedOperationException
ifUUID.version()
== 3
and no name is stored for the specified UUIDSQLException
if the storage lookup fails andStorageMethod.isDatabase()
InterruptedException
if the future is suddenly interruptedNoSuchElementException
ifUUID.version()
!= 3
and it does not belong to a paid Java or Bedrock accountIOException
if a connection or JSON error occurs while fetching
- Parameters:
uuid
- Player's UUID- Returns:
- New offline player
- Throws:
IllegalArgumentException
- IfUUID.version()
is not 0, 3 or 4
-